CLOUD/Docker&Kubernetes

[Kubernetes/Ubuntu] 쿠버네티스 워크로드 - Pod

alsruds 2023. 5. 16. 18:09

[ Pod ]

☆ Pod 를 만들어보자 ☆

● go-http-pod.yaml 작성

# gedit go-http-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: http-go
spec:
  containers:
  - name: http-go
    image: nuy0307/http-go
    ports:
    - containerPort: 8080

 

● 파드 생성 & 확인

# 생성
kubectl create -f go-http-pod.yaml

# 파드 상태 확인
kubectl get pod http-go

# 자세한 정보 출력
kubectl get pod http-go -o wide

# 작성된 내용 확인
kubectl get pod http-go -o yaml

# json 형식으로 작성된 내용 확인
kubectl get pod http-go -o json

# 생성 시간 & 진행 상황 확인
kubectl describe pod http-go

 

● 주석 달기

# 주석 달기
kubectl annotate pod http-go testanno=test^^

# 확인
kubectl get pod http-go -o yaml

 

● 삭제

# 특정 파드 삭제
kubectl delete -f go-http-pod.yaml

# 모든 파드 삭제
kubectl delete pod --all

 

 

☆ Jenkins Pod 를 만들어보자 ☆

● jenkins-manual-pod.yaml 작성

# gedit jenkins-manual-pod.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: jenkins-manual
spec:
  containers:
  - name: jenkins
    image: jenkins/jenkins
    ports:
    - containerPort: 8080

 

● 파드 생성 및 확인

# 파드 생성
kubectl create -f jenkins-manual-pod.yaml

# 실시간 상태 확인 : -w 옵션
kubectl get pod -w

# exec & curl 옵션으로 확인
kubectl exec jenkins-manual -- curl 127.0.0.1:8080 -s

 

포트포워딩 후 Firefox 웹 브라우저 접속

kubectl port-forward jenkins-manual 8888:8080

접속 성공 ~

》 kubectl logs jenkins-manual 명령어로 admin 암호 확인 가능

 

내용 확인

# yaml 내용 확인
kubectl get pod jenkins-manual -o yaml

# 상세 정보 확인
kubectl describe pod jenkins-manual