The gateway

How operators reach your Wardn, the names and certificates the gateway needs, and how replicas share clusters.

The gateway is the server role that operators connect to. Each cluster's operator dials out to it and keeps one long-lived connection open, over which the cluster's inventory, health and drift flow in and Wardn's signed commands flow out. Your clusters never accept a connection from Wardn. How it works describes what crosses that connection; this page covers what you set up to make it work.

What the connection needs

NeedDetail
A reachable addressEvery cluster you connect needs outbound access to the gateway's host and port (8443 by default).
TCP passthroughThe connection is mutual TLS: Wardn checks the operator's client certificate itself. A proxy or load balancer in front must pass TCP through. An ingress that ends TLS breaks it.
A certificate for the nameThe certificate the gateway presents must be valid for the name operators dial.

The gateway listens on WARDN_GATEWAY_ADDR (:8443). The charts put it behind its own Service, <release>-gateway, separate from the web app's ingress:

ChartService typeReached from
wardn-tinyClusterIPThe same cluster only, unless you change gateway.service.type
wardn-standardLoadBalancer, with externalTrafficPolicy: LocalWherever the load balancer is reachable

Set gateway.service.type to NodePort (with gateway.service.nodePort) or LoadBalancer, and gateway.service.annotations for your cloud's load balancer options, such as an internal-only one.

How an operator trusts the gateway

When you connect a cluster, Wardn makes a one-time join token. Besides the secret the operator trades for its client certificate, the token carries a pin of Wardn's own certificate authority. That is how a new operator can trust a gateway certificate that Wardn signed, without a CA file.

Wardn's certificate authority is created the first time a gateway starts. Until then, creating a join token is refused with 409 operator.no_gateway. The gateway role also needs the secret store open, which means WARDN_SECRET_MASTER_KEY must be set: without it, a server running the default roles starts without the gateway and logs a warning, and one that asked for the gateway in WARDN_ROLES stops with an error.

Certificates

Choose how the gateway presents itself.

Generated by Wardn (default)

The gateway signs a server certificate from Wardn's certificate authority for the names in WARDN_GATEWAY_TLS_HOSTS, and replaces it a month before it expires. Operators trust it through the pin in their join token. There is nothing else to do except list every name operators dial:

values.yaml
gateway:
  hosts: [gateway.example.com]

The charts add localhost and 127.0.0.1 themselves. The certificate is signed when the server starts, so a change of names takes effect on the restart that helm upgrade causes.

From a Secret

To present a certificate from a public CA, for example one cert-manager keeps from Let's Encrypt, give the gateway a kubernetes.io/tls Secret:

values.yaml
gateway:
  hosts: [gateway.example.com]
  tls:
    mode: existingSecret
    existingSecret: wardn-gateway-tls

The chart mounts the Secret and sets WARDN_GATEWAY_TLS_CERT_FILE and WARDN_GATEWAY_TLS_KEY_FILE. The gateway checks the files every minute and uses a renewed certificate without a restart; connections already open keep the old one until they reconnect.

A certificate from a public CA is trusted by the operator through the system's roots. For a certificate from a private CA other than Wardn's, give the operator that CA with wardn cluster connect --gateway-ca-file ca.pem (wardn cluster).

The address operators dial

You give it to each operator once, with wardn cluster connect --gateway-url https://gateway.example.com:8443. The URL must be https://. The operator keeps it and reconnects to it by itself.

gateway.advertise (WARDN_GATEWAY_ADVERTISE_ADDR) is the address a gateway reports for itself, such as gateway.example.com:8443. Set it to the same address operators dial.

Several replicas

In wardn-standard, every replica runs a gateway. Each cluster is held by exactly one of them at a time:

  1. The owner of a cluster is chosen by hashing the cluster over the gateways that are alive, and it takes a lease on the cluster in the database.
  2. An operator that reaches a replica which is not its owner is refused, and reconnects through the same address until the load balancer sends it to the owner.
  3. When a replica stops, its clusters move to another within the lease time, WARDN_GATEWAY_LEASE_TTL (15 seconds by default, at least 3 seconds). Their operators reconnect and resume from the last batch Wardn acknowledged.

In wardn-scale, the gateways are their own Deployment, behind the gateway Service, and an operator that reaches the wrong one is sent on the same way. A terminal or a log stream in the web app reaches whichever replica the browser landed on. If that replica does not hold the cluster, it passes the request, unchanged, to the one that does, at the address in WARDN_GATEWAY_API_ADDR. The charts set it to the pod's IP and port 8080, so replicas must be able to reach each other's pods on that port. The receiving replica checks the request again; the hop adds no trust.

Disconnecting a cluster

wardn cluster disconnect revokes a cluster's certificate, its stream tokens and its unused join tokens. A connected operator is cut off within seconds, and the gateway refuses it until the cluster gets a new join token and joins again. See wardn cluster.

Firewalls and network policies

  • From each cluster: outbound TCP to the gateway's address and port.
  • Between replicas: TCP to each other's pod IP on 8080, for passed-on terminals and log streams.
  • To the ops port (9090): only from your monitoring. It serves profiles and metrics.

Next

On this page