KUBERNETES( Commands , Arguments and ENV variables)
In this below sample yaml file- command & arguments values are executed during the container startup.
SAMPLE YAML Showing the Usage Command & Argument.
Passing just and argument to overwrite the default value:
SAMPLE YAML showing the usage of Argument:
ENV Variable:
In kubernetes to set and environment variable we can use env property.
There are different way to sett the environment variable.
- Plain Key value:
env:
-name: Color
value: green
- ConfigMap
env:
-name: Color
valueFrom:
configMapKeyRef:
- Secrets :
Secret are used to store the sensitive information like- password , keys etc. They are stored in encoded or Hashed format.
Steps involved- 1.) Create a secret. 2.) Inject into to pod.
Two ways to create a Secret —
1.) Imperative way without using a definition file :-
syntax: kubectl create secret generic <secret name> — from-leteral=<Key> =<Value>
kubectl create secret generic app-secret — from-literal=DB_HOST=OracleServer
— from-literal=DB_USER=OracleUser
Create from file:
kubectl create secret generic <secret-name> — from-file=<path-to-file>
kubectl create secret generic app-secret — from-file=app_secret.properties
2.) Declarative way by using a secret definition file.
syntax: kubectl create -f
env:
-name: Color
valueFrom:
secretKeyRef:=================================
secret1.yaml:
apiVersion: v1
kind: Secret
metadata:
name: app-secret
data:
DB_USER: jdw82js=$
DB_PASS: GFcCd674k=================================
Pod-defn.yaml:
apiVersion: v1
kind: Pod
metadata:
name: app1
labels:
name: app1
spec:
containers:
- name: app1
image: app1
ports:
-containerPort: 8080
envFrom:
-secretRef:
name: app-secret