Skip to main content

Gatekeeper hello world

Context

This project goal is to explore different use cases to test gatekeeper policy behaviours.

Prerequisites

Deploying all pods from all these use cases require admin right due to restricted namespace access

use case files:

Tutorial

Use casePolicy concernedFileRequired admin rightCommandExpected results
Pod without requesting privilegeno-privileged-containernginx-not-privileged-pod.yamlNokubectl apply -f nginx-not-privileged-pod.yaml -n devpod/nginx-not-privileged created
Pod requesting privilegeno-privileged-containernginx-privileged-pod.yamlNokubectl apply -f nginx-privileged-pod.yaml -n devError from server (Forbidden): error when creating "nginx-privileged-pod.yaml": admission webhook "validation.gatekeeper.sh" denied the request ...
Deploy pod from untrusted repo and restricted namespacecontainers-shall-only-use-allowed-imagesnginx-microsoft-repo-ns-dev.yamlNokubectl apply -f nginx-microsoft-repo-ns-client.yaml -n devError from server (Forbidden): error when creating "nginx-microsoft-repo-ns-dev.yaml": admission webhook "validation.gatekeeper.sh" denied the request:...
Deploy pod from untrusted repo and unrestricted namespacecontainers-shall-only-use-allowed-imagesnginx-microsoft-repo-ns-kube-system.yamlYeskubectl apply -f nginx-microsoft-repo-ns-kube-system.yamlpod/nginx-from-microsoft-repo created
Deploy pod from trusted repo and restricted namespacecontainers-shall-only-use-allowed-imagesnginx-artifactory-repo-ns-dev.yamlNokubectl apply -f nginx-artifactory-repo-ns-client.yaml -n devpod/nginx-from-artifactory-repo created
Deploy pod from trusted repo and unrestricted namespacecontainers-shall-only-use-allowed-imagesnginx-artifactory-repo-ns-kube-system.yamlYeskubectl apply -f nginx-artifactory-repo-ns-kube-system.yamlpod/nginx-from-artifactory-repo created

Remove your test

kubectl delete pod nginx-not-privileged-pod -n dev
kubectl delete pod nginx-privileged-pod -n dev
kubectl delete pod nginx-microsoft-repo-ns-client -n dev
kubectl delete pod nginx-microsoft-repo-ns-kube-system -n kube-system
kubectl delete pod nginx-artifactory-repo-ns-client -n dev
kubectl delete pod nginx-artifactory-repo-ns-kube-system -n kube-system