쿠버네티스를 이용해 컨테이너를 실행하는 방법에는 두 가지가 있다.
1. kubectl run 명령어 사용하기
2. yaml 형식으로 template으로 컨테이너 실행하기
kubectl run 명령어 사용하기
--image: 컨테이너 이미지
--port: 컨테이너가 사용할 포트 지정
kubectl run <deployment_name> --image <image_name> --port=<port>
kubectl run nginx-app --image=nginx:1.14 --port=80
사용자가 kubernetes cluster에 container를 실행하라고 명령하면 지정된 container의 image가 docker hub와 같은 registry에서 가져와 cluster 안에서 실행하는 것이다.
yaml 형식으로 template으로 컨테이너 실행하기
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
labels:
app: webui
spec:
replicas: 3
selector:
matchLabels:
app: webui
template:
metadata:
name: nginx-pod
labels:
app: webui
spec:
containers:
- name: nginx-container
image: nginx:1.14
kubectl apply 명령어를 이용해 배포한다.
kubectl apply -f <yaml_file>
반응형
'Kubernetes' 카테고리의 다른 글
5-2. livenessProbe를 이용해 Self-healing Pod 만들기 (0) | 2022.02.06 |
---|---|
4. kubernetes architecture (0) | 2022.02.06 |
kubeconfig에 대해서 알아보자 (0) | 2022.02.05 |
[ERROR] kubelet.service: Unit entered failed state. (0) | 2022.02.04 |
How to completely uninstall kubernetes & install kubeadm, kubelet, kubectl (0) | 2022.02.03 |