Exercise 5.1: Configure the Deployment: ConfigMaps
CP 노드에 연결된 터미널로 이동
ConfigMap에 사용할 파일 생성
{ cd && mkdir primary echo c > primary/cyan echo m > primary/magenta echo y > primary/yellow echo k > primary/black echo "known as key" >> primary/black echo blue > favorite }ConfigMap 생성
kubectl create configmap colors \ --from-literal=text=black \ --from-file=./favorite \ --from-file=./primary/생성된 ConfigMap 확인
kubectl get cm colors생성된 ConfigMap 데이터 확인
kubectl get cm colors -o yamlPod 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx env: - name: ilike valueFrom: configMapKeyRef: name: colors key: favorite EOF생성된 Pod에 지정한 환경변수 확인
kubectl exec shell-demo -- /bin/bash -c 'echo $ilike'Pod 삭제
kubectl delete pod shell-demoPod 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx envFrom: - configMapRef: name: colors EOF생성된 Pod에 지정된 모든 환경변수 확인
kubectl exec shell-demo -- /bin/bash -c 'env'Pod 삭제
kubectl delete pod shell-demoConfigMap 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: ConfigMap metadata: name: fast-car namespace: default data: car.make: Ford car.model: Mustang car.trim: Shelby EOF생성된 ConfigMap 데이터 확인
kubectl get cm fast-car -o yamlPod 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx volumeMounts: - name: car-vol mountPath: /etc/cars volumes: - name: car-vol configMap: name: fast-car EOF생성된 Pod에 ConfigMap의 데이터가 볼륨으로 마운트 되었는지 확인
kubectl exec shell-demo -- ls /etc/cars생성된 Pod에 마운트된 파일 내용 확인
kubectl exec shell-demo -- /bin/bash -c 'cat /etc/cars/car.trim; echo'Pod 삭제
kubectl delete pod shell-demoReadiness Probe를 명시하고 Pod 생성
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx volumeMounts: - name: car-vol mountPath: /etc/cars readinessProbe: exec: command: - ls - /etc/cars periodSeconds: 5 volumes: - name: car-vol configMap: name: fast-car EOFPod 상태 확인
kubectl get pod shell-demo리소스 삭제
{ kubectl delete pod shell-demo kubectl delete cm fast-car colors }
PreviousCHAPTER 5. DEPLOYMENT CONFIGURATIONNextExercise 5.2: Configure the Deployment: Attaching Storage
Last updated