Identity & Zero Trust for Platform Engineers cheat sheet
80 commands from every lesson of Identity & Zero Trust for Platform Engineers, on one page.
Quick checks: how much implicit trust is left?
kubectl get networkpolicy -A | Namespaces with no policy are flat: every pod can reach them |
kubectl get peerauthentication -A | Mesh mTLS mode per namespace (PERMISSIVE still accepts plaintext) |
kubectl get ns -L pod-security.kubernetes.io/enforce | Pod Security level enforced per namespace |
kubectl get clusterrolebindings -o wide | grep cluster-admin | Who holds cluster-admin |
kubectl auth can-i --list --as=system:serviceaccount:<ns>:default | What a namespace's default ServiceAccount can do |
Inspect TLS from the command line
openssl s_client -connect host:443 -servername host -tls1_3 </dev/null | Handshake details, chain and negotiated cipher |
openssl s_client -connect host:443 -showcerts </dev/null | Print every certificate the server sends |
openssl x509 -in cert.pem -noout -subject -issuer -dates -ext subjectAltName | Who, issued by whom, validity, SAN names |
curl -v --cert client.crt --key client.key --cacert ca.crt https://api.internal | Call an mTLS endpoint with a client certificate |
openssl s_server -accept 8443 -cert srv.crt -key srv.key -CAfile ca.crt -Verify 1 | Test server that requires a client certificate |
Inventory and expiry
kubectl get certificates -A | cert-manager certificates and their Ready state |
kubectl get certificaterequests -A --sort-by=.metadata.creationTimestamp | Recent issuance attempts (look for failures) |
kubeadm certs check-expiration | Control-plane certificate expiry on a kubeadm node |
openssl x509 -in cert.pem -noout -enddate | Expiry of one certificate |
echo | openssl s_client -connect host:443 -servername host 2>/dev/null | openssl x509 -noout -enddate | Expiry as a client actually sees it |
Trust bundles
cat old-root.pem new-root.pem > bundle.pem | A bundle that trusts both roots during rotation |
openssl verify -CAfile bundle.pem -untrusted intermediate.pem leaf.pem | Check a leaf chains to a root in the bundle |
Look at identities
istioctl proxy-config secret deploy/orders -n shop | Certificates the proxy holds (identity, expiry) |
istioctl proxy-config secret deploy/orders -n shop -o json | jq -r '..|.inlineBytes?' | grep -v null | head -1 | base64 -d | openssl x509 -noout -text | grep URI | The SPIFFE ID inside the workload certificate |
linkerd viz edges deploy -n shop | Which identities talk to which (Linkerd) |
kubectl exec -n spire spire-server-0 -- /opt/spire/bin/spire-server entry show | Registration entries in SPIRE |
AWS
kubectl annotate sa orders -n shop eks.amazonaws.com/role-arn=arn:aws:iam::111122223333:role/orders | IRSA: link a ServiceAccount to an IAM role |
aws eks create-pod-identity-association --cluster-name prod --namespace shop --service-account orders --role-arn <role-arn> | EKS Pod Identity association |
kubectl exec -n shop deploy/orders -- aws sts get-caller-identity | Which role the pod actually assumed |
aws ec2 modify-instance-metadata-options --instance-id <id> --http-tokens required --http-put-response-hop-limit 1 | IMDSv2 only, unreachable from pod network namespaces |
Azure and GCP
az identity federated-credential create --name orders --identity-name orders-id --resource-group rg --issuer <aks-oidc-issuer> --subject system:serviceaccount:shop:orders --audience api://AzureADTokenExchange | Azure: trust one ServiceAccount |
kubectl annotate sa orders -n shop azure.workload.identity/client-id=<client-id> | Azure: link the ServiceAccount (pods also need label azure.workload.identity/use=true) |
kubectl annotate sa orders -n shop iam.gke.io/gcp-service-account=orders@proj.iam.gserviceaccount.com | GKE: link to a Google service account |
Check what is allowed
kubectl get networkpolicy -n shop -o yaml | All network rules in a namespace |
kubectl get authorizationpolicy -A | Istio identity-based policies |
istioctl x authz check <payments-pod> -n shop | Effective authorisation rules on one workload's proxy |
hubble observe --namespace shop --verdict DROPPED | Cilium: flows that policy dropped, with identities |
kubectl -n shop exec deploy/orders -- curl -s -o /dev/null -w '%{http_code}' http://payments:8080/charge | Test a call: 403 means L7 policy, timeout means network policy |
Explore an OIDC provider
curl -s https://issuer.example.com/.well-known/openid-configuration | jq | Discovery: endpoints, supported flows, JWKS URL |
curl -s <jwks_uri> | jq '.keys[] | {kid, alg, kty}' | The public keys used to verify tokens |
cut -d. -f2 <<< "$TOKEN" | tr '_-' '/+' | base64 -d 2>/dev/null | jq | Read a JWT's claims (reading is not validating) |
Get tokens (test IdP)
curl -s -d grant_type=client_credentials -d client_id=svc -d client_secret=… <token_endpoint> | Client Credentials: a service gets a token for itself |
kubectl oidc-login get-token --oidc-issuer-url=<issuer> --oidc-client-id=kubectl | kubelogin: browser login, token for kubectl |
Gateway / mesh token checks (Istio)
kubectl apply -f requestauthentication.yaml | Validate JWTs from an issuer (signature, iss, aud) at the proxy |
kubectl get requestauthentication,authorizationpolicy -n shop | Which token rules apply in a namespace |
Debugging tokens
cut -d. -f1 <<< "$TOKEN" | base64 -d 2>/dev/null | Header: alg and kid |
cut -d. -f2 <<< "$TOKEN" | tr '_-' '/+' | base64 -d 2>/dev/null | jq '{iss,aud,sub,exp,scope}' | Claims that every check uses |
date -d @<exp> | Human-readable expiry |
Who can do what
kubectl auth can-i --list --as=alice@example.com --as-group=team-shop | Effective permissions of a user and group |
kubectl get clusterrolebindings,rolebindings -A -o wide | grep -i <group> | Where a group is bound |
kubectl get clusterrolebindings -o json | jq -r '.items[] | select(.roleRef.name=="cluster-admin") | .metadata.name, .subjects' | Everyone with cluster-admin |
Audit
jq 'select(.verb=="create" and .objectRef.subresource=="exec")' audit.log | Who exec'd into pods |
jq 'select(.objectRef.resource=="secrets" and .user.username | test("@"))' audit.log | Humans reading Secrets |
PostgreSQL row-level security
ALTER TABLE accounts ENABLE ROW LEVEL SECURITY; | Turn on RLS for a table |
ALTER TABLE accounts FORCE ROW LEVEL SECURITY; | Apply RLS to the table owner too |
CREATE POLICY tenant_isolation ON accounts USING (tenant_id = current_setting('app.tenant_id')::uuid); | Only rows for the session's tenant |
SET app.tenant_id = '…'; | Set the tenant for this connection or transaction (from the verified token) |
Quick isolation tests
curl -H "Authorization: Bearer $TENANT_A_TOKEN" https://api.example.com/tenants/B/users | Must be 403/404, never data |
kubectl get resourcequota,limitrange -n <tenant-ns> | Compute limits for a dedicated namespace |
Evidence you can pull from the platform
kubectl get policyreport,clusterpolicyreport -A | Kyverno policy results per namespace (pass/fail) |
kube-bench run --targets node,policies --json | CIS Kubernetes Benchmark results |
trivy image --format cyclonedx --output sbom.json <image> | SBOM for an image |
cosign verify --key cosign.pub <image>@<digest> | Proof an image was signed by your pipeline |
git log --merges --format='%h %an %s' -- clusters/prod | Reviewed, merged changes to production config |
STRIDE at a glance
S: Spoofing | Pretending to be someone else → strong authentication, mTLS, MFA |
T: Tampering | Changing data or code → signing, integrity checks, GitOps |
R: Repudiation | Denying an action → audit logs, signed commits, tamper-resistant logs |
I: Information disclosure | Leaking data → encryption, tenant isolation, least privilege |
D: Denial of service | Exhausting resources → rate limits, quotas, cells |
E: Elevation of privilege | Gaining more rights → least privilege, Pod Security, admission control |
Contain
kubectl label pod <pod> -n shop quarantine=true app- | Remove from Service endpoints (stop new traffic) and mark it |
kubectl apply -f quarantine-netpol.yaml | Deny all ingress and egress for quarantine=true pods |
kubectl cordon <node> | No new pods on the affected node |
Preserve and scope
kubectl get pod <pod> -n shop -o yaml > pod.yaml | Spec, image digest, ServiceAccount, node |
kubectl logs <pod> -n shop --all-containers --timestamps > logs.txt | Container logs before anything restarts |
kubectl debug node/<node> -it --image=busybox | Inspect the node from a debug pod (host filesystem under /host) |
kubectl auth can-i --list --as=system:serviceaccount:shop:<sa> | What the workload's identity could do in the cluster |
kubectl get clusterrolebindings,mutatingwebhookconfigurations,daemonsets -A --sort-by=.metadata.creationTimestamp | Recently created high-risk objects (persistence) |
Review questions per layer
Humans | SSO + MFA everywhere? Standing admin? JIT? Reviews? |
Workloads | One identity per service? Static cloud keys anywhere? |
Service to service | Default deny? Strict mTLS? Identity-based L7 policy? |
Edge and users | Token checks complete (aud, alg, tenant)? Identity headers stripped? |
Data | Tenant enforced in the database? Per-tenant keys where needed? |
Delivery | Signed images verified at admission? Pipeline credentials short-lived? |
Detect and respond | Runtime detection? Audit logs central? Quarantine runbook? |