Give a pod its own Guard node
A connector lets the network reach the cluster. A sidecar is for the other direction: a pod that has to reach the network, such as a deployment tool that connects to servers, or a job that reads a database on another site.
A labelled pod gets a Guard client beside its containers. The pod becomes a node of the network and joins with its own service account token. Guard checks that token against a trusted issuer. Nothing secret is stored in the cluster.
Before you begin
Section titled “Before you begin”- The operator installed, as in Connect a Kubernetes cluster to Guard. The versions on that page apply.
- cert-manager in the cluster. The operator uses it for the injection webhook’s certificate.
- A Guard address with a publicly trusted certificate. A pod whose
connection sets
caBundleSecretRefis refused. - Namespaces that allow privileged pods. The sidecar adds the
capabilities
NET_ADMINandMKNOD. ThebaselineandrestrictedPod Security levels refuseNET_ADMIN, so each namespace with injected pods must enforceprivileged. A namespace labelledbaselineorrestrictedis refused even if your admission configuration exempts the pods. - On a private Google Kubernetes Engine cluster, a firewall rule that
allows TCP 9443 from the control plane’s address range to the nodes.
The injection webhook listens on that port. Without the rule, every
labelled pod is refused with
failed calling webhook … context deadline exceeded. - A container runtime that allows the tunnel device. runc 1.2.0 to 1.2.3 refuse it to unprivileged containers, and 1.2.4 restores it. Some containerd configurations also leave it out of the devices a container may open.
Turn injection on
Section titled “Turn injection on”helm upgrade guard-operator \ oci://registry.authwise.com/authwise/guard-operator/charts/guard-operator \ --version 0.3.1 --namespace guard-system --reset-then-reuse-values \ --set injection.enabled=true \ --set injection.imagePullSecret=authwise-registryTrust the cluster in Guard
Section titled “Trust the cluster in Guard”-
Find the cluster’s service account issuer.
Terminal window kubectl get --raw /.well-known/openid-configuration | jq -r .issuerOn Google Kubernetes Engine the issuer is
https://container.googleapis.com/v1/projects/PROJECT/locations/LOCATION/clusters/CLUSTER. -
Add it to the network as a trusted issuer. Choose where Guard gets the issuer’s signing keys:
-
Discover, when the Guard control plane can reach the issuer’s published keys. That’s true of Google Kubernetes Engine, and of Amazon EKS and Azure AKS with the OIDC issuer turned on.
Terminal window awctl guard trusted-issuers create --display-name ops-cluster \--issuer ISSUER --discover -
Upload, for a cluster whose keys the control plane can’t reach.
Terminal window kubectl get --raw /openid/v1/jwks > jwks.jsonawctl guard trusted-issuers create --display-name ops-cluster \--issuer ISSUER --keys-file jwks.jsonUploaded keys go stale when the cluster rotates them. See Keep a private cluster’s keys current.
-
-
Add a rule for each service account that may join. Nothing joins until a rule admits it.
Terminal window awctl guard trusted-issuers rules create ops-cluster \--subject system:serviceaccount:deploy:argocd-application-controller \--node-name-prefix ops-argocd \--node-group deployers \--ephemeralSetting What to enter Subject system:serviceaccount:NAMESPACE:SERVICE_ACCOUNT. Use the pod’sserviceAccountName, ordefaultif it sets none. It’s matched exactly. There are no patterns.Node name prefix At most 32 characters, starting and ending with a letter or digit. The node is named PREFIX-POD_NAME.Ephemeral On for pods of a Deployment or a Job. Their nodes are removed when the pod stops cleanly, or after about an hour offline. Off for pods of a StatefulSet and pods you mark persistent. Node group The group the nodes join. Its grants decide what the pods can reach. Maximum nodes How many nodes the rule may hold at once. The default is 100.
You can do the same in the console. On the network’s Enrollment tab,
select Add a trusted issuer. Then open the issuer and select Add
rule under Who may join. The issuer’s page also shows the
Audience. Or use the authwise_guard_trusted_issuer and
authwise_guard_trusted_issuer_rule Terraform resources. In the console
and awctl, these changes ask for your second factor. See
Changes that need a second factor.
Add a connection for sidecars
Section titled “Add a connection for sidecars”Sidecars join by workload identity, so they need a connection of that
kind. Mark it default and pods need no further setting.
apiVersion: connect.guard.authwise.com/v1alpha1kind: GuardConnectionmetadata: name: opsspec: address: guard.example.com network: tenants/t-abc123/networks/n-def456 clusterName: ops default: true identity: method: WorkloadIdentityThe connection that joins by enrollment key stays for your connectors.
Name it in each connector’s spec.connection.
Inject a pod
Section titled “Inject a pod”-
Prepare the pod’s namespace: allow privileged pods, and add the registry credential. The operator doesn’t copy credentials between namespaces.
Terminal window kubectl label namespace deploy pod-security.kubernetes.io/enforce=privilegedkubectl -n deploy create secret docker-registry authwise-registry \--docker-server=registry.authwise.com \--docker-username=REGISTRY_USER \--docker-password="$(cat token)" -
Label the pod template.
spec:template:metadata:labels:connect.guard.authwise.com/inject: "true"
The pod’s own containers start only after the sidecar has joined and its routes and names are in place. A short Guard outage delays a rollout and doesn’t fail it.
| Key | Kind | Meaning |
|---|---|---|
connect.guard.authwise.com/inject: "true" | Label on the pod | Asks for the sidecar. |
connect.guard.authwise.com/connection: NAME | Label on the pod or its namespace | Which connection to use. Without it, the default connection. |
connect.guard.authwise.com/persistent: "true" | Annotation on the pod | Keeps the node when the pod stops. Pods of a StatefulSet are persistent without it. |
What changes in the pod
Section titled “What changes in the pod”- A container named
guardruns beside the pod’s own, with 10m CPU and 32Mi of memory requested and a 128Mi memory limit. - The pod’s DNS goes through the sidecar. Names that Guard owns are answered from the network. Every other name goes to the cluster’s DNS as before, with the same search list.
- The pod’s termination grace period is raised to 15 seconds if it was lower, so that an ephemeral node can leave cleanly.
- A persistent pod gets a Secret named
guard-node-POD_NAMEin its namespace. It holds the node’s key. Don’t delete it.
Pods that are refused
Section titled “Pods that are refused”A labelled pod is refused at admission, with the reason, when:
- the cluster runs Kubernetes older than 1.29;
- its namespace enforces
baselineorrestricted; - no connection is named and none is the default, or two are;
- its connection joins by enrollment key, or sets
caBundleSecretRef; - it sets
hostNetwork: true,dnsPolicy: Default, ordnsPolicy: Nonewith no name servers; - the operator can’t find the cluster’s DNS address. Set
spec.dns.clusterDNSon the connection; - it’s marked persistent and has no name at admission. A Deployment’s pods are like that. Persistent pods need a StatefulSet, or a pod that you name yourself.
Check that it works
Section titled “Check that it works”kubectl -n deploy get pod POD -o jsonpath='{.metadata.annotations.connect\.guard\.authwise\.com/injected}'kubectl -n deploy logs POD -c guardIn Guard, the node appears as PREFIX-POD_NAME, and its page shows the
rule it joined by. If the sidecar doesn’t start:
- The join is refused. The sidecar’s log says
the identity token was not accepted, with the token’s issuer and subject. No rule matches that subject exactly, the rule is at its maximum, the issuer’s keys are stale, or the connection’snetworkuses short names where it needs ids. - The sidecar’s log says
the container runtime refuses /dev/net/tun, and the pod stays inInit. See Before you begin. Upgrade the runtime, or have your platform team allow the devicec 10:200to the pod. - The image can’t be pulled. The pod’s namespace has no Secret with
the name set in
injection.imagePullSecret, which isauthwise-registryin this guide.
Keep a private cluster’s keys current
Section titled “Keep a private cluster’s keys current”Keys that you upload by hand go stale when the cluster rotates its signing keys, and pods then can’t join. To keep them current without a person, let one connector report them.
-
Set
issuerKeySource: trueon one connector in the cluster. It must join by enrollment key.spec:issuerKeySource: true -
Read the issuer address and the connector’s node names.
Terminal window kubectl -n monitoring get gconnector observability \-o jsonpath='{.status.issuerKeys.issuer}{"\n"}{.status.nodes}{"\n"}' -
In Guard, name one of those nodes as the trusted issuer’s key source.
Terminal window awctl guard trusted-issuers update ops-cluster --key-source-node NODE_NAME
That node reports the cluster’s keys whenever they change, under its own identity. Upload the keys once first, or pods can’t join until the first report arrives.
A change reaches Guard in up to 11 minutes: the operator reads the cluster’s keys every 10 minutes, and the node reports within about a minute after that. Rotate by adding the new key while the old one still verifies, and wait at least 11 minutes before you retire the old one.
Guard holds a report that would replace every key at once. Pods keep joining with the stored keys, and the trusted issuer shows the held keys for an administrator to accept:
awctl guard trusted-issuers describe ops-clusterawctl guard trusted-issuers update ops-cluster --adopt-held-keysWhile the key-source node is down, a rotation waits for it. You can name another of the connector’s nodes instead.
Operator availability
Section titled “Operator availability”The injection webhook fails closed: when no operator pod is ready, a
labelled pod is refused. Unlabelled pods are never affected. The operator
runs two pods by default, with a rolling update that keeps one ready and a
PodDisruptionBudget. With --set replicas=1, labelled pods are refused
for the seconds the operator takes to restart.
Uninstall with sidecars on
Section titled “Uninstall with sidecars on”helm uninstall keeps the webhook configuration. While the operator is
uninstalled, new pods with the inject label are refused. Install the
operator again, or delete the webhook configuration to admit them without
a sidecar:
kubectl delete mutatingwebhookconfiguration guard-operator