Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

전공공부

2. Replica & ReplicaSet 제작 본문

Study/K8S

2. Replica & ReplicaSet 제작

monitor 2023. 1. 29. 20:35

1. Replica

- multiple instance 환경에서 권장하며 replica controller가 pod 가용성을 위해서 관리

 

rs-definition.yaml 제작
apiVersion: v1
kind: ReplicaController
metadata:
	name: myapp-rs
    labels:
    	name: myapp
        type: frontend
spec:
	template:
    	metadata:
        	name: myapp
            labels:
            	name:
                type: frontend
        spec:
        	containers:
            	-name: nginx-containers
                image: nginx
	replicas: 3
replicacontroller 확인
kubectl create -f rs-definition.yaml
kubectl get replicacontroller

2. ReplicaSet

 

replicaset-definition.yaml 제작
apiVersion: apps/v1
kind: ReplicaSet
metadata:
	name: myapp-rs
    labels:
    	name: myapp
        type: frontend
spec:
	template:
    Pod 특징 나열 (metadata, spec,...)
   	replica: 3
    selector:
    	matchLabels: #template 내부 나열된 pod를 특정하기 위해서 사용
        	type: frontend
레플리카 셋 제작 및 확인
kubectl create -f replicaset-definition.yaml
kubectl get replicaset #확인

3. Scale up하기

yaml 방식

 

kubectl apply -f <yaml 파일>

 

cli 방식

 

kubectl scale --replicas=6 -f <replica>

'Study > K8S' 카테고리의 다른 글

Service Account  (2) 2023.03.19
Docker Security  (0) 2023.03.19
Secret  (0) 2023.03.03
configMaps  (0) 2023.03.03
1. K8S Pod 설치  (1) 2023.01.29