Exercise 8.1: Troubleshooting: Monitor Applications
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: demo spec: containers: - name: busybox image: busybox command: [ "sleep" ] args: [ "10" ] - name: web image: nginx livenessProbe: httpGet: path: / port: 80 initialDelaySeconds: 3 periodSeconds: 3 EOFkubectl get pod demokubectl describe pod demo{ kubectl logs demo busybox kubectl logs demo web }kubectl get pod demokubectl delete pod democat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: busybox spec: containers: - name: busybox image: busybox command: [ "sleep" ] args: [ "3600" ] securityContext: runAsUser: 2000 EOFkubectl exec -it busybox -- /bin/shnslookup www.linuxfoundation.orgcat /etc/resolv.confnc www.linux.com 25 wget http://www.linux.comexitkubectl delete pod busyboxcat <<EOF | kubectl apply -f - apiVersion: v1 kind: Namespace metadata: name: demo --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: nginx namespace: demo spec: selector: matchLabels: app: nginx replicas: 3 template: metadata: labels: app: nginx spec: containers: - image: nginx:1.20.1 name: nginx ports: - containerPort: 80 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: nginx namespace: demo spec: type: NodePort selector: app: nginx ports: - port: 80 EOFkubectl get svc,ep -n demops -elf |grep kube-proxysudo journalctl -a | grep proxy kubectl -n kube-system logs ds/kube-proxysudo iptables-save |grep nginxcurl localhost:NODE_PORT
Last updated