Question 1: Function of Admission Controllers
The first question asks which task admission controllers do not perform. The correct answer is that they do not handle user authentication. Admission controllers come into effect after authentication, enforcing policies by validating or mutating resources.Question 2: Enabling the Default Admission Controllers
The next question examines which admission controller is not enabled by default. To determine this:-
List the control plane pods in the kube-system namespace:
-
Inspect the kube-apiserver pod (e.g.,
kube-apiserver-controlplane). Execute a shell inside the pod and search for the enabled admission plugins:The output confirms that while plugins such as mutating and validating admission webhooks are present, the “namespace auto-provision” admission controller is absent. This controller is therefore not enabled by default.
Question 3: Admission Controller Enabled by Default (But Normally Disabled)
This question asks which admission controller is active in the cluster that is usually disabled by default. To answer:-
Open the kube-apiserver configuration file at
/etc/kubernetes/manifests/kube-apiserver.yaml. -
Run the following command to locate the admission plugin configuration:
You should see an output similar to:From this configuration, it is clear that the “NodeRestriction” plugin is enabled, even though it is not typically activated by default in standard configurations.
Question 4: Creating an NGINX Pod without Pre-Creating the Namespace
In this task, we create an NGINX pod in a non-existent namespace called “blue.” This operation will help us understand how Kubernetes responds when the specified namespace is missing. Execute the following command:Enabling the Namespace Auto-Provision Admission Controller
To enable automatic namespace creation, update the API server manifest at/etc/kubernetes/manifests/kube-apiserver.yaml as follows:
-
Locate the line with
--enable-admission-plugins. -
Add the
NamespaceAutoProvisionplugin, making the line appear as shown below:
After saving the changes, the API server pod will restart. Allow a few minutes for it to come back online.
Question 5: Disabling the Default Storage Class Admission Controller
The final task involves disabling the default storage class admission controller. This is accomplished by modifying the API server manifest.-
Open the file
/etc/kubernetes/manifests/kube-apiserver.yaml. -
Directly after the
--enable-admission-pluginsflag, add the disable flag for the DefaultStorageClass plugin (--disable-admission-plugins=DefaultStorageClass) as shown below:
Ensure you allow the API server sufficient time to restart after making these changes. Validate the changes by checking the status of pods and namespaces.
Summary
To summarize, in this lab we:- Identified the function of admission controllers and clarified that they do not manage user authentication.
- Determined which admission controllers are enabled by default.
- Enabled the Namespace Auto-Provision admission controller to automatically create namespaces.
- Disabled the default storage class admission controller through modifications to the API server manifest.