Cheat sheets
Networking, storage and security
Service types, DNS names, volume objects, RBAC objects, Pod Security levels and the 4Cs on one page.
Networking
| Service type | Reachable from | Notes |
|---|---|---|
| ClusterIP (default) | Inside the cluster | Stable virtual IP and DNS name |
| NodePort | Any node IP on a port in 30000 to 32767 | Builds on ClusterIP |
| LoadBalancer | An external load balancer | Needs a cloud or add-on controller |
| ExternalName | Inside the cluster | Returns a DNS CNAME, no proxying |
Headless (clusterIP: None) | Inside the cluster | DNS returns Pod IPs. Used by StatefulSets |
- DNS name of a Service:
service.namespace.svc.cluster.local. - Every Pod gets its own IP. Pods reach each other without NAT. A CNI plug-in builds that network.
- A NetworkPolicy only works if the CNI plug-in enforces it.
- An Ingress object needs an ingress controller. Gateway API is the successor with role-based resources.
Storage
| Object | Role |
|---|---|
| Volume | Storage attached to a Pod. emptyDir lives as long as the Pod |
| PersistentVolume (PV) | A piece of storage in the cluster |
| PersistentVolumeClaim (PVC) | A request for storage by a user |
| StorageClass | Describes a kind of storage and enables dynamic provisioning |
| CSI | The standard plug-in interface that storage drivers implement |
- Access modes:
ReadWriteOnce(one node),ReadOnlyMany,ReadWriteMany,ReadWriteOncePod. - Reclaim policy:
Deleteremoves the volume with the claim.Retainkeeps it for manual cleanup. - A StatefulSet uses
volumeClaimTemplatesto give each Pod its own PVC.
Security
| Topic | Remember |
|---|---|
| 4Cs | Cloud, Cluster, Container, Code. Each layer builds on the one outside it |
| Role / RoleBinding | Permissions in one namespace |
| ClusterRole / ClusterRoleBinding | Permissions across the cluster, or on cluster-scoped resources |
| ServiceAccount | An identity for Pods |
| Pod Security Standards | privileged, baseline, restricted, applied by namespace labels |
| Secrets | Base64-encoded by default. Turn on encryption at rest and restrict RBAC |
| Admission | Mutating first, then validating, after authentication and authorization |
Base64 is not encryption
A Secret that is only base64-encoded can be read by anyone with access to etcd or to the API object. The answer to "protect Secrets in etcd" is encryption at rest, not another encoding.