Lab8 Secret Solution
Secret de type Volume
Copier le fichier /etc/nginx/nginx.conf à partir d’un pod web existant
kubectl cp web:/etc/nginx/nginx.conf nginx.confModifier le fichier et créer un Secret nommé nginx-conf
kubectl create secret generic nginx-conf --from-file=nginx.confCréer un pod web avec le Secret nginx-conf
vi web.ymlapiVersion: v1kind: Podmetadata: name: web labels: app: webspec: containers: - name: www image: nginx:1.17-alpine volumeMounts: - name: config mountPath: "/etc/nginx/nginx.conf" subPath: "nginx.conf" volumes: - name: config secret: secretName: nginx-confVérifier le fichier de conf /etc/nginx/nginx.conf du pod web
kubectl exec -it web -- shcat /etc/nginx/nginx.confSecret de type variable d’environnement
Créer un Secret nommé mysql-pass qui contient une clé password et une valeur root
kubectl create secret generic mysql-pass --from-literal=password=rootVisualiser le Secret
kubectl get sc/mysql-pass -o yamlCréer un pod mysql et initialiser le ROOT_PASSWORD de mysql
vi mysql.ymlapiVersion: v1kind: Podmetadata: name: mysqlspec: containers: - image: mysql:5.6 name: mysql env: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: name: mysql-pass key: passwordkubectl apply -f mysql.ymlVérifier que le pod mysql est Running
kubectl get pods