Hands-on Lab·Kubernetes and Cloud Native Security Associate
Private Registry Authentication
Private images need a credential, and Kubernetes stores it as an ordinary Secret with the password in clear. This guide reads it back out, watches a pull fail without it and again with it, and attaches it once to a ServiceAccount instead of to every Pod.
Platform Security Guide 34 of 42 Beginner
- Kubernetesapiserver v1.36.4, kubelet v1.36.3
- Runtimecontainerd 2.2.6
- CNICilium 1.18.1
- Built withkubeadm v1.36.3
- TimeAbout 15 min
kubernetes.io/dockerconfigjson is base64, not encryption. imagePullSecrets on a ServiceAccount is applied to Pods by the ServiceAccount admission plugin.
- Host kernel7.0.0-29
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| CKA5001 | 192.168.0.41 | Ubuntu 26.04 LTS | Control Plane Node (tainted NoSchedule) | 2 Core | 4 GB | 50 GB |
| CKA5001-NODE01 | 192.168.0.42 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA5001-NODE02 | 192.168.0.43 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
| CKA5001-NODE03 | 192.168.0.44 | Ubuntu 26.04 LTS | Worker Node | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when an image needs a credential before it can be pulled. This matters because Kubernetes stores a registry login as an ordinary Secret with base64 inside it - and attaching it to a ServiceAccount is what stops every Pod having to name it.
- creating a registry Secret and reading it straight back out
- decoding the auth field, which turns out to be the same credential a second time
- watching a Pod fail to pull with nothing attached to it
- attaching the Secret to the Pod, and reading how the error changes
- attaching it once to the ServiceAccount instead of on every Pod
Before you start
-
A Secret that is a registry login
-
The auth field, which is the same thing twice
-
A Pod that needs the credential and has not got it
-
The same image with the Secret attached
-
Attaching it once instead of on every Pod