Exercise 5.3: Using ConfigMaps Configure Ambassador Containers
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" EOFkubectl get pv weblog-pv-volumecat <<EOF | kubectl create -f - kind: PersistentVolumeClaim apiVersion: v1 metadata: name: weblog-pv-claim spec: accessModes: - ReadWriteOnce resources: requests: storage: 100Mi EOFkubectl get pvc weblog-pv-claimcat <<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 EOFkubectl get pod nginx -o widels -al /tmp/weblog/for i in {1..5} do curl -sI $(kubectl get pod nginx -o=jsonpath='{.status.podIP}') done{ kubectl exec nginx -it -c nginx -- ls -al /var/log/nginx kubectl exec nginx -it -c nginx -- cat /var/log/nginx/access.log }cat /tmp/weblog/access.logkubectl logs nginx -c fdloggercat <<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> EOFkubectl delete pod nginxcat <<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 EOFfor i in {1..5} do curl -sI $(kubectl get pod nginx -o=jsonpath='{.status.podIP}') donekubectl 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