Exercise 2.3: Create a Basic Pod
kubectl api-resourceskubectl get pod -v 6kubectl get ing -v 6kubectl explain podcat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx EOFkubectl get pod nginxkubectl describe pod nginxkubectl delete pod nginxkubectl get pod nginxkubectl explain pod.spec.containers.portscat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 EOFkubectl exec nginx -- cat /etc/nginx/conf.d/default.confkubectl get pod nginx -o widecurl $(kubectl get pod nginx -o=jsonpath='{.status.podIP}')kubectl delete pod nginxcat <<EOF | kubectl apply -f - apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: selector: app: nginx ports: - protocol: TCP port: 80 EOFkubectl get svc nginx -o widekubectl get ep nginxcat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 EOFkubectl get pod -o wide -l app=nginxkubectl get ep nginxcurl $(kubectl get svc nginx -o=jsonpath='{.spec.clusterIP}')cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Service metadata: name: nginx spec: selector: app: nginx type: NodePort ports: - protocol: TCP port: 80 EOFkubectl get service nginxecho "$(curl -s ifconfig.io):$(kubectl get svc nginx -o=jsonpath='{.spec.ports[0].nodePort}')"
Last updated