# Secure access across services

This page explains how secure access is provided across a Kuma deployment:

  • Security between our services, via the mTLS policy.
  • Security between the Kuma control plane and its data plane proxies, via the data plane proxy token.
  • Security when accessing the control plane.
  • Security when external systems access the control plane.

Kuma stores autogenerated certificates and other files in a working directory. The default value for this directory is $HOME/.kuma. You can change the working directory by setting the KUMA_GENERAL_WORK_DIR environment variable.

This section is not to be confused with the mTLS policy that we can apply to a Mesh to secure service-to-service traffic.

# Data plane proxy to control plane communication

A data plane proxy connects to the control plane for its configuration, including mTLS certificates described in the following sections.

# Encrypted communication

Because the data plane proxy and the control plane exchange sensitive information, the communication needs to be encrypted by TLS. By default, the control plane's server that is consumed by the data plane proxy is secured by TLS with autogenerated certificates.

It is recommended that the data plane proxy verifies the identity of the control plane. To do so, data plane proxies need to obtain the CA that was used to generate the certificate by which the control plane's server is secured. Note, this CA is not the same CA for service-to-service communication.

To override autogenerated certificates

    # Authentication

    See Data plane proxy authentication and Zone Ingress authentication.

    # User to control plane communication

    Users and automation tools can interact with the control plane via the API Server using tools like curl or kumactl. API Server is exposed by default on :5681 on HTTP and :5682 on HTTPS.

    # Encrypted communication

    The API Server HTTPS server is secured by default by autogenerated certificates.

    To override autogenerated certificates.

    1. Prepare certificates

    Generate TLS pair with a PKI of your choice and store it in PEM-encoded format in /tmp/tls.crt, /tmp/tls.key. Store the CA that was used to sign this pair in /tmp/ca.crt

    We can also use kumactl to generate self-signed certs.

    kumactl generate tls-certificate \
      --type=server \
      --hostname=<KUMA_CP_DNS_NAME> \ # pick a name that will be used by kumactl or other client to connect to the control plane
      --cert-file=/tmp/tls.crt \
      --key-file=/tmp/tls.key
    cp /tmp/tls.crt /tmp/ca.crt # since this is self-signed cert, the cert is also a CA
    
    1
    2
    3
    4
    5
    6
    1. Configure the control plane with generated certificates
      1. Configure secure connection using kumactl CLI tool.
      kumactl config control-planes add \
        --name=<NAME> \
        --address=https://<KUMA_CP_DNS_NAME>:5682 \
        --ca-cert-file=/tmp/ca.crt \
      
      1
      2
      3
      4

      We can also hide the HTTP version of API Server by binding it to localhost KUMA_API_SERVER_HTTP_INTERFACE: 127.0.0.1 or by disabling it altogether KUMA_API_SERVER_HTTP_ENABLED: false

      # Authentication

      See API Server authentication.

      # Control plane to control plane (Multizone)

      A zone control plane connects to a global control plane for policies configuration.

      # Encrypted communication

      Because the global control plane and the zone control plane exchange sensitive information, the communication needs to be encrypted by TLS. By default, the global control plane's server that is consumed by the zone control plane is secured by TLS with autogenerated certificates.

      It is recommended that the zone control plane verifies the identity of the global control plane. To do so, zone control planes need to obtain the CA that was used to generate the certificate by which the control plane's server is secured.

      To override autogenerated certificates

      1. Prepare certificates

      Generate TLS pair with a PKI of your choice and store it in PEM-encoded format in /tmp/tls.crt, /tmp/tls.key. Store the CA that was used to sign this pair in /tmp/ca.crt

      We can also use kumactl to generate self-signed certs.

      kumactl generate tls-certificate \
        --type=server \
        --hostname=<CROSS_ZONE_KUMA_CP_DNS_NAME> \
        --cert-file=/tmp/tls.crt \
        --key-file=/tmp/tls.key
      cp /tmp/tls.crt /tmp/ca.crt # since this is self-signed cert, the cert is also a CA
      
      1
      2
      3
      4
      5
      6
      1. Configure global control plane
        1. Configure the zone control plane

          # Authentication

          Define firewall rules on the global control plane to only accept connections from known IPs of the zone control planes.

          Third-party extensions, cloud implementations or commercial offerings may be extending the authentication support.

          # Control plane to Postgres communication

          Since on Universal secrets such as provided CA's private key are stored in Postgres, a connection between Postgres and Kuma CP should be secured with TLS.

          To secure the connection, we first need to pick the security mode using KUMA_STORE_POSTGRES_TLS_MODE. There are several modes:

          • disable - is not secured with TLS (secrets will be transmitted over network in plain text).
          • verifyNone - the connection is secured but neither hostname, nor by which CA the certificate is signed is checked.
          • verifyCa - the connection is secured and the certificate presented by the server is verified using the provided CA.
          • verifyFull - the connection is secured, certificate presented by the server is verified using the provided CA and server hostname must match the one in the certificate.

          The CA used to verify the server's certificate can be set using the KUMA_STORE_POSTGRES_TLS_CA_PATH environment variable.

          After configuring the above security settings in Kuma, we also have to configure Postgres' pg_hba.conf (opens new window) file to restrict unsecured connections.

          Here is an example configuration that will allow only TLS connections and will require username and password:

          # TYPE  DATABASE        USER            ADDRESS                 METHOD
          hostssl all             all             0.0.0.0/0               password
          
          1
          2

          We can also provide a client key and certificate for mTLS using the KUMA_STORE_POSTGRES_TLS_CERT_PATH and KUMA_STORE_POSTGRES_TLS_KEY_PATH variables. This pair can be used in conjunction with the cert auth-method described here (opens new window).

          Last Updated: 2/23/2022, 3:49:32 PM