Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Q1. Create a Secret with name mysecret using YAML, which consists the #following data.
- #USERNAME:
- #PASSWORD:
- kind: Secret
- apiVersion: v1
- metadata:
- name: mysecret
- type: Opaque
- stringData:
- username: myusername
- password: mypassword
- ---
- #Q2. Create a Pod with name mysecretpod which will be consuming the #secret mysecret as environment variable TOPSECRETUSERNAME will have #value of USERNAME and environment variable TOPSECRETPASSWORD will have #value of PASSWORD. You can use any image of your choice for creating #pod.
- apiVersion: v1
- kind: Pod
- metadata:
- name: mysecretpod
- spec:
- containers:
- - name: mysecretpod
- image: nginx:alpine
- ports:
- - containerPort: 80
- env:
- - name: TOPSECRETUSERNAME
- valueFrom:
- secretKeyRef:
- name: mysecret
- key: username
- - name: TOPSECRETPASSWORD
- valueFrom:
- secretKeyRef:
- name: mysecret
- key: password
- command: ["/bin/sh", "-c"]
- args:
- - cat date >> /usr/share/nginx/html;
- while true; do
- echo $username >> /usr/share/nginx/html;
- echo $password >> /usr/share/nginx/html;
- sleep 1;
- done
- restartPolicy: Never
- ---
- #Q3. Create a ConfigMap with name myconf using YAML, which consists the #following data.
- #COMPANY:
- #PROJECT:
- apiVersion: v1
- kind: ConfigMap
- metadata:
- name: myconf
- data:
- COMPANY: mycomp
- PROJECT: myproj
- #Q4. Create a Pod with name myconfpod which will be mounting the data #from ConfigMap myconf at the location /tmp/data of pod. You can use #any image of your choice for creating pod.
- kind: Pod
- apiVersion: v1
- metadata:
- name: myconfpod
- spec:
- containers:
- - name: myconfpod
- image: nginx:alpine
- ports:
- - containerPort: 80
- # command: [ "/bin/sh", "-c", "ls /tmp/" ]
- volumeMounts:
- - name: config-volume
- mountPath: /tmp/data
- volumes:
- - name: config-volume
- configMap:
- name: myconf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement