Exercise 3.4: Deploy A Sample Application
kubectl create deployment nginx --image=nginxkubectl get deploykubectl get podkubectl describe deployment nginxkubectl get events --sort-by='.metadata.creationTimestamp'kubectl get deploy nginx -o yamlkubectl get deploy nginx -o yaml > first.yamlapiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" generation: 1 labels: app: nginx name: nginx namespace: default spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: nginx strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx imagePullPolicy: Always name: nginx resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30
kubectl delete deploy nginxkubectl apply -f first.yamlkubectl get deploykubectl get deploy nginx -o yaml > second.yamldiff first.yaml second.yaml -ykubectl get deploy nginx -o=jsonpath='{.metadata.resourceVersion}{"\n"}'kubectl delete pod -l app=nginxkubectl get deploy nginx -o=jsonpath='{.metadata.resourceVersion}{"\n"}'kubectl create deployment nginx --image=nginx --dry-run=client -o yamlkubectl get deployment nginx -o jsonkubectl expose deployment/nginxkubectl expose -h.... spec: containers: - image: nginx imagePullPolicy: Always name: nginx ports: - containerPort: 80 protocol: TCP ....apiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" generation: 1 labels: app: nginx name: nginx namespace: default spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: nginx strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx imagePullPolicy: Always name: nginx ports: - containerPort: 80 protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30kubectl apply -f first.yamlkubectl get deploy,rs,podkubectl expose deployment/nginxkubectl get svc nginxkubectl get ep nginxkubectl get pod -l app=nginx -o widesudo tcpdump -i cilium_vxlancurl NGINX_SVC_CLUSTER_IPcurl $(kubectl get svc nginx -o=jsonpath='{.spec.clusterIP}')ip akubectl get ciliumnodescurl NGINX_ENDPOINT_IPcurl $(kubectl get ep nginx -o=jsonpath='{.subsets[0].addresses[0].ip}:{.subsets[0].ports[0].port}')kubectl scale deployment nginx --replicas=3kubectl get pod -l app=nginx -o widekubectl get ep nginx
Last updated