Kubernetes
Use Onboardbase in your Kubernetes environment.
Onboardbase can generate secrets that work in a Kubernetes environment.
1. Onboardbase CLI
After installing the Onboardbase CLI, you'll need to login to your Onboardbase account.
- If you have browser access on your server you can use the
onboardbase login
command. - Otherwise you'll need to create a service token for machine-to-machine communication using the web dashboard.
2. Creating the secret configuration
Once logged in, we use the Onboardbase secrets --docker
command to generate a file containing our environment variables:
kubectl create secret generic onboardbase-env-vars --from-env-file <(onboardbase secrets --docker -p "Onboardbase project name" -e "deployment environment")
You can view the generated secrets with:
kubectl describe secret onboardbase-env-vars
3. Referencing the secret config
Next, create a Pod that will use the generated secret (onboardbase-env-vars)
to create an environment variable for every key defined in the secret's data using the below spec (onboardbase-env-vars-pod.yaml)
:
apiVersion: v1
kind: Pod
metadata:
name: onboardbase-env-vars
spec:
restartPolicy: Never
containers:
- name: onboardbase-env-vars
image: ubuntu
args: ["printenv"] # start command here
# Populates every key in the secret as an env var
envFrom:
- secretRef:
name: onboardbase-env-vars
4. Create the K8s Pod
Finally, create a pod from the specification:
kubectl apply -f onboardbase-env-vars-pod.yaml
Confirm that the secrets were printed with:
kubectl logs onboardbase-env-vars
Updated 3 months ago