@@ -31,7 +31,6 @@ import (
31
31
"github.com/openshift/library-go/pkg/operator/staticresourcecontroller"
32
32
"github.com/openshift/library-go/pkg/operator/status"
33
33
"github.com/openshift/library-go/pkg/operator/v1helpers"
34
- admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
35
34
appsv1 "k8s.io/api/apps/v1"
36
35
corev1 "k8s.io/api/core/v1"
37
36
v1 "k8s.io/api/core/v1"
@@ -43,7 +42,6 @@ import (
43
42
"k8s.io/apimachinery/pkg/runtime/schema"
44
43
"k8s.io/client-go/dynamic"
45
44
"k8s.io/client-go/dynamic/dynamicinformer"
46
- informercorev1 "k8s.io/client-go/informers/core/v1"
47
45
kubeclient "k8s.io/client-go/kubernetes"
48
46
"k8s.io/client-go/rest"
49
47
"k8s.io/client-go/tools/cache"
@@ -59,12 +57,10 @@ const (
59
57
operatorVersionEnvName = "OPERATOR_IMAGE_VERSION"
60
58
operandVersionEnvName = "OPERAND_IMAGE_VERSION"
61
59
operandImageEnvName = "OPERAND_IMAGE"
62
- webhookImageEnvName = "WEBHOOK_IMAGE"
63
60
64
61
defaultPriorityClass = "system-cluster-critical"
65
62
hypershiftPriorityClass = "hypershift-control-plane"
66
63
hyperShiftPullSecretName = "pull-secret"
67
- webhookSecretName = "csi-snapshot-webhook-secret"
68
64
69
65
resync = 20 * time .Minute
70
66
)
@@ -179,8 +175,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
179
175
"CSISnapshotGuestStaticResourceController" ,
180
176
namespacedAssetFunc ,
181
177
[]string {
182
- "rbac/webhook_clusterrole.yaml" ,
183
- "rbac/webhook_clusterrolebinding.yaml" ,
184
178
"volumesnapshots.yaml" ,
185
179
"volumesnapshotcontents.yaml" ,
186
180
"volumesnapshotclasses.yaml" ,
@@ -204,8 +198,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
204
198
namespacedAssetFunc ,
205
199
[]string {
206
200
"serviceaccount.yaml" ,
207
- "webhook_serviceaccount.yaml" ,
208
- "webhook_service.yaml" ,
209
201
},
210
202
resourceapply .NewKubeClientHolder (controlPlaneKubeClient ),
211
203
guestOperatorClient ,
@@ -215,7 +207,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
215
207
namespacedAssetFunc ,
216
208
[]string {
217
209
"csi_controller_deployment_pdb.yaml" ,
218
- "webhook_deployment_pdb.yaml" ,
219
210
},
220
211
func () bool {
221
212
if isHyperShift {
@@ -242,23 +233,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
242
233
return err
243
234
}
244
235
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
-
262
236
priorityClass := defaultPriorityClass
263
237
var deploymentHooks []dc.DeploymentHookFunc
264
238
deploymentInformers := []factory.Informer {
@@ -286,6 +260,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
286
260
hyperShiftColocationHook (controlPlaneNamespace ),
287
261
hyperShiftNodeSelectorHook (hcpInformer .Lister (), controlPlaneNamespace ),
288
262
hyperShiftSetSecurityContext (),
263
+ withVolumeGroupSnapshot (volumeGroupSnapshotAPIEnabled ),
289
264
}
290
265
291
266
} else {
@@ -295,7 +270,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
295
270
csidrivercontrollerservicecontroller .WithReplicasHook (
296
271
guestConfigInformers ,
297
272
),
298
- withVolumeGroupSnapshotWebhook (volumeGroupSnapshotAPIEnabled ),
273
+ withVolumeGroupSnapshot (volumeGroupSnapshotAPIEnabled ),
299
274
}
300
275
}
301
276
controllerDeploymentController := dc .NewDeploymentController (
@@ -312,41 +287,6 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
312
287
deploymentHooks ... ,
313
288
)
314
289
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
-
350
290
versionController := NewVersionController (
351
291
"VersionController" ,
352
292
guestOperatorClient ,
@@ -410,12 +350,10 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
410
350
logLevelController ,
411
351
managementStateController ,
412
352
controllerDeploymentController ,
413
- webhookDeploymentController ,
414
353
versionController ,
415
354
cndController ,
416
355
guestStaticResourceController ,
417
356
controlPlaneStaticResourcesController ,
418
- webhookController ,
419
357
} {
420
358
if controller != nil {
421
359
go controller .Run (ctx , 1 )
@@ -702,20 +640,6 @@ func hyperShiftAddKubeConfigVolume(secretName string) dc.DeploymentHookFunc {
702
640
}
703
641
}
704
642
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
-
719
643
func hyperShiftAddPullSecret () dc.DeploymentHookFunc {
720
644
return func (_ * operatorv1.OperatorSpec , deployment * appsv1.Deployment ) error {
721
645
if deployment .Spec .Template .Spec .ImagePullSecrets == nil {
@@ -740,7 +664,7 @@ func namespaceReplacer(assetFunc resourceapply.AssetFunc, placeholder, namespace
740
664
}
741
665
}
742
666
743
- func withVolumeGroupSnapshotWebhook (enabled bool ) dc.DeploymentHookFunc {
667
+ func withVolumeGroupSnapshot (enabled bool ) dc.DeploymentHookFunc {
744
668
return func (_ * operatorv1.OperatorSpec , deployment * appsv1.Deployment ) error {
745
669
if ! enabled {
746
670
return nil
@@ -750,8 +674,6 @@ func withVolumeGroupSnapshotWebhook(enabled bool) dc.DeploymentHookFunc {
750
674
switch container .Name {
751
675
case "snapshot-controller" :
752
676
container .Args = append (container .Args , "-feature-gates=CSIVolumeGroupSnapshot=true" )
753
- case "webhook" :
754
- container .Args = append (container .Args , "-feature-gates=CSIVolumeGroupSnapshot=true" )
755
677
}
756
678
}
757
679
return nil
0 commit comments