Hello, I am referring to the question lab-mock-exam-1 (CKS). The solution you provided is not clear to me perfectly, it seems to be very confusing for me, and I couldn’t make it complete. Could you please double-check this solution and explain it simply?
Solutions:
Create the below admission-configuration inside /root/CKS/ImagePolicy
directory in the controlplane node:
apiVersion: apiserver.config.k8s.io/v1
kind: AdmissionConfiguration
plugins:
- name: ImagePolicyWebhook
configuration:
imagePolicy:
kubeConfigFile: /etc/admission-controllers/admission-kubeconfig.yaml
allowTTL: 50
denyTTL: 50
retryBackoff: 500
defaultAllow: false
The /root/CKS/ImagePolicy
is mounted at the path /etc/admission-controllers
directory in the kube-apiserver
. So, you can directly place the files under /root/CKS/ImagePolicy
.
Here is a snippet of the volume and volumeMounts (already added to apiserver config):
containers:
.
.
.
volumeMounts:
- mountPath: /etc/admission-controllers
name: admission-controllers
readOnly: true
volumes:
- hostPath:
path: /root/CKS/ImagePolicy/
type: DirectoryOrCreate
name: admission-controllers
Next, update the kube-apiserver command flags and add ImagePolicyWebhook to the enable-admission-plugins flag. Use the configuration file that was created in the previous step as the value of admission-control-config-file
.
Note: Remember, this command will be run inside the kube-apiserver container, so the path must be /etc/admission-controllers/admission-configuration.yaml
(mounted from /root/CKS/ImagePolicy
in controlplane).
- --admission-control-config-file=/etc/admission-controllers/admission-configuration.yaml
- --enable-admission-plugins=NodeRestriction,ImagePolicyWebhook
Example of Confusing point:
- from where did you get this “kubeConfigFile: /etc/admission-controllers/admission-kubeconfig.yaml” ?
- If we create admission-configuration inside ‘/root/CKS/ImagePolicy’ directory, what will be the name of file and how this file will be linked to the kube-API server?
Thanks in advance.