Skip to content

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.

  • 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.
  • helm 3.14 or later and kubectl, 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.
  • awctl 0.45.1 or later for the Guard commands on this page. You can use the console or the Terraform provider instead.
  • A tenantAdmin or networkAdmin role 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:

FactWhere to find itExample
Guard addressThe address people enter in the Guard clientguard.example.com
Network resource nameThe 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 domainThe 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
  1. Create the operator’s namespace. The connectors’ pods run in this namespace. They need the capability NET_ADMIN and a privileged init container that turns on IP forwarding. The baseline Pod Security level refuses both, so the namespace enforces privileged.

    Terminal window
    kubectl create namespace guard-system
    kubectl label namespace guard-system pod-security.kubernetes.io/enforce=privileged
  2. Store the registry credential. Put the token in a file named token first, 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)"
  3. Install the chart. The release must be named guard-operator and must be in the namespace guard-system.

    Terminal window
    helm registry login registry.authwise.com -u REGISTRY_USER --password-stdin < token
    helm 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'
  4. 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.

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.

  1. Create a node group for the cluster’s connectors.

    Terminal window
    awctl guard context set --tenant TENANT --network NETWORK
    awctl guard node-groups create --display-name ops-cluster-connectors

    The context takes short names or ids.

  2. 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.key

    The key’s secret is shown once and written to guard.key.

  3. 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.key
    rm 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:

Terminal window
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.

A GuardConnection says which Guard network the cluster joins and how. It’s cluster-scoped.

apiVersion: connect.guard.authwise.com/v1alpha1
kind: GuardConnection
metadata:
name: ops-key
spec:
address: guard.example.com
network: tenants/t-abc123/networks/n-def456
clusterName: ops
identity:
method: EnrollmentKey
enrollmentKey:
secretRef:
name: guard-key
key: key
FieldMeaning
addressYour Guard address: a host name or an https URL.
networkThe 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.
clusterNameA 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.
defaultSet true on at most one connection. Connectors and pods that name no connection use it.
caBundleSecretRefA 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:

Terminal window
kubectl apply -f guardconnection.yaml
kubectl get gconn

Ready 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.

A GuardConnector lives in the namespace of the Services it serves.

apiVersion: connect.guard.authwise.com/v1alpha1
kind: GuardConnector
metadata:
name: observability
namespace: monitoring
spec:
connection: ops-key
replicas: 2
services:
- name: prometheus
ports: [9090]
- name: elasticsearch
publishedName: search
  1. Apply it.

    Terminal window
    kubectl apply -f guardconnector.yaml
    kubectl -n monitoring get gconnector

    The connector’s pods run in guard-system. Nothing is added to the Services’ namespace except the GuardConnector itself.

  2. 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.ops
    elasticsearch elasticsearch.monitoring.svc.cluster.local search.monitoring.ops
  3. 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-connectors

    Enter 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-name out, Guard names the application prometheus.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.

  4. Grant the resource to the nodes or node groups that should reach it. The resource’s id is in the Created line of the previous command, and in awctl guard resources list.

    Terminal window
    awctl guard node-groups add-grants engineers resources/RESOURCE_ID

On a granted node, the application answers at its published name, on the Service’s own port:

Terminal window
curl http://prometheus.monitoring.ops:9090/-/ready

If it doesn’t:

  • kubectl get gconn isn’t Ready. The operator can’t reach the Guard address. Check the address, outbound HTTPS from the cluster, and caBundleSecretRef for a private certificate authority.
  • The connector’s replicas aren’t ready. Run kubectl -n monitoring describe gconnector observability and read the events. A TunRefused event 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 reports ServiceProblem.
  • 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_CAPABILITY when you create the resource. A serving node in the group isn’t a connector. Use a group that holds only connectors.

Everything is outbound from the cluster. Replies returning through a stateful firewall are enough, and nothing needs an inbound rule.

ToProtocol and portFor
Your Guard addressTCP 443, or the port in the addressJoining, configuration and key reports
Each relay of the networkTCP to the relay’s port, and UDP to the same portReaching other nodes. TCP alone works. UDP gives the faster paths.
Other nodes’ addressesUDP, any portDirect 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.

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: grafana

Isolate 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.

Terminal window
helm upgrade guard-operator \
oci://registry.authwise.com/authwise/guard-operator/charts/guard-operator \
--version NEW_VERSION --namespace guard-system --reset-then-reuse-values

Use --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.

helm uninstall keeps the custom resource definitions, every GuardConnection and every GuardConnector. Connector replicas keep serving, with nothing managing them. To remove everything:

Terminal window
kubectl delete gconnector -A --all # while the operator still runs
helm uninstall guard-operator -n guard-system
kubectl delete crd guardconnections.connect.guard.authwise.com \
guardconnectors.connect.guard.authwise.com

Deleting 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:

Terminal window
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.