This lab has been modernised but not yet verified end to end. Tell us if something breaks.
Enforcing Workload Policies
Lab Solution
The output from Kubectl apply gives you the first violation:
Error from server ([requiredlabels-ns] you must provide labels: {"kubernetes.courselabs.co"}): error when creating "labs//admission//specs//apod//01-namespace.yaml": admission webhook "validation.gatekeeper.sh" denied the request: [requiredlabels-ns] you must provide labels: {"kubernetes.courselabs.co"}So you'll need to add the label to the namespace spec; here's my solution:
Now the resources can all be created, but the Deployments never get up to scale:
kubectl get deploy -n apodFetch the details for the ReplicaSets (any one will do):
kubectl describe rs -n apodYou'll see the failures:
Error creating: admission webhook "validation.gatekeeper.sh" denied the request: [resource-limits] container <web> has no cpu limit[requiredlabels-pods] you must provide labels: {"app", "version"} The Pod specs need labels, and the container specs need resource limits:
Apply the fixed specs:
kubectl apply -f labs/admission/solutionThe Deployments should all get up to scale, and the app should be running at http://localhost:30016
Back to the exercises.