Exercise 5.3: Using ConfigMaps Configure Ambassador Containers
PV 생성
cat <<EOF | kubectl create -f - kind: PersistentVolume apiVersion: v1 metadata: name: weblog-pv-volume labels: type: local spec: capacity: storage: 100Mi accessModes: - ReadWriteOnce hostPath: path: "/tmp/weblog" EOF생성된 PV 확인
kubectl get pv weblog-pv-volumePVC 생성
cat <<EOF | kubectl create -f - kind: PersistentVolumeClaim apiVersion: v1 metadata: name: weblog-pv-claim spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Mi EOF생성된 PVC 확인
kubectl get pvc weblog-pv-claimPod 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: nginx labels: type: webserver spec: containers: - name: nginx image: nginx ports: - containerPort: 80 volumeMounts: - mountPath: "/var/log/nginx/" name: weblog-pv-storage - name: fdlogger image: fluent/fluentd volumeMounts: - mountPath: "/var/log" name: weblog-pv-storage volumes: - name: weblog-pv-storage persistentVolumeClaim: claimName: weblog-pv-claim EOFPod가 생성된 노드 확인
kubectl get pod nginx -o widePod 생성된 노드에 접속해서 hostPath에 명시한 디렉토리가 생성됐는지 확인
ls -al /tmp/weblog/CP 노드로 이동
CURL 명령어를 통해서 생성된 Pod의 IP주소로 HTTP 요청
for i in {1..5} do curl -sI $(kubectl get pod nginx -o=jsonpath='{.status.podIP}') donePod 접속해서 로그파일 확인
{ kubectl exec nginx -it -c nginx -- ls -al /var/log/nginx kubectl exec nginx -it -c nginx -- cat /var/log/nginx/access.log }Pod 생성된 노드에 접속해서 로그파일 확인
cat /tmp/weblog/access.logCP 노드로 이동
Fluentd 컨테이너 로그 확인
kubectl logs nginx -c fdloggerConfigMap 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: ConfigMap metadata: name: fluentd-config data: fluentd.conf: | <source> @type tail format none path /var/log/access.log tag count.format1 </source> <match *.**> @type stdout id stdout_output </match> EOFPod 삭제
kubectl delete pod nginxPod 생성
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: nginx labels: type: webserver spec: containers: - name: nginx image: nginx ports: - containerPort: 80 volumeMounts: - mountPath: "/var/log/nginx/" name: weblog-pv-storage - name: fdlogger image: fluent/fluentd env: - name: FLUENTD_OPT value: -c /etc/fluentd-config/fluentd.conf volumeMounts: - mountPath: "/var/log" name: weblog-pv-storage - name: log-config mountPath: "/etc/fluentd-config" volumes: - name: weblog-pv-storage persistentVolumeClaim: claimName: weblog-pv-claim - name: log-config configMap: name: fluentd-config EOFCURL 명령어를 통해서 생성된 Pod의 IP주소로 HTTP 요청
for i in {1..5} do curl -sI $(kubectl get pod nginx -o=jsonpath='{.status.podIP}') doneFluentd 컨테이너 로그 확인
kubectl logs nginx -c fdlogger리소스 삭제
{ kubectl delete pod nginx kubectl delete cm fluentd-config kubectl delete pvc weblog-pv-claim kubectl delete pv weblog-pv-volume }
PreviousExercise 5.2: Configure the Deployment: Attaching StorageNextExercise 5.4: Rolling Updates and Rollbacks
Last updated