Workload identity · wrap-up
Cheat sheet & self-check
Every command from this section on one page.
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 |