Retrieve Keys from a Kubernetes Secret

Retrieve TLS certificates from a Kubernetes secret added with a configuration source to the /opt/mtx/conf/keystore directory.

Procedure

  1. Enable use of Kubernetes secrets with the following configuration in gateway.yaml:
    #Set the security type to cert the default is keyStore
    securityType: cert
    #Give the name of the secret that will be created in Kubernetes
    security:
      certificate:
        secretName: "" 
  2. Create the Kubernetes secret with the following kubectl create secret command:
    kubectl create secret tls name_of_secret \
      --cert=cert.crt \
      --key=cert.key

    The name of the Kubernetes secret must meet the following requirements:

    • Must consist of lower case alphanumeric characters.
    • Must contain a hyphen (-) or a period (.).
    • Must end with an alphanumeric character.
  3. Add certificates for the Vertx server by creating a certificate and a key file with commands similar to the following:
    Warning: Use self-signed certificates for development and integration testing only.
    # generate the RSA key, protected without a password:
    openssl genpkey -out cert.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048
    
    # generate a self-signed certificate using the cert key
    openssl req -nodes -key cert.key -x509 -sha256 -days 3650 -out cert.crt \
     -subj "/C=US/ST=CA/L=SJ/O=Matrixx/OU=Eng/CN=example.com/emailAddress=user@host" \
     -addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"
    
    # generate the RSA key, protected without a password:
    openssl genpkey -out trustcert.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048
    
    # generate a self-signed certificate using the trust cert key
    openssl req -nodes -key trustcert.key -x509 -sha256 -days 3650 -out trustcert.crt \
     -subj "/C=US/ST=CA/L=SJ/O=Matrixx/OU=Eng/CN=example.com/emailAddress=user@host" \
     -addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"

Results

The default location for certsPath and keyPath is /opt/mtx/conf/keystore. The following YAML structure defines the certificates and key:
cert:
  certPath: /opt/mtx/conf/keystore/cert.crt
  keyPath: /opt/mtx/conf/keystore/cert.key
trustcert:
  certPath: /opt/mtx/conf/keystore/trustcert.crt
  keyPath: /opt/mtx/conf/keystore/trustcert.key

For information about adding the Kubernetes secret to your MATRIXX deployment, see the discussion about configuration sources in MATRIXX Installation and Upgrade.