728x90
Pod yaml 파일형식
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
※ 기본 yaml 파일의 형식은 apiVersion, kind, metadata, spec 노드로 구성된다.
ReplicationController yaml 파일형식
apiVersion: v1
kind: ReplicationController
metadata
name: myapp-rc
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
※ spec 노드 하위에 template 노드에서 복제 대상 pod의 metadata 하위 부분이 그대로 들어가고, replicas 노드에 복제본 수를 명시한다.
Replicaset yaml 파일형식
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end
※ spec 노드 하위에 추가로 selector 노드가 추가된다.
command
kubectl create -f replicaset-definition.yaml
kubectl get replicaset
kubectl delete replicaset myapp-replicaset #복제된 pod도 함께 삭제됨
kubectl edit rs [replicaset name] #복제된 pod 삭제해야 새로 만들어짐
## Scale (1)
vi replicaset-definition.yaml
kubectl replace -f replicaset-definition.yaml
## Scale (2)
kubectl scale --replicas=6 -f replicaset-definition.yaml
## Scale (3)
kubectl scale --replicas=6 [type] [name]
kubectl scale --replicas=6 replicaset myapp-replicaset
728x90
반응형
'데브옵스 > Orchestration' 카테고리의 다른 글
[Kubernetes] 9. Service (0) | 2024.11.05 |
---|---|
[Kubernetes] 8. Deployment (0) | 2024.11.05 |
[Kubernetes] 6. 쿠버네티스 아키텍처와 yaml 파일 (0) | 2024.11.04 |
[Kubernetes] 5. 서비스 배포 및 확인 (0) | 2024.11.04 |
[Kubernetes] 4. 서비스 배포 환경 구성 - HELM, Ingress NGINX, metalLB 설치 (1) | 2024.10.31 |