Skip to content

Commit 0d5c769

Browse files
committed
minor fixes
1 parent 3057adb commit 0d5c769

File tree

6 files changed

+87
-3
lines changed

6 files changed

+87
-3
lines changed

chart/templates/deploymentpolicy-crd.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
4+
name: deploymentpolicies.skyhook.nvidia.com
45
annotations:
56
controller-gen.kubebuilder.io/version: v0.18.0
6-
name: deploymentpolicies.skyhook.nvidia.com
7+
labels:
8+
{{- include "chart.labels" . | nindent 4 }}
79
spec:
10+
conversion:
11+
strategy: Webhook
12+
webhook:
13+
clientConfig:
14+
service:
15+
name: skyhook-operator-webhook-service
16+
namespace: '{{ .Release.Namespace }}'
17+
path: /convert
18+
conversionReviewVersions:
19+
- v1
820
group: skyhook.nvidia.com
921
names:
1022
kind: DeploymentPolicy

chart/templates/mutating-webhook.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,32 @@ webhooks:
3232
scope: '*'
3333
sideEffects: None
3434
timeoutSeconds: 10
35+
- admissionReviewVersions:
36+
- v1
37+
clientConfig:
38+
caBundle: ""
39+
service:
40+
name: skyhook-operator-webhook-service
41+
namespace: {{ .Release.Namespace }}
42+
path: /mutate-skyhook-nvidia-com-v1alpha1-deploymentpolicy
43+
port: 443
44+
failurePolicy: Fail
45+
matchPolicy: Equivalent
46+
name: mutate-deploymentpolicy.nvidia.com
47+
namespaceSelector: {}
48+
objectSelector: {}
49+
reinvocationPolicy: Never
50+
rules:
51+
- apiGroups:
52+
- skyhook.nvidia.com
53+
apiVersions:
54+
- v1alpha1
55+
operations:
56+
- CREATE
57+
- UPDATE
58+
resources:
59+
- deploymentpolicies
60+
scope: '*'
61+
sideEffects: None
62+
timeoutSeconds: 10
3563
{{- end }}

chart/templates/validating-webhook.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,31 @@ webhooks:
3131
scope: '*'
3232
sideEffects: None
3333
timeoutSeconds: 10
34+
- admissionReviewVersions:
35+
- v1
36+
clientConfig:
37+
caBundle: ""
38+
service:
39+
name: skyhook-operator-webhook-service
40+
namespace: {{ .Release.Namespace }}
41+
path: /validate-skyhook-nvidia-com-v1alpha1-deploymentpolicy
42+
port: 443
43+
failurePolicy: Fail
44+
matchPolicy: Equivalent
45+
name: validate-deploymentpolicy.nvidia.com
46+
namespaceSelector: {}
47+
objectSelector: {}
48+
rules:
49+
- apiGroups:
50+
- skyhook.nvidia.com
51+
apiVersions:
52+
- v1alpha1
53+
operations:
54+
- CREATE
55+
- UPDATE
56+
resources:
57+
- deploymentpolicies
58+
scope: '*'
59+
sideEffects: None
60+
timeoutSeconds: 10
3461
{{- end }}

operator/api/v1alpha1/deployment_policy_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ func (r *DeploymentPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error {
4646

4747
//+kubebuilder:webhook:path=/mutate-skyhook-nvidia-com-v1alpha1-deploymentpolicy,mutating=true,failurePolicy=fail,sideEffects=None,groups=skyhook.nvidia.com,resources=deploymentpolicies,verbs=create;update,versions=v1alpha1,name=mdeploymentpolicy.kb.io,admissionReviewVersions=v1
4848

49-
// SkyhookWebhook handles validation and defaulting for Skyhook resources
49+
// DeploymentPolicyWebhook handles validation and defaulting for DeploymentPolicy resources
5050
// +kubebuilder:object:generate=false
5151
type DeploymentPolicyWebhook struct {
5252
}
5353

54-
var _ admission.CustomDefaulter = &SkyhookWebhook{}
54+
var _ admission.CustomDefaulter = &DeploymentPolicyWebhook{}
5555

5656
// Default implements webhook.Defaulter so a webhook will be registered for the type
5757
func (r *DeploymentPolicyWebhook) Default(ctx context.Context, obj runtime.Object) error {

operator/config/crd/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# It should be run by config/default
2020
resources:
2121
- bases/skyhook.nvidia.com_skyhooks.yaml
22+
- bases/skyhook.nvidia.com_deploymentpolicies.yaml
2223

2324
patches:
2425
- path: patches/webhook_in_skyhooks.yaml

operator/internal/controller/webhook_controller.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ func webhookMutatingWebhookConfiguration(namespace, serviceName string, secret *
309309
SideEffects: ptr(admissionregistrationv1.SideEffectClassNone),
310310
AdmissionReviewVersions: []string{"v1"},
311311
},
312+
{
313+
Name: "mutate-deploymentpolicy.nvidia.com",
314+
ClientConfig: webhookClient(serviceName, namespace, "/mutate-skyhook-nvidia-com-v1alpha1-deploymentpolicy", secret),
315+
FailurePolicy: ptr(admissionregistrationv1.Fail),
316+
Rules: webhookRule(),
317+
SideEffects: ptr(admissionregistrationv1.SideEffectClassNone),
318+
AdmissionReviewVersions: []string{"v1"},
319+
},
312320
},
313321
}
314322

@@ -360,6 +368,14 @@ func webhookRule() []admissionregistrationv1.RuleWithOperations {
360368
Resources: []string{"skyhooks"},
361369
},
362370
},
371+
{
372+
Operations: []admissionregistrationv1.OperationType{admissionregistrationv1.Create, admissionregistrationv1.Update},
373+
Rule: admissionregistrationv1.Rule{
374+
APIGroups: []string{v1alpha1.GroupVersion.Group},
375+
APIVersions: []string{v1alpha1.GroupVersion.Version},
376+
Resources: []string{"deploymentpolicies"},
377+
},
378+
},
363379
}
364380
}
365381

0 commit comments

Comments
 (0)