일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- livenessPorbe
- 딥레이서 보상함수
- grafana on kubernetes
- Aurora cluster
- SAA 합격 후기
- LoadBalancer Controller
- jenkins
- 쿠버네티스
- AWS 딥레이서
- Firelens
- 솔데스크
- 메탈LB
- EKS 클러스터
- headless service
- 쿠버네티스 컴포넌트
- 그라파나 대시보드
- 로드밸런서 컨트롤러
- kubernetes 동작 원리
- 그라파나 시각화
- terraform
- blue-green
- github action 사용법
- 깃허브 액션
- helm
- Kubernets on Jenkins
- Kubernetes
- EFS CSI Driver
- Solution Architecture
- Prometheus install
- 딥레이서
mingming
kubernetes controller - ReplicaSet 본문
ReplicaSet
- ReplicationController 와 같은 역할을 하는컨트롤러
- ReplicationController 보다 풍부한 Selctor를지원
selector:
matchLabels:
component: redis
matchExpressions:
- {key: tier, operator: In, values: [cache]}
- {key: environment, operator: NotIn, values: [dev]}
- matchExpression 연산자
In: key와 values를 지정하여 key, value가 일치하는 Pod만 연결
NotIn: key와 일치하고 value는 일치하지 않는 Pod에 연결
Exists: key에 맞는 label의 Pod를 연결
DoesNotExist: key와 다른 label의 Pod를 연결
ReplicationController
spec:
replicas: 3
selector:
app: webui
version: "2.1"
template:
ReplicaSet
spec:
replicas: 3
selector:
matchLabels:
app: webui
matchExressions:
- {key: version, operator: In, value: ["2.1"]}
template:
위 두 개의 yaml파일은 같은 내용을 담고있습니다.
nginx-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-rc
spec:
replicas: 3
selector:
app: webui
template:
metadata:
name: nginx-pod
labels:
app: webui
spec:
containers:
- name: nginx-container
image: nginx:1.14
nginx-rs.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-rs
spec:
replicas: 3
selector:
matchLabels:
app: webui
template:
metadata:
name: nginx-pod
labels:
app: webui
spec:
containers:
- name: nginx-container
image: nginx:1.14
작성한 ReplicaSet.yaml 을 배포해줍니다.
kubectl apply -f nginx-rs.yaml
개수 조절
kubectl scale rs nginx-rs --replicas=2
풍부한 Selector 지원하는 것을 빼면 기본적으로 ReplicationController와 매우 유사합니다.
Pod는 유지하면서 ReplicaSet 만 삭제하기
kubectl delete rs nginx-rs --cascade=false
ReplicaSet은 삭제되었지만 Pod는 여전히 동작중입니다.
EXAMPLE
1. 다음의 조건으로 ReplicaSet을 사용하는 rc-lab.yaml 파일을 생성하고 동작시킵니다.
- labels(name: apache, app:main, rel:stable)를 가지는 httpd:2.2 버전의 Pod를 2개 운영합니다.
rs name: rs-mainui
container: httpd:2.2
rc-lab.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: rs-mainui
spec:
replicas: 2
selector:
matchLabels:
app: main
template:
metadata:
name: http-pod
labels:
name: apache
app: main
rel: stable
spec:
containers:
- name: apache
image: httpd:2.2
2. 동작되는 httpd:2.2 버전의 컨테이너를 1개로 축소하는 명령을 적고 실행하세요
kubectl scale rs rs-mainui --replicas=1
'kubernetes' 카테고리의 다른 글
kubernetes controller - StatefulSet (0) | 2023.09.04 |
---|---|
kubernetes controller - Deployment (1) | 2023.09.04 |
kubernetes controller - Replication Controller (0) | 2023.09.03 |
Vagrant로 kubernetes Cluster 구축하기 (0) | 2023.09.01 |
Kubernetes Pod Resoure 할당하기 (0) | 2023.08.31 |