Skip to content

Commit ad8e59d

Browse files
committed
Remove webhook
1 parent dc75a6e commit ad8e59d

10 files changed

+4
-359
lines changed

assets/assets.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"embed"
55
)
66

7-
//go:embed *.yaml rbac/*.yaml
7+
//go:embed *.yaml
88
var f embed.FS
99

1010
// ReadFile reads and returns the content of the named file.

assets/rbac/webhook_clusterrole.yaml

-11
This file was deleted.

assets/rbac/webhook_clusterrolebinding.yaml

-12
This file was deleted.

assets/webhook_config.yaml

-42
This file was deleted.

assets/webhook_deployment.yaml

-83
This file was deleted.

assets/webhook_deployment_pdb.yaml

-11
This file was deleted.

assets/webhook_service.yaml

-18
This file was deleted.

assets/webhook_serviceaccount.yaml

-5
This file was deleted.

pkg/operator/starter.go

+3-81
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"github.com/openshift/library-go/pkg/operator/staticresourcecontroller"
3232
"github.com/openshift/library-go/pkg/operator/status"
3333
"github.com/openshift/library-go/pkg/operator/v1helpers"
34-
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
3534
appsv1 "k8s.io/api/apps/v1"
3635
corev1 "k8s.io/api/core/v1"
3736
v1 "k8s.io/api/core/v1"
@@ -43,7 +42,6 @@ import (
4342
"k8s.io/apimachinery/pkg/runtime/schema"
4443
"k8s.io/client-go/dynamic"
4544
"k8s.io/client-go/dynamic/dynamicinformer"
46-
informercorev1 "k8s.io/client-go/informers/core/v1"
4745
kubeclient "k8s.io/client-go/kubernetes"
4846
"k8s.io/client-go/rest"
4947
"k8s.io/client-go/tools/cache"
@@ -59,12 +57,10 @@ const (
5957
operatorVersionEnvName = "OPERATOR_IMAGE_VERSION"
6058
operandVersionEnvName = "OPERAND_IMAGE_VERSION"
6159
operandImageEnvName = "OPERAND_IMAGE"
62-
webhookImageEnvName = "WEBHOOK_IMAGE"
6360

6461
defaultPriorityClass = "system-cluster-critical"
6562
hypershiftPriorityClass = "hypershift-control-plane"
6663
hyperShiftPullSecretName = "pull-secret"
67-
webhookSecretName = "csi-snapshot-webhook-secret"
6864

6965
resync = 20 * time.Minute
7066
)
@@ -179,8 +175,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
179175
"CSISnapshotGuestStaticResourceController",
180176
namespacedAssetFunc,
181177
[]string{
182-
"rbac/webhook_clusterrole.yaml",
183-
"rbac/webhook_clusterrolebinding.yaml",
184178
"volumesnapshots.yaml",
185179
"volumesnapshotcontents.yaml",
186180
"volumesnapshotclasses.yaml",
@@ -204,8 +198,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
204198
namespacedAssetFunc,
205199
[]string{
206200
"serviceaccount.yaml",
207-
"webhook_serviceaccount.yaml",
208-
"webhook_service.yaml",
209201
},
210202
resourceapply.NewKubeClientHolder(controlPlaneKubeClient),
211203
guestOperatorClient,
@@ -215,7 +207,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
215207
namespacedAssetFunc,
216208
[]string{
217209
"csi_controller_deployment_pdb.yaml",
218-
"webhook_deployment_pdb.yaml",
219210
},
220211
func() bool {
221212
if isHyperShift {
@@ -242,23 +233,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
242233
return err
243234
}
244235

245-
var webhookHooks []validatingWebhookConfigHook
246-
if isHyperShift {
247-
webhookHooks = []validatingWebhookConfigHook{
248-
hyperShiftSetWebhookService(),
249-
}
250-
}
251-
webhookController := NewValidatingWebhookConfigController(
252-
"WebhookController",
253-
guestOperatorClient,
254-
guestKubeClient,
255-
guestKubeInformersForNamespaces.InformersFor("").Admissionregistration().V1().ValidatingWebhookConfigurations(),
256-
namespacedAssetFunc,
257-
"webhook_config.yaml",
258-
eventRecorder,
259-
webhookHooks,
260-
)
261-
262236
priorityClass := defaultPriorityClass
263237
var deploymentHooks []dc.DeploymentHookFunc
264238
deploymentInformers := []factory.Informer{
@@ -286,6 +260,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
286260
hyperShiftColocationHook(controlPlaneNamespace),
287261
hyperShiftNodeSelectorHook(hcpInformer.Lister(), controlPlaneNamespace),
288262
hyperShiftSetSecurityContext(),
263+
withVolumeGroupSnapshot(volumeGroupSnapshotAPIEnabled),
289264
}
290265

291266
} else {
@@ -295,7 +270,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
295270
csidrivercontrollerservicecontroller.WithReplicasHook(
296271
guestConfigInformers,
297272
),
298-
withVolumeGroupSnapshotWebhook(volumeGroupSnapshotAPIEnabled),
273+
withVolumeGroupSnapshot(volumeGroupSnapshotAPIEnabled),
299274
}
300275
}
301276
controllerDeploymentController := dc.NewDeploymentController(
@@ -312,41 +287,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
312287
deploymentHooks...,
313288
)
314289

315-
webhookDeploymentManifest, err := namespacedAssetFunc("webhook_deployment.yaml")
316-
if err != nil {
317-
return err
318-
}
319-
var secretInformer informercorev1.SecretInformer
320-
if isHyperShift {
321-
secretInformer = controlPlaneInformersForNamespaces.InformersFor(controlPlaneNamespace).Core().V1().Secrets()
322-
} else {
323-
secretInformer = guestKubeInformersForNamespaces.InformersFor(controlPlaneNamespace).Core().V1().Secrets()
324-
}
325-
deploymentHooks = append(deploymentHooks, csidrivercontrollerservicecontroller.WithSecretHashAnnotationHook(
326-
guestNamespace,
327-
webhookSecretName,
328-
secretInformer,
329-
))
330-
webhookDeploymentController := dc.NewDeploymentController(
331-
// Name of this controller must match SISnapshotWebhookController from 4.11
332-
// so it "adopts" its conditions during upgrade
333-
"CSISnapshotWebhookController",
334-
webhookDeploymentManifest,
335-
eventRecorder,
336-
guestOperatorClient,
337-
controlPlaneKubeClient,
338-
controlPlaneInformersForNamespaces.InformersFor(controlPlaneNamespace).Apps().V1().Deployments(),
339-
[]factory.Informer{
340-
guestKubeInformersForNamespaces.InformersFor("").Core().V1().Nodes().Informer(),
341-
guestConfigInformers.Config().V1().Infrastructures().Informer(),
342-
secretInformer.Informer(),
343-
},
344-
[]dc.ManifestHookFunc{
345-
replacePlaceholdersHook(os.Getenv(webhookImageEnvName), priorityClass),
346-
},
347-
deploymentHooks...,
348-
)
349-
350290
versionController := NewVersionController(
351291
"VersionController",
352292
guestOperatorClient,
@@ -410,12 +350,10 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
410350
logLevelController,
411351
managementStateController,
412352
controllerDeploymentController,
413-
webhookDeploymentController,
414353
versionController,
415354
cndController,
416355
guestStaticResourceController,
417356
controlPlaneStaticResourcesController,
418-
webhookController,
419357
} {
420358
if controller != nil {
421359
go controller.Run(ctx, 1)
@@ -702,20 +640,6 @@ func hyperShiftAddKubeConfigVolume(secretName string) dc.DeploymentHookFunc {
702640
}
703641
}
704642

705-
func hyperShiftSetWebhookService() validatingWebhookConfigHook {
706-
return func(configuration *admissionregistrationv1.ValidatingWebhookConfiguration) error {
707-
for i := range configuration.Webhooks {
708-
webhook := &configuration.Webhooks[i]
709-
webhook.ClientConfig.Service = nil
710-
// Name of csi-snapshot-webhook service in the same namespace as the guest API server.
711-
url := "https://csi-snapshot-webhook"
712-
webhook.ClientConfig.URL = &url
713-
}
714-
715-
return nil
716-
}
717-
}
718-
719643
func hyperShiftAddPullSecret() dc.DeploymentHookFunc {
720644
return func(_ *operatorv1.OperatorSpec, deployment *appsv1.Deployment) error {
721645
if deployment.Spec.Template.Spec.ImagePullSecrets == nil {
@@ -740,7 +664,7 @@ func namespaceReplacer(assetFunc resourceapply.AssetFunc, placeholder, namespace
740664
}
741665
}
742666

743-
func withVolumeGroupSnapshotWebhook(enabled bool) dc.DeploymentHookFunc {
667+
func withVolumeGroupSnapshot(enabled bool) dc.DeploymentHookFunc {
744668
return func(_ *operatorv1.OperatorSpec, deployment *appsv1.Deployment) error {
745669
if !enabled {
746670
return nil
@@ -750,8 +674,6 @@ func withVolumeGroupSnapshotWebhook(enabled bool) dc.DeploymentHookFunc {
750674
switch container.Name {
751675
case "snapshot-controller":
752676
container.Args = append(container.Args, "-feature-gates=CSIVolumeGroupSnapshot=true")
753-
case "webhook":
754-
container.Args = append(container.Args, "-feature-gates=CSIVolumeGroupSnapshot=true")
755677
}
756678
}
757679
return nil

0 commit comments

Comments
 (0)