Skip to content

Commit

Permalink
Adding pod disruption budget (#1105)
Browse files Browse the repository at this point in the history
Co-authored-by: Sertac Ozercan <sozercan@gmail.com>
  • Loading branch information
mveitas and sozercan committed Feb 23, 2021
1 parent b975ee3 commit 6d99979
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/build/helmify/kustomize-for-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ webhooks:
path: /v1/admitlabel
name: check-ignore-label.gatekeeper.sh
timeoutSeconds: HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: gatekeeper-controller-manager
namespace: gatekeeper-system
spec:
minAvailable: HELMSUBST_PDB_CONTROLLER_MANAGER_MINAVAILABLE
selector:
matchLabels:
control-plane: controller-manager
gatekeeper.sh/operation: webhook
gatekeeper.sh/system: "yes"
2 changes: 2 additions & 0 deletions cmd/build/helmify/replacements.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ var replacements = map[string]string{
{{- if .Values.enableDeleteOperations }}
- DELETE
{{- end}}`,

"HELMSUBST_PDB_CONTROLLER_MANAGER_MINAVAILABLE": `{{ .Values.pdb.controllerManager.minAvailable }}`,
}
1 change: 1 addition & 0 deletions cmd/build/helmify/static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
| podLabels | The labels to add to the Gatekeeper pods | `{}` |
| secretAnnotations | The annotations to add to the Gatekeeper secrets | `{}` |
| customResourceDefinitions.create | Whether the release should install CRDs. Regardless of this value, Helm v3+ will install the CRDs if those are not present already. Use --skip-crds with helm install if you want to skip CRD creation | `true` |
| pdb.controllerManager.minAvailable | The number of controller manager pods that must still be available after an eviction | 1 |

## Contributing Changes

Expand Down
3 changes: 3 additions & 0 deletions cmd/build/helmify/static/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ audit:
memory: 256Mi
customResourceDefinitions:
create: true
pdb:
controllerManager:
minAvailable: 1
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bases:
- ../crd
- ../rbac
- ../manager
- ../pdb
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in crd/kustomization.yaml
- ../webhook
- ../secret
Expand Down
2 changes: 2 additions & 0 deletions config/pdb/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- pdb.yaml
10 changes: 10 additions & 0 deletions config/pdb/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: controller-manager
spec:
minAvailable: 1
selector:
matchLabels:
control-plane: controller-manager
gatekeeper.sh/operation: webhook
1 change: 1 addition & 0 deletions manifest_staging/charts/gatekeeper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
| podLabels | The labels to add to the Gatekeeper pods | `{}` |
| secretAnnotations | The annotations to add to the Gatekeeper secrets | `{}` |
| customResourceDefinitions.create | Whether the release should install CRDs. Regardless of this value, Helm v3+ will install the CRDs if those are not present already. Use --skip-crds with helm install if you want to skip CRD creation | `true` |
| pdb.controllerManager.minAvailable | The number of controller manager pods that must still be available after an eviction | 1 |

## Contributing Changes

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
labels:
app: '{{ template "gatekeeper.name" . }}'
chart: '{{ template "gatekeeper.name" . }}'
gatekeeper.sh/system: "yes"
heritage: '{{ .Release.Service }}'
release: '{{ .Release.Name }}'
name: gatekeeper-controller-manager
namespace: gatekeeper-system
spec:
minAvailable: {{ .Values.pdb.controllerManager.minAvailable }}
selector:
matchLabels:
app: '{{ template "gatekeeper.name" . }}'
chart: '{{ template "gatekeeper.name" . }}'
control-plane: controller-manager
gatekeeper.sh/operation: webhook
gatekeeper.sh/system: "yes"
heritage: '{{ .Release.Service }}'
release: '{{ .Release.Name }}'
3 changes: 3 additions & 0 deletions manifest_staging/charts/gatekeeper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ audit:
memory: 256Mi
customResourceDefinitions:
create: true
pdb:
controllerManager:
minAvailable: 1
15 changes: 15 additions & 0 deletions manifest_staging/deploy/gatekeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,21 @@ spec:
defaultMode: 420
secretName: gatekeeper-webhook-server-cert
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
labels:
gatekeeper.sh/system: "yes"
name: gatekeeper-controller-manager
namespace: gatekeeper-system
spec:
minAvailable: 1
selector:
matchLabels:
control-plane: controller-manager
gatekeeper.sh/operation: webhook
gatekeeper.sh/system: "yes"
---
apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingWebhookConfiguration
metadata:
Expand Down

0 comments on commit 6d99979

Please sign in to comment.