Security - Admission Controllers Flashcards
Where does the certificate lie that is used per default by kubectl?
root/.kube/config
What can you do, if you want for example only permit images from certain images or not permit runAs root user?
You use Admission Controller for that.
Enforce how a Cluster is used
What can an Admission Controller do?
- validate configuration
- change request
- perform additional operations before pod is created
- lot more
Name a few by default enabled Admission Controllers
- AlwaysPullImages
- DefaultStorageClass
- EventRateLimit
- NamespaceExists
- many more
How can you see all pre-enabled admission controllers?
Ps -ef | grep kube-apiserver
How do you add an Admission Controller?
kube-apiserver.yaml
add Flag
–enable-admission-plugings=…
How do you disable an Admission Controller?
add flag to kube-apiserver service/yaml:
–disable-admission-plugins=…
How do you apply changes to the kube-apiserver?
Change the yaml under /etc/kubernetes/manifest/kube-apiserver.yaml
What kind of Admission Controllers exist?
- Validating Admission Controller
- Mutating Admission Controller
- some can do both
In what sequence are Admission Controllers invoked?
- first Mutating ACs
- then Validating ACs
What Admission Controllers are the basis for your own?
- MutatingAdmissionWebhook
- ValidatingAdmissionWebhook
How do Mutating/Validating AdmissionWebhooks work?
- we have our own Admission Webhook server (externally or in the cluster)
- has our own AdmissionWebhook service running
- after a request goes through all other ACs it hits the AdmissionWebhook Controllers
- then makes a call to the webhook service, using a AdmissionReview-Object, and gets a answer in form of AdmissionReview-object with ‘allowed’ value
How does a Admission Webhook configuration look like?
yaml:
~~~
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: “pod-policy.example.com”
webhooks:
- name: “pod-policy.example.com”
clientConfig: (location of our client webhook server)
url: “…..” (if deployed external of cluster9
service:
namespace: “webhook-namespace”
name: “webhook-service”
caBundle: “Ci0..”
rules: (only call the service, when the following is happening)
- apiGroups: [””]
apiVersions: [“v1”]
operations: [“CREATE”]
resources: [“pods”]
scope: “Namespaced”
~~~
With what command can you see with grep more than one line?
grep -A2 security
-> two lines after where first found security