Created
July 12, 2018 22:37
-
-
Save joshy91/4b189dee8dba62ff0b9f8384d5c14500 to your computer and use it in GitHub Desktop.
Configure YAML file using Config Map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#How k8 configures application | |
#Create config map | |
kubectl create configmap my-map –from-literal=school=LinuxAcademy | |
#Check status of config map | |
kubectl get configmaps | |
#Detailed description of config map | |
kubectl describe configmaps my-map | |
#Generate yaml code for config map | |
kubectl get configmap my-map -o yaml | |
echo “apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: config-test-pod | |
namespace: default | |
spec: | |
containers: | |
- name: test-container | |
image: busybox | |
command: [ "/bin/sh", "-c", "env" ] | |
env: | |
- name: WHAT_SCHOOL | |
valueFrom: | |
configMapKeyRef: | |
name: my-map | |
key: school | |
restartPolicy: Never” >> pod-config.yaml | |
#Create pod from yaml file | |
kubectl create -f pod-config.yaml | |
#Check status of pods | |
kubectl get pods | |
#Display logs for config test pod | |
kubectl logs config-test-pod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment