This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement pre-delete hook for graceful delete of spiffe-oidc-discover…
…y-provider (#353)
- Loading branch information
1 parent
a6dcf26
commit c11a8c0
Showing
10 changed files
with
108 additions
and
14 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 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 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
71 changes: 71 additions & 0 deletions
71
charts/spire/charts/spiffe-oidc-discovery-provider/templates/pre-delete-hook.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,71 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "spiffe-oidc-discovery-provider.serviceAccountName" . }}-pre-delete | ||
namespace: {{ include "spiffe-oidc-discovery-provider.namespace" . }} | ||
labels: | ||
{{- include "spiffe-oidc-discovery-provider.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": pre-delete | ||
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "spiffe-oidc-discovery-provider.fullname" . }}-pre-delete | ||
annotations: | ||
"helm.sh/hook": pre-delete | ||
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed | ||
rules: | ||
- apiGroups: ["apps"] | ||
resources: ["deployments"] | ||
resourceNames: [{{ include "spiffe-oidc-discovery-provider.fullname" . | quote }}] | ||
verbs: ["get", "delete"] | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: {{ include "spiffe-oidc-discovery-provider.fullname" . }}-pre-delete | ||
annotations: | ||
"helm.sh/hook": pre-delete | ||
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "spiffe-oidc-discovery-provider.serviceAccountName" . }}-pre-delete | ||
namespace: {{ include "spiffe-oidc-discovery-provider.namespace" . }} | ||
roleRef: | ||
kind: Role | ||
name: {{ include "spiffe-oidc-discovery-provider.fullname" . }}-pre-delete | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "spiffe-oidc-discovery-provider.fullname" . }}-pre-delete | ||
namespace: {{ include "spiffe-oidc-discovery-provider.namespace" . }} | ||
labels: | ||
{{- include "spiffe-oidc-discovery-provider.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": pre-delete | ||
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed | ||
spec: | ||
template: | ||
metadata: | ||
name: {{ include "spiffe-oidc-discovery-provider.fullname" . }}-pre-delete | ||
spec: | ||
restartPolicy: Never | ||
serviceAccountName: {{ include "spiffe-oidc-discovery-provider.serviceAccountName" . }}-pre-delete | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
containers: | ||
- name: pre-delete-job | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 10 }} | ||
image: {{ template "spire-lib.kubectl-image" (dict "appVersion" $.Chart.AppVersion "image" .Values.tools.kubectl.image "global" .Values.global "KubeVersion" .Capabilities.KubeVersion.Version) }} | ||
args: | ||
- delete | ||
- -n | ||
- {{ include "spiffe-oidc-discovery-provider.namespace" . }} | ||
- deployment | ||
- {{ include "spiffe-oidc-discovery-provider.fullname" . }} | ||
- --wait |
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 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 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 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 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 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