Identity & Zero Trust for Platform Engineers›Workload identity · Cheat sheet & self-check

Workload identity · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

04 · Workload identity with SPIFFE

Look at identities

istioctl proxy-config secret deploy/orders -n shopCertificates 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 URIThe SPIFFE ID inside the workload certificate
linkerd viz edges deploy -n shopWhich identities talk to which (Linkerd)
kubectl exec -n spire spire-server-0 -- /opt/spire/bin/spire-server entry showRegistration entries in SPIRE

05 · Cloud workload identity

AWS

kubectl annotate sa orders -n shop eks.amazonaws.com/role-arn=arn:aws:iam::111122223333:role/ordersIRSA: 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-identityWhich role the pod actually assumed
aws ec2 modify-instance-metadata-options --instance-id <id> --http-tokens required --http-put-response-hop-limit 1IMDSv2 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://AzureADTokenExchangeAzure: 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.comGKE: link to a Google service account

06 · Service-to-service authorization

Check what is allowed

kubectl get networkpolicy -n shop -o yamlAll network rules in a namespace
kubectl get authorizationpolicy -AIstio identity-based policies
istioctl x authz check <payments-pod> -n shopEffective authorisation rules on one workload's proxy
hubble observe --namespace shop --verdict DROPPEDCilium: flows that policy dropped, with identities
kubectl -n shop exec deploy/orders -- curl -s -o /dev/null -w '%{http_code}' http://payments:8080/chargeTest a call: 403 means L7 policy, timeout means network policy