Skip to content

Commit

Permalink
Apply proxy config to Deployment containers
Browse files Browse the repository at this point in the history
  • Loading branch information
bertinatto committed Jan 13, 2021
1 parent ff52bd9 commit 90b2324
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions assets/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apps/v1
metadata:
name: aws-ebs-csi-driver-controller
namespace: openshift-cluster-csi-drivers
annotations:
config.openshift.io/inject-proxy: csi-driver
spec:
selector:
matchLabels:
Expand Down
2 changes: 2 additions & 0 deletions assets/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apps/v1
metadata:
name: aws-ebs-csi-driver-node
namespace: openshift-cluster-csi-drivers
annotations:
config.openshift.io/inject-proxy: csi-driver
spec:
selector:
matchLabels:
Expand Down
4 changes: 4 additions & 0 deletions pkg/generated/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/openshift/library-go/pkg/controller/factory"
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/resource/resourcehash"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -21,8 +22,9 @@ import (
configinformers "github.com/openshift/client-go/config/informers/externalversions"
"github.com/openshift/library-go/pkg/controller/controllercmd"
"github.com/openshift/library-go/pkg/operator/csi/csicontrollerset"
"github.com/openshift/library-go/pkg/operator/csi/csidrivercontrollerservicecontroller"
"github.com/openshift/library-go/pkg/operator/csi/csidrivernodeservicecontroller"
goc "github.com/openshift/library-go/pkg/operator/genericoperatorclient"
"github.com/openshift/library-go/pkg/operator/resource/resourcehash"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
"github.com/openshift/library-go/pkg/operator/v1helpers"

Expand Down Expand Up @@ -86,6 +88,9 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
"rbac/snapshotter_role.yaml",
"rbac/snapshotter_binding.yaml",
},
).WithCSIConfigObserverController(
"AWSEBSDriverCSIConfigObserverController",
configInformers,
).WithCSIDriverControllerService(
"AWSEBSDriverControllerServiceController",
withCustomCABundle(generated.MustAsset, kubeClient),
Expand All @@ -94,12 +99,14 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
kubeInformersForNamespaces.InformersFor(defaultNamespace),
configInformers,
withSecretHashAnnotation(kubeInformersForNamespaces, defaultNamespace, secretName),
csidrivercontrollerservicecontroller.WithObservedProxyDeploymentHook(),
).WithCSIDriverNodeService(
"AWSEBSDriverNodeServiceController",
generated.MustAsset,
"node.yaml",
kubeClient,
kubeInformersForNamespaces.InformersFor(defaultNamespace),
csidrivernodeservicecontroller.WithObservedProxyDaemonSetHook(),
)

if err != nil {
Expand Down Expand Up @@ -201,8 +208,8 @@ func isCustomCABundleUsed(kubeClient kubeclient.Interface) (bool, error) {
return exists, nil
}

func withSecretHashAnnotation(kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces, namespace, secret string) func(*appsv1.Deployment) error {
return func(deployment *appsv1.Deployment) error {
func withSecretHashAnnotation(kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces, namespace, secret string) func(*opv1.OperatorSpec, *appsv1.Deployment) error {
return func(opSpec *opv1.OperatorSpec, deployment *appsv1.Deployment) error {
inputHashes, err := resourcehash.MultipleObjectHashStringMapForObjectReferenceFromLister(
kubeInformersForNamespaces.InformersFor(namespace).Core().V1().ConfigMaps().Lister(),
kubeInformersForNamespaces.InformersFor(namespace).Core().V1().Secrets().Lister(),
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/starter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ apiVersion: apps/v1
metadata:
name: aws-ebs-csi-driver-controller
namespace: openshift-cluster-csi-drivers
annotations:
config.openshift.io/inject-proxy: csi-driver
spec:
selector:
matchLabels:
Expand Down Expand Up @@ -181,6 +183,8 @@ apiVersion: apps/v1
metadata:
name: aws-ebs-csi-driver-controller
namespace: openshift-cluster-csi-drivers
annotations:
config.openshift.io/inject-proxy: csi-driver
spec:
selector:
matchLabels:
Expand Down

0 comments on commit 90b2324

Please sign in to comment.