Skip to content

Instantly share code, notes, and snippets.

@youcefguichi
Last active April 9, 2025 08:04
Show Gist options
  • Save youcefguichi/5298d1ed356ea482a6693b23f371d6ff to your computer and use it in GitHub Desktop.
Save youcefguichi/5298d1ed356ea482a6693b23f371d6ff to your computer and use it in GitHub Desktop.

Construct te required secrets from the certs i provided

kubectl create secret generic truststore \
  --from-file=ca.p12=<path-to-your-ca.p12> \
  --from-literal=ca.password=<your-ca.password> \
  --namespace=test
kubectl create secret generic keystore \
  --from-file=user.p12=<path-to-your-user.p12> \
  --from-literal=user.password=<your-user.password> \
  --namespace=test

Sample client that mounts the secrets

apiVersion: v1
kind: Pod
metadata:
  name: client-example
  namespace: test
spec:
  containers:
  - name: test
    image: your-image
    env:
    - name: CA_PASSWORD # the passwords will provided as env variables as well that your code can use
      valueFrom:
        secretKeyRef:
          name: truststore
          key: ca.password
    - name: USER_PASSWORD
      valueFrom:
        secretKeyRef:
          name: keystore
          key: user.password
    volumeMounts:
    - name: keystore
      mountPath: /tmp/keystore  # this folder will have /tmp/keystore/user.p12 and /tmp/keystore/user.password
    - name: truststore
      mountPath: /tmp/truststore  # this folder will have /tmp/truststore/ca.p12 and /tmp/truststore/ca.password
  volumes:
  - name: keystore
    secret:
      secretName: keystore
  - name: truststore
    secret:
      secretName: truststore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment