Kubernetes environment parameter

Environment parameter


1. Plain key value: put the environment parameter in yaml file

pod yaml file

spec:

    containers:

        env:

        - name: APP_COLOR

           value: pink

2. configMap: put the environment parameter in config map

create #kubectl create -f <configMap file>

check #kubectl get configmap

check #kubectl describe configmap <configmap name>

Example yaml file: https://github.com/tomshenhao/kubernetes-learning/blob/master/configmap.yaml


inject the config map to pod

pod yaml file

spec:

  containers:

  - name: webapp-color

    image: kodekloud/webapp-color

    envFrom:

    - configMapRef:

        name: webapp-config-map


1. Secrets: put the environment parameter in secret in hash format

create #kubectl create -f <secret file>

check #kubectl get secrets

check #kubectl describe secrets <secret name>

check #kubectl get secret <secret name> -o yaml

Get the hash value of the value: echo -n '<value>'|base 64

Example: echo -n 'root' | base64

Get the value from the hash value: echo -n '<hash value>| base64 --decode

Example: echo -n 'bXlzcWw='| base64 --decode

Example yaml file: https://github.com/tomshenhao/kubernetes-learning/blob/master/secret.yaml

inject the secret to pod

pod yaml file

spec:

  containers:

  - name: webapp-color

    image: kodekloud/webapp-color

    envFrom:

    - secretRef:

        name: db-config


Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error