Skip to content

Commit 99438af

Browse files
author
Martin Linkhorst
committed
switch to generic deny-all admitter, match conditions and fail policy
1 parent b077696 commit 99438af

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

cluster/config-defaults.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,9 @@ teapot_admission_controller_configmap_deletion_protection_factories_enabled: "tr
677677
# enable the rolebinding admission-controller webhook which validates rolebindings and clusterrolebindings
678678
teapot_admission_controller_enable_rolebinding_webhook: "true"
679679

680-
# enable the generic admission-controller webhook which catches all resources
681-
teapot_admission_controller_enable_generic_webhook: "false"
682-
# prevent write operations for non-admin users in protected namespaces
680+
# enable the generic deny-all admission webhook which rejects all requests it receives
681+
teapot_admission_controller_enable_write_protection_webhook: "false"
682+
# configure the behaviour of the deny-all admission webhook, `true` blocks everything, `false` allows everything
683683
teapot_admission_controller_prevent_write_operations: "false"
684684

685685
# Enable and configure Pod Security Policy rules implemented in admission-controller.

cluster/manifests/01-admission-control/teapot.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ webhooks:
267267
apiVersions: ["v1"]
268268
resources: ["rolebindings", "clusterrolebindings"]
269269
{{- end }}
270-
{{- if eq .Cluster.ConfigItems.teapot_admission_controller_enable_generic_webhook "true" }}
271-
- name: generic-namespaced-admitter.teapot.zalan.do
270+
{{- if eq .Cluster.ConfigItems.teapot_admission_controller_enable_write_protection_webhook "true" }}
271+
- name: namespaced-deny-admitter.teapot.zalan.do
272272
clientConfig:
273-
url: "https://localhost:8085/generic"
273+
url: "https://localhost:8085/deny"
274274
caBundle: "{{ .Cluster.ConfigItems.ca_cert_decompressed }}"
275275
admissionReviewVersions: ["v1beta1"]
276276
failurePolicy: Fail
@@ -287,9 +287,16 @@ webhooks:
287287
apiVersions: ["*"]
288288
resources: ["*/*"]
289289
scope: "Namespaced"
290-
- name: generic-cluster-admitter.teapot.zalan.do
290+
matchConditions:
291+
- name: 'exclude-privileged-groups'
292+
expression: 'request.userInfo.groups.all(g, !(g in ["system:masters", "system:nodes", "system:serviceaccounts:kube-system", "okta:common/administrator", "zalando:administrator"]))'
293+
- name: 'exclude-privileged-usernames'
294+
expression: '!(request.userInfo.username in ["system:kube-controller-manager", "system:kube-scheduler", "zalando-iam:zalando:service:k8sapi_credentials-provider"])'
295+
- name: 'exclude-eks-components'
296+
expression: '!request.userInfo.username.startsWith("eks:")'
297+
- name: global-deny-admitter.teapot.zalan.do
291298
clientConfig:
292-
url: "https://localhost:8085/generic"
299+
url: "https://localhost:8085/deny"
293300
caBundle: "{{ .Cluster.ConfigItems.ca_cert_decompressed }}"
294301
admissionReviewVersions: ["v1beta1"]
295302
failurePolicy: Fail
@@ -304,4 +311,11 @@ webhooks:
304311
apiVersions: ["*"]
305312
resources: ["*/*"]
306313
scope: "Cluster"
314+
matchConditions:
315+
- name: 'exclude-privileged-groups'
316+
expression: 'request.userInfo.groups.all(g, !(g in ["system:masters", "system:nodes", "system:serviceaccounts:kube-system", "okta:common/administrator", "zalando:administrator"]))'
317+
- name: 'exclude-privileged-usernames'
318+
expression: '!(request.userInfo.username in ["system:kube-controller-manager", "system:kube-scheduler", "zalando-iam:zalando:service:k8sapi_credentials-provider"])'
319+
- name: 'exclude-eks-components'
320+
expression: '!request.userInfo.username.startsWith("eks:")'
307321
{{- end }}

cluster/node-pools/master-default/userdata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ write_files:
206206
limits:
207207
memory: {{ .Values.InstanceInfo.MemoryFraction (parseInt64 .Cluster.ConfigItems.apiserver_memory_limit_percent)}}
208208
{{- end }}
209-
- image: 926694233939.dkr.ecr.eu-central-1.amazonaws.com/production_namespace/teapot/admission-controller:master-224
209+
- image: 926694233939.dkr.ecr.eu-central-1.amazonaws.com/production_namespace/teapot/admission-controller:master-226
210210
name: admission-controller
211211
lifecycle:
212212
preStop:

0 commit comments

Comments
 (0)