쿠버네티스 Pod 생성하기

1 개요[ | ]

k8s pod 생성
K8s Pod 배포
쿠버네티스 Pod 생성하기
쿠버네티스 Pod 배포하기

2 방법1: yaml 파일 작성 후 적용[ | ]

testuser@localhost:~$ vi pod-nginx.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
testuser@localhost:~$ kubectl apply -f pod-nginx.yaml
pod/nginx created
testuser@localhost:~$ kubectl get pod nginx
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          10s

3 방법2: yaml 파일 없이 적용[ | ]

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
EOF
testuser@localhost:~$ cat <<EOF | kubectl apply -f -
> apiVersion: v1
> kind: Pod
> metadata:
>   name: nginx
>   labels:
>     name: nginx
> spec:
>   containers:
>   - name: nginx
>     image: nginx
> EOF
pod/nginx created
testuser@localhost:~$ kubectl get pod nginx
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          10s

echo "
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
" | kubectl apply -f -
testuser@localhost:~$ echo "
> apiVersion: v1
> kind: Pod
> metadata:
>   name: nginx
>   labels:
>     name: nginx
> spec:
>   containers:
>   - name: nginx
>     image: nginx
> " | kubectl apply -f -
pod/nginx created

4 뒷정리(Cleanup)[ | ]

testuser@localhost:~$ kubectl delete pod nginx
pod "nginx" deleted

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}