Exercise 2.3: Create a Basic Pod
쿠버네티스 API 리소스 목록 확인
kubectl api-resourcesPod 객체의 API 경로 확인
kubectl get pod -v 6Ingress 객체의 API 경로 확인
kubectl get ing -v 6Pod 객체의 필드 확인
kubectl explain podPod 생성
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx EOFPod 상태 확인
kubectl get pod nginxPod 상세 내용 확인
kubectl describe pod nginxPod 삭제
kubectl delete pod nginxPod가 삭제 되었는지 확인
kubectl get pod nginxPodSpec에 명시하는 컨테이너의 포트 정보가 무엇을 의미하는지 확인
kubectl explain pod.spec.containers.portsNGINX 이미지 생성에 사용한 Dockerfile 확인 - https://hub.docker.com/_/nginx/tags
Dockerfile에서 EXPOSE가 무엇을 의미하는지 확인 - https://docs.docker.com/engine/reference/builder/#expose
Pod 생성
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 EOFNGINX 설정 파일 확인
kubectl exec nginx -- cat /etc/nginx/conf.d/default.conf생성된 Pod의 IP주소 확인
kubectl get pod nginx -o wideCURL 명령어를 통해서 생성된 Pod의 IP주소로 HTTP 요청
curl $(kubectl get pod nginx -o=jsonpath='{.status.podIP}')Pod 삭제
kubectl delete pod nginxService 생성
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: selector: app: nginx ports: - protocol: TCP port: 80 EOF생성된 Service 확인
kubectl get svc nginx -o wide생성된 Endpoint 확인
kubectl get ep nginxPod 생성
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 EOF생성된 Pod 확인
kubectl get pod -o wide -l app=nginxEndpoint 확인
kubectl get ep nginxCURL 명령어를 통해서 Service의 Cluster IP로 HTTP 요청
curl $(kubectl get svc nginx -o=jsonpath='{.spec.clusterIP}')위에서 생성한 Service를 NodePort 형식으로 변경
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Service metadata: name: nginx spec: selector: app: nginx type: NodePort ports: - protocol: TCP port: 80 EOFService의 IP주소 및 포트 확인
kubectl get service nginx웹브라우저에서
ANY_NODE_IP:SERVICE_NODE_PORT로 접속되는지 확인 - 아래 명령어로 주소 확인 가능echo "$(curl -s ifconfig.io):$(kubectl get svc nginx -o=jsonpath='{.spec.ports[0].nodePort}')"
Last updated