Kubernetes admission controllers act as gatekeepers by accepting or rejecting requests and can even alter (or mutate) requests to comply to the configuration set in the controller. In this hands-on lab, you will be challenged to enable an admission controller, create a new admission controller resource, edit existing resources, and deploy pods to the cluster while observing the impact the admission controllers have on the pods.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Enable and Disable Admission Controllers
- Use a text editor to modify the
kube-apiserver.yaml
file.- Enable the
ResourceQuota
admission controller. - Disable the
MutatingAdmissionWebhook
admission controller.
- Enable the
- Validate that the
kube-apiserver
pod redeploys successfully by issuing a simplekubectl
command (the pod can take several seconds to redeploy).
- Use a text editor to modify the
- Create and Edit Admission Controller Resources
- Use the
kubectl
command to edit theLimitRange
object in the dev namespace.- Update the default CPU limit to be
500m
and the memory limit to be512Mi
. - Update the default CPU request to be
250m
and the memory request to be128Mi
.
- Update the default CPU limit to be
Create and deploy a
ResourceQuota
object to thetest
namespace using the following steps:- Create a manifest file called
test-quota.yaml
with the following specifications:
Note: Performing a copy paste directly from the objective will result in additional spaces being added. To remove additional spaces, either copy to a text editor on your computer before copying to the file on the host or manually remove the spaces once you have copied the file.
apiVersion: v1 kind: ResourceQuota metadata: name: test-quota namespace: test spec: hard: requests.memory: 128Mi requests.cpu: 250m limits.memory: 512Mi limits.cpu: "1"
- Use
kubectl
to deploy the manifest file.
- Create a manifest file called
- Use the
- Deploy Pods to the Cluster
- View the contents of the
nginx-pod.yaml
file in the/home/cloud_user
directory (take note of any memory requests or limits, if they appear).- Use the
kubectl
command to deploy the manifest. - Use the
kubectl
command to print information about the pod in YAML format (pay attention to the requests and limits for memory and CPU).
- Use the
- Edit the
nginx-pod.yaml
file and change the namespace totest
and attempt to deploy the pod (take note of any output you receive). - Edit the
nginx-pod.yaml
file and redeploy it to the test namespace.- Under the
containers
section, add a section forresources
. - Under
resources
, add a section forlimits
and setmemory
to256Mi
andcpu
to500m
. - Under
resources
, add a section forrequests
and setmemory
to64Mi
andcpu
to125m
. - Use the
kubectl
command to deploy thenginx-pod.yaml
(take note of any output). - Use the
kubectl
command to print information about the pod in YAML format (view the requests and limits).
- Under the
- View the contents of the