Skip to main content

Use self-signed SSL certificates (Kubernetes Deployments)

danger

Follow this process only after running the devops.automations script during your initial deployment and each additional time you run the script (such as updating your Cinchy platform), as it wipes out all custom configurations you set up to use a self-signed certificate.

  1. Execute the following commands in any folder to generate the self-signed certificate:
openssl genrsa -des3 -out rootCA.key 4096
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
openssl genrsa -out mydomain.com.key 2048
openssl req -new -sha256 -key mydomain.com.key -subj "/C=US/ST=CA/O=MyOrg, Inc./CN=mydomain.com " -out mydomain.com.csr
  1. Create a YAML file located at cinchy.kubernetes/platform_components/base/self-signed-ssl-root-ca.yaml.

  2. Add the following to the YAML file:

apiVersion: v1
kind: ConfigMap
metadata:
name: self-signed-ca-pemstore
data:
rootCA.crt: |
<rootCA.crt>
  1. Add the self signed root CA cert file to the cinchy.kubernetes/environment_kustomizations/cinchy_nonprod/base folder.

  2. Add the yaml code snippet to the cinchy.kubernetes/environment_kustomizations/cinchy_nonprod/base/kustomization.yaml file, changing the below files key value as per your root ca cert file name:

configMapGenerator:
- name: self-signed-ca-pemstore
behavior: replace
files:
- rootCA.crt
  1. Add the following line to the cinchy.kubernetes/platform_components/base/kustomization.yaml file
- self-signed-ssl-root-ca.yaml
  1. Add the below Deployment patchesJson6902 to each of your cinchy.kubernetes/environment_kustomizations/cinchy_nonprod/ENV_NAME/PLATFORM_COMPONENT_NAME/kustomization.yaml files, except base.
  • Ensure that the rootCA.crt file name is matched with ConfigMap data, configMapGenerator files, and the patch subpath.
    - op: add
path: /spec/template/spec/volumes/-
value:
configMap:
name: self-signed-ca-pemstore
name: self-signed-ca-pemstore
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value:
mountPath: /etc/ssl/certs/rootCA.crt
name: self-signed-ca-pemstore
subPath: rootCA.crt
  1. Once the changes are deployed, verify the root CA cert is available on the pod under /etc/ssl/certs with below command. Make sure to input your own POD_NAME and NAMESPACE:
 kubectl exec -it POD_NAME -n NAMESPACE -- openssl x509 -in /etc/ssl/certs/rootCA.crt -text