Connect a Kubernetes cluster to Guard
The Guard operator joins a Kubernetes cluster’s workloads to a Guard network. It does two things:
- A connector serves Services of the cluster, such as Prometheus or an internal API, to the network’s nodes. The Services’ pods don’t change.
- A sidecar makes a pod a Guard node of its own, so that the pod can reach the network. See Give a pod its own Guard node.
This page installs the operator and serves a Service. The operator runs in the workload cluster, not in the cluster that runs Authwise.
Before you begin
Section titled “Before you begin”- Guard control plane 0.32.0 or later on the Authwise install.
- Guard operator 0.3.1, which this page installs. It runs the Guard client 0.25.0.
- Kubernetes 1.29 or later in the workload cluster. On Google Kubernetes Engine, use a Standard cluster. Autopilot isn’t supported, because it doesn’t allow the privileged container a connector needs.
helm3.14 or later andkubectl, with cluster administrator access to the workload cluster.- Console 0.55.1 or later on the Authwise install, for the values this page reads from it.
awctl0.45.1 or later for the Guard commands on this page. You can use the console or the Terraform provider instead.- A
tenantAdminornetworkAdminrole on the Guard network. - A second factor on your account. Creating an enrollment key asks you to sign in again with it. See Changes that need a second factor.
- A registry user name and token for
registry.authwise.com, from Authwise. - Outbound access from the cluster’s pods. See What the firewall must allow.
You also need three facts about the Guard network:
| Fact | Where to find it | Example |
|---|---|---|
| Guard address | The address people enter in the Guard client | guard.example.com |
| Network resource name | The network’s Overview tab in the console shows Resource name, with a copy button. Or run awctl guard networks describe TENANT/NETWORK and read the field name. | tenants/t-abc123/networks/n-def456 |
| Mesh domain | The Mesh domain section of the same tab, or the field mesh_domain of the same command. See Reach nodes and applications by name. | ops.acme.guard.example.com |
Install the operator
Section titled “Install the operator”-
Create the operator’s namespace. The connectors’ pods run in this namespace. They need the capability
NET_ADMINand a privileged init container that turns on IP forwarding. ThebaselinePod Security level refuses both, so the namespace enforcesprivileged.Terminal window kubectl create namespace guard-systemkubectl label namespace guard-system pod-security.kubernetes.io/enforce=privileged -
Store the registry credential. Put the token in a file named
tokenfirst, so that it doesn’t appear in your shell history.Terminal window kubectl -n guard-system create secret docker-registry authwise-registry \--docker-server=registry.authwise.com \--docker-username=REGISTRY_USER \--docker-password="$(cat token)" -
Install the chart. The release must be named
guard-operatorand must be in the namespaceguard-system.Terminal window helm registry login registry.authwise.com -u REGISTRY_USER --password-stdin < tokenhelm install guard-operator \oci://registry.authwise.com/authwise/guard-operator/charts/guard-operator \--version 0.3.1 \--namespace guard-system \--set 'imagePullSecrets[0].name=authwise-registry' -
Check that both operator pods are ready.
Terminal window kubectl -n guard-system get pods
The operator runs two pods by default, on separate nodes where it can.
Create an enrollment key
Section titled “Create an enrollment key”A connector joins the network with an enrollment key. Its nodes go into a node group, and that group is what serves the cluster’s Services.
-
Create a node group for the cluster’s connectors.
Terminal window awctl guard context set --tenant TENANT --network NETWORKawctl guard node-groups create --display-name ops-cluster-connectorsThe context takes short names or ids.
-
Create the key. It must admit more than one join and must not be ephemeral. Allow one use for each connector replica, plus headroom for replicas that join afresh.
Terminal window awctl guard enrollment-keys create \--description "ops cluster connectors" \--max-uses 20 --ttl 90d \--node-group ops-cluster-connectors \--out guard.keyThe key’s secret is shown once and written to
guard.key. -
Put the key in the operator’s namespace, then delete the file.
Terminal window kubectl -n guard-system create secret generic guard-key --from-file=key=./guard.keyrm guard.key
A key works for at most 90 days. A replica that restarts or moves rejoins
as the same node by proving its own node key. That uses no enrollment key
and works after the key has ended. The key is needed when a node joins for
the first time: a new connector, a higher replicas count, or a connector
that you create again. Replace the key before it ends, in place:
kubectl -n guard-system create secret generic guard-key \ --from-file=key=./guard.key --dry-run=client -o yaml | kubectl apply -f -Running replicas see the new key within about a minute, and nothing needs a restart. Don’t delete the Secret first: a pod that starts while it’s missing can’t mount it.
Connect the cluster to the network
Section titled “Connect the cluster to the network”A GuardConnection says which Guard network the cluster joins and how.
It’s cluster-scoped.
apiVersion: connect.guard.authwise.com/v1alpha1kind: GuardConnectionmetadata: name: ops-keyspec: address: guard.example.com network: tenants/t-abc123/networks/n-def456 clusterName: ops identity: method: EnrollmentKey enrollmentKey: secretRef: name: guard-key key: key| Field | Meaning |
|---|---|
address | Your Guard address: a host name or an https URL. |
network | The network’s resource name, with the ids: tenants/t-…/networks/n-…. Don’t use short names here. They’re accepted, but pods then can’t join, because the audience of their tokens doesn’t match. |
clusterName | A short name for the cluster, at most 32 characters. It’s the middle of the names suggested for served Services and the start of the connector’s node names. It defaults to the object’s name. |
default | Set true on at most one connection. Connectors and pods that name no connection use it. |
caBundleSecretRef | A Secret in guard-system whose key ca.crt holds the certificate authority of your Guard address. Set it only when that address uses a private certificate authority. |
Apply it and wait until it’s ready:
kubectl apply -f guardconnection.yamlkubectl get gconnReady means the operator reached the Guard control plane at that address.
A connector joins only through a connection that uses an enrollment key.
If your default connection joins by workload identity, name the
enrollment-key connection in each connector’s spec.connection.
Otherwise the connector reports ConnectionUnusable.
Serve a Service
Section titled “Serve a Service”A GuardConnector lives in the namespace of the Services it serves.
apiVersion: connect.guard.authwise.com/v1alpha1kind: GuardConnectormetadata: name: observability namespace: monitoringspec: connection: ops-key replicas: 2 services: - name: prometheus ports: [9090] - name: elasticsearch publishedName: search-
Apply it.
Terminal window kubectl apply -f guardconnector.yamlkubectl -n monitoring get gconnectorThe connector’s pods run in
guard-system. Nothing is added to the Services’ namespace except theGuardConnectoritself. -
Read what to declare in Guard. The operator holds no Guard administrator credential, so it tells you the values and you create the resources.
Terminal window kubectl -n monitoring get gconnector observability \-o jsonpath='{range .status.services[*]}{.name}{"\t"}{.address}{"\t"}{.publishedName}{"\n"}{end}'prometheus prometheus.monitoring.svc.cluster.local prometheus.monitoring.opselasticsearch elasticsearch.monitoring.svc.cluster.local search.monitoring.ops -
For each Service, create an application resource in Guard with that address and published name, served by the connectors’ node group.
Terminal window awctl guard resources create --display-name Prometheus --kind application \--address prometheus.monitoring.svc.cluster.local \--published-name prometheus.monitoring.ops \--serving-node-groups ops-cluster-connectorsEnter the published name exactly as the operator shows it. It’s the whole name that granted nodes use, and it includes the cluster’s name, so two clusters can serve Services with the same name. If you leave
--published-nameout, Guard names the applicationprometheus.monitoring.MESH_DOMAIN.A published name must be unique in the network. Don’t use a name that also exists on the internet: on granted nodes, only Guard answers a published name.
Guard gives the application an address of its own on the network. The connector resolves the cluster name and forwards, and the port passes through unchanged.
-
Grant the resource to the nodes or node groups that should reach it. The resource’s id is in the
Createdline of the previous command, and inawctl guard resources list.Terminal window awctl guard node-groups add-grants engineers resources/RESOURCE_ID
Check that it works
Section titled “Check that it works”On a granted node, the application answers at its published name, on the Service’s own port:
curl http://prometheus.monitoring.ops:9090/-/readyIf it doesn’t:
kubectl get gconnisn’t Ready. The operator can’t reach the Guard address. Check the address, outbound HTTPS from the cluster, andcaBundleSecretReffor a private certificate authority.- The connector’s replicas aren’t ready. Run
kubectl -n monitoring describe gconnector observabilityand read the events. ATunRefusedevent means the node’s container runtime refuses the tunnel device. runc 1.2.0 to 1.2.3 refuse it, and 1.2.4 restores it. - A Service shows
found: false. The Service doesn’t exist in the connector’s namespace, it has no selector, or it lacks a port that you listed. The connector reportsServiceProblem. - The name doesn’t resolve on the node. The node isn’t granted the resource, or it runs a Guard client older than 0.23, which doesn’t resolve application names inside the network’s mesh domain.
NODE_LACKS_CAPABILITYwhen you create the resource. A serving node in the group isn’t a connector. Use a group that holds only connectors.
What the firewall must allow
Section titled “What the firewall must allow”Everything is outbound from the cluster. Replies returning through a stateful firewall are enough, and nothing needs an inbound rule.
| To | Protocol and port | For |
|---|---|---|
| Your Guard address | TCP 443, or the port in the address | Joining, configuration and key reports |
| Each relay of the network | TCP to the relay’s port, and UDP to the same port | Reaching other nodes. TCP alone works. UDP gives the faster paths. |
| Other nodes’ addresses | UDP, any port | Direct paths between nodes. Optional. Without it, traffic stays on a relay. |
A cluster with private nodes needs Cloud NAT, or another route out, for these.
The network’s Relays tab in the console lists the relays you run yourself, each with its URL, which holds the host name and port. For relays that Authwise manages, ask Authwise for the host names and ports.
Restrict who reaches the served pods
Section titled “Restrict who reaches the served pods”By default a connector changes nothing inside the cluster. To admit only the connector to the served pods, on the served ports, set:
spec: networkPolicy: mode: Isolate allowedPeers: - podSelector: matchLabels: app: grafanaIsolate cuts off every other caller inside the cluster, such as Grafana
querying Prometheus, unless you list it in allowedPeers. The cluster
must enforce network policies: on Google Kubernetes Engine, that’s
Dataplane V2 or network policy enforcement. Without it, the policies are
created and nothing is enforced.
Upgrade
Section titled “Upgrade”helm upgrade guard-operator \ oci://registry.authwise.com/authwise/guard-operator/charts/guard-operator \ --version NEW_VERSION --namespace guard-system --reset-then-reuse-valuesUse --reset-then-reuse-values, not --reuse-values. With
--reuse-values, the release keeps the old chart’s defaults, including
the old Guard client, and sidecars then fail to join.
Each operator release names the Guard control plane and client it needs. Upgrade the control plane first.
Uninstall
Section titled “Uninstall”helm uninstall keeps the custom resource definitions, every
GuardConnection and every GuardConnector. Connector replicas keep
serving, with nothing managing them. To remove everything:
kubectl delete gconnector -A --all # while the operator still runshelm uninstall guard-operator -n guard-systemkubectl delete crd guardconnections.connect.guard.authwise.com \ guardconnectors.connect.guard.authwise.comDeleting a GuardConnector removes its nodes from Guard. The operator
stops the replicas, and then removes each node, speaking as that node
with the node’s own key. It holds no Guard administrator credential. The
nodes stay in Guard, and the connector shows a NodesNotRemoved event,
when the GuardConnection is already gone or the control plane can’t be
reached for three minutes. A connector that you force-delete leaves its
nodes and shows nothing. Remove those nodes in Guard yourself. Record
their names first:
kubectl -n monitoring get gconnector observability -o jsonpath='{.status.nodes}'If you leave them, a connector you create again joins under names with a number added, and other nodes keep routes to peers that no longer exist.
If sidecars are turned on, read Uninstall with sidecars on first.