forked from kanisterio/kanister
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create certificate for webhook with "kube-webhook-certgen"
Fixes kanisterio#1345
- Loading branch information
Showing
11 changed files
with
203 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
rules: | ||
- apiGroups: | ||
- admissionregistration.k8s.io | ||
resources: | ||
- validatingwebhookconfigurations | ||
verbs: | ||
- get | ||
- update | ||
{{- end }} |
17 changes: 17 additions & 0 deletions
17
helm/kanister-operator/templates/webhook/clusterrolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
namespace: {{ .Release.Namespace | quote }} | ||
{{- end }} |
47 changes: 47 additions & 0 deletions
47
helm/kanister-operator/templates/webhook/job-createSecret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission-create | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
spec: | ||
{{- if .Capabilities.APIVersions.Has "batch/v1alpha1" }} | ||
# Alpha feature since k8s 1.12 | ||
ttlSecondsAfterFinished: 0 | ||
{{- end }} | ||
template: | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission-create | ||
spec: | ||
containers: | ||
- name: create | ||
{{- with .Values.bpValidatingWebhook.image }} | ||
image: "{{ .repository }}/{{ .image }}:{{ .tag }}" | ||
{{- end }} | ||
imagePullPolicy: {{ .Values.bpValidatingWebhook.image.pullPolicy }} | ||
args: | ||
- create | ||
- --host={{ include "kanister-operator.fullname" . }},{{ include "kanister-operator.fullname" . }}.$(POD_NAMESPACE).svc | ||
- --namespace=$(POD_NAMESPACE) | ||
- --secret-name={{ include "kanister-operator.fullname" . }}-admission | ||
- --key-name=tls.key | ||
- --cert-name=tls.crt | ||
env: | ||
- name: foo | ||
value: bar | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
restartPolicy: OnFailure | ||
serviceAccountName: {{ include "kanister-operator.fullname" . }}-admission | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: {{ .Values.bpValidatingWebhook.runAsUser }} | ||
fsGroup: {{ .Values.bpValidatingWebhook.fsGroup }} | ||
{{- end }} |
45 changes: 45 additions & 0 deletions
45
helm/kanister-operator/templates/webhook/job-patchWebhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission-patch | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
"helm.sh/hook": post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
spec: | ||
{{- if .Capabilities.APIVersions.Has "batch/v1alpha1" }} | ||
# Alpha feature since k8s 1.12 | ||
ttlSecondsAfterFinished: 0 | ||
{{- end }} | ||
template: | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission-patch | ||
spec: | ||
containers: | ||
- name: patch | ||
{{- with .Values.bpValidatingWebhook.image }} | ||
image: "{{ .repository }}/{{ .image }}:{{ .tag }}" | ||
{{- end }} | ||
imagePullPolicy: {{ .Values.bpValidatingWebhook.image.pullPolicy }} | ||
args: | ||
- patch | ||
- --webhook-name=blueprints.cr.kanister.io | ||
- --namespace=$(POD_NAMESPACE) | ||
- --patch-mutating=false | ||
- --secret-name={{ include "kanister-operator.fullname" . }}-admission | ||
- --patch-failure-policy={{ .Values.bpValidatingWebhook.failurePolicy }} | ||
env: | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
restartPolicy: OnFailure | ||
serviceAccountName: {{ include "kanister-operator.fullname" . }}-admission | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: {{ .Values.bpValidatingWebhook.runAsUser }} | ||
fsGroup: {{ .Values.bpValidatingWebhook.fsGroup }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
namespace: {{ .Release.Namespace | quote }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- get | ||
- create | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
namespace: {{ .Release.Namespace | quote }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
{{- end }} |
10 changes: 10 additions & 0 deletions
10
helm/kanister-operator/templates/webhook/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "kanister-operator.fullname" . }}-admission | ||
namespace: {{ .Release.Namespace | quote }} | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
{{- end }} |
23 changes: 23 additions & 0 deletions
23
helm/kanister-operator/templates/webhook/validating-webhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if .Values.bpValidatingWebhook.enabled -}} | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: ValidatingWebhookConfiguration | ||
metadata: | ||
name: "blueprints.cr.kanister.io" | ||
webhooks: | ||
- name: "blueprints.cr.kanister.io" | ||
rules: | ||
- apiGroups: ["cr.kanister.io"] | ||
apiVersions: ["v1alpha1"] | ||
operations: ["CREATE", "UPDATE"] | ||
resources: ["blueprints"] | ||
scope: "Namespaced" | ||
clientConfig: | ||
service: | ||
namespace: {{ .Release.Namespace }} | ||
name: {{ template "kanister-operator.fullname" . }} | ||
path: "/validate/v1alpha1/blueprint" | ||
port: {{ .Values.controller.service.port }} | ||
admissionReviewVersions: ["v1", "v1beta1"] | ||
sideEffects: None | ||
timeoutSeconds: 5 | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters