Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #Q1. Create a Secret with name mysecret using YAML, which consists the #following data.
  2. #USERNAME:
  3. #PASSWORD:
  4.  
  5. kind: Secret
  6. apiVersion: v1
  7. metadata:
  8. name: mysecret
  9. type: Opaque
  10. stringData:
  11. username: myusername
  12. password: mypassword
  13.  
  14. ---
  15. #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.
  16.  
  17.  
  18. apiVersion: v1
  19. kind: Pod
  20. metadata:
  21. name: mysecretpod
  22. spec:
  23. containers:
  24. - name: mysecretpod
  25. image: nginx:alpine
  26. ports:
  27. - containerPort: 80
  28. env:
  29. - name: TOPSECRETUSERNAME
  30. valueFrom:
  31. secretKeyRef:
  32. name: mysecret
  33. key: username
  34. - name: TOPSECRETPASSWORD
  35. valueFrom:
  36. secretKeyRef:
  37. name: mysecret
  38. key: password
  39. command: ["/bin/sh", "-c"]
  40. args:
  41. - cat date >> /usr/share/nginx/html;
  42. while true; do
  43. echo $username >> /usr/share/nginx/html;
  44. echo $password >> /usr/share/nginx/html;
  45. sleep 1;
  46. done
  47. restartPolicy: Never
  48.  
  49. ---
  50. #Q3. Create a ConfigMap with name myconf using YAML, which consists the #following data.
  51. #COMPANY:
  52. #PROJECT:
  53. apiVersion: v1
  54. kind: ConfigMap
  55. metadata:
  56. name: myconf
  57. data:
  58. COMPANY: mycomp
  59. PROJECT: myproj
  60.  
  61.  
  62. #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.
  63.  
  64. kind: Pod
  65. apiVersion: v1
  66. metadata:
  67. name: myconfpod
  68. spec:
  69. containers:
  70. - name: myconfpod
  71. image: nginx:alpine
  72. ports:
  73. - containerPort: 80
  74. # command: [ "/bin/sh", "-c", "ls /tmp/" ]
  75. volumeMounts:
  76. - name: config-volume
  77. mountPath: /tmp/data
  78. volumes:
  79. - name: config-volume
  80. configMap:
  81. name: myconf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement