For the complete documentation index, see llms.txt. This page is also available as Markdown.

Control Center in Kubernetes with TLS

Running GridGain Control Center and a GridGain cluster in Kubernetes with TLS encryption at every step, from certificate generation to cluster attachment.

This topic covers how you can set up GridGain and Control Center with encryption on each step.

1. Create Certificate Files

First, generate certificates for all the components: frontend, backend and GridGain nodes. Below is a generation script that creates certificates. Make sure to specify your own data instead of placeholders.

countryName value must be a two-letter country code.

script.sh
#!/usr/bin/env bash

set -x

# Certificates password.
PASS=qwerty

# Server.
SERVER_DN="CN=localhost,OU=ID,O=GG,L=Hursley,S=Hants,C=GB"

# ca key config.
cat << EOF > ca_key.conf
[req]
prompt                 = no
distinguished_name     = dn
req_extensions         = req_ext
[ dn ]
countryName            = MyCountry
stateOrProvinceName    = MyState
localityName           = MyLocality
organizationName       = MyCompany
commonName             = localhost
organizationalUnitName = IT
emailAddress           = example@test.local
[ req_ext ]
subjectAltName         = @alt_names
[ alt_names ]
DNS.1                  = localhost
EOF

# ca configuration file
cat << EOF > ca.cnf
[ ca ]
default_ca = CertificateAuthority

[ CertificateAuthority ]
certificate = ./ca.pem
database = ./index.txt
private_key = ./ca.key
new_certs_dir = ./
default_md = sha256
policy = policy_match
serial = ./serial
default_days = 365

[policy_match]
commonName = supplied
EOF

touch index.txt
echo 01 > serial

# Generate CA
openssl req -new -newkey rsa:2048 -nodes -config ca_key.conf -out ca.csr -keyout ca.key
openssl x509 -trustout -signkey ca.key -req -in ca.csr -out ca.pem
keytool -deststorepass ${PASS} -noprompt  -import -file ca.pem -alias CertificateAuthority -keystore trust.jks

# Generate node certificates
keytool -genkey -keyalg RSA -keysize 2048 -alias node -deststorepass ${PASS} -keystore node.jks -noprompt \
 -dname ${SERVER_DN} \
 -storepass ${PASS} \
 -keypass ${PASS}
keytool -deststorepass ${PASS} -certreq -alias node -file node.csr -keystore node.jks
openssl ca -batch -config ca.cnf -out node.pem -infiles node.csr
keytool -deststorepass ${PASS} -import -alias ca -keystore node.jks -file ca.pem -noprompt
keytool -deststorepass ${PASS} -import -alias node -keystore node.jks -file node.pem -noprompt
keytool -importkeystore -srcstoretype JKS -deststoretype PKCS12 -srckeystore node.jks -destkeystore node.p12 -srcstorepass ${PASS} -deststorepass ${PASS} -srcalias node -destalias node -noprompt
openssl pkcs12 -in node.p12 -out ca_odbc.pem -passin pass:${PASS} -nodes

# frontend key config
cat << EOF > frontend.conf
[req]
prompt                 = no
distinguished_name     = dn
req_extensions         = req_ext
[ dn ]
countryName            = MyCountry
stateOrProvinceName    = MyState
localityName           = MyLocality
organizationName       = MyCompany
commonName             = localhost
organizationalUnitName = IT
emailAddress           = example@test.local
[ req_ext ]
subjectAltName         = @alt_names
[ alt_names ]
DNS.1                  = localhost
DNS.2                  = frontend
DNS.3                  = frontend.gridgain-control-center
IP.1                   = 127.0.0.1
EOF

# Generate frontend certificates
openssl genrsa -out frontend.nopass.key 1024
openssl req -new -key frontend.nopass.key -config frontend.conf -out frontend.csr
openssl x509 -req -days 365 -in frontend.csr -CA ca.pem -CAkey ca.key -set_serial 01 -extensions req_ext -extfile frontend.conf -out frontend.crt
openssl pkcs12 -export -in frontend.crt -inkey frontend.nopass.key -passin pass:${PASS} -certfile frontend.crt -out frontend.p12 -passout pass:${PASS}
keytool -importkeystore -srckeystore frontend.p12 -srcstoretype PKCS12 -destkeystore frontend.jks -deststoretype JKS -noprompt -srcstorepass ${PASS} -deststorepass ${PASS}

# backend key config
cat << EOF > backend.conf
[req]
prompt                 = no
distinguished_name     = dn
req_extensions         = req_ext
[ dn ]
countryName            = MyCountry
stateOrProvinceName    = MyState
localityName           = MyLocality
organizationName       = MyCompany
commonName             = localhost
organizationalUnitName = IT
emailAddress           = example@test.local
[ req_ext ]
subjectAltName         = @alt_names
[ alt_names ]
DNS.1                  = localhost
DNS.2                  = backend
DNS.3                  = backend.gridgain-control-center
IP.1                   = 127.0.0.1
EOF

# Generate backend certificates
openssl genrsa -des3 -passout pass:${PASS} -out backend.key 1024
openssl req -new -passin pass:${PASS} -key backend.key -config backend.conf -out backend.csr
openssl x509 -req -days 365 -in backend.csr -CA ca.pem -CAkey ca.key -set_serial 01 -extensions req_ext -extfile backend.conf -out backend.crt
openssl pkcs12 -export -in backend.crt -inkey backend.key -passin pass:${PASS} -certfile backend.crt -out backend.p12 -passout pass:${PASS}
keytool -importkeystore -srckeystore backend.p12 -srcstoretype PKCS12 -destkeystore backend.jks -deststoretype JKS -noprompt -srcstorepass ${PASS} -deststorepass ${PASS}

As a result of execution, you will get a set of key and certificate files.

2. Set up Control Center

Now that you have certificates, configure Control Center to use SSL:

  • Create new namespace gridgain-control-center in kubernetes.

    • Create Control Center namespace:

    • Set namespace as current:

  • Place required certificates in k8s secrets:

    • Create secret for backend:

    • Create secret for frontend:

  • Set up Control Center backend with the following commands:

    • Apply backend configuration: kubectl apply -f control-center-backend-configmap.yaml

    • Create a backend statefulset: kubectl apply -f control-center-backend-statefulset.yaml

    • Create a backend service: kubectl apply -f control-center-backend-service.yaml

  • Set up Control Center frontend:

    • Apply the configuration file: kubectl apply -f control-center-frontend-configmap.yaml

    • Apply the deployment configuration: kubectl apply -f control-center-frontend-deployment.yaml

    • Create the frontend service: kubectl apply -f control-center-frontend-service.yaml

After you complete configuration, check the frontend service with the kubectl get svc frontend -n gridgain-control-center command:

Now frontend web will be available on https://{EXTERNAL-IP}:8443 URL.

Get the token for authorization in Control Center from backend logs. You can get them with the kubectl logs backend-0 command:

3. Set up GridGain Cluster

To use SSL on all stages of the connection, you also need a GridGain cluster to run SSL:

  • Create the new namespace by using the following commands:

    • kubectl create namespace gridgain

    • kubectl config set-context --current --namespace=gridgain

  • Put required certificates in Kubernetes:

    • kubectl create secret generic certificate --from-file=node.jks --from-file=trust.jks

  • Deploy the server nodes:

    • Create the gridgain service: kubectl create -f service.yaml

    • Create a GridGain service account: kubectl create sa gridgain

    • Configure cluster role: kubectl create -f cluster-role.yaml

    • Configure the node: kubectl create configmap gridgain-config --from-file=node-configuration.xml

    • Create the stateful set: kubectl create -f statefulset.yaml

4. Connect GridGain cluster to Control Center

  • Check gridgain pod name with the kubectl get pods -n gridgain command:

  • Get a shell to the running gridgain container:

    • kubectl exec -it gridgain-cluster-0 -n gridgain -- /bin/bash

  • Inside the container, configure connection to Control Center:

    • cd /opt/gridgain/bin/

    • ./management.sh --uri https://frontend.gridgain-control-center:8443 --management-truststore-type jks --management-truststore /gridgain/tls/trust.jks --management-truststore-password qwerty

    • exit

Use the token from the logs to attach cluster with the kubectl logs gridgain-cluster-0 -n gridgain command:

Last updated

Was this helpful?