ํ๋์ ์งํฉ
myweb-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: myweb-rc
spec:
replicas: 3
selector:
app: web
# Pod Configure
template:
metadata:
labels:
app: web
spec:
containers:
- name: myweb
image: ghcr.io/c1t1d0s7/go-myweb
ports:
- containerPort: 8080
protocol: TCP
$ kubectl create -f myweb-rc.yaml
$ watch kubectl get rc,pods --show-labels -o wide
NAME READY STATUS RESTARTS AGE LABELS
pod/myweb-rc-7m4v7 1/1 Running 0 29m app=web
pod/myweb-rc-7s4vp 1/1 Running 0 78m app=web
pod/myweb-rc-jtq7d 1/1 Running 0 78m app=web
$ kubectl label pod myweb-rc-jtq7d app=db --overwrite
$ kubectl label pod myweb-rc-jtq7d app=web --overwrite
๋ช ๋ นํ ์ปค๋งจ๋
$ kubectl scale rc myweb-rc --replicas=5
๋ช ๋ นํ ์ค๋ธ์ ํธ ๊ตฌ์ฑ
$ kubectl replace -f myweb-rc.yaml
$ kubectl patch -f myweb-rc.yaml -p '{"spec": {"replicas": 3}}'
$ kubectl patch rc myweb-rc.yaml --patch-file replicas.json
replicas.json
{"spec": {"replicas": 3}}
$ kubectl edit -f myweb-rc.yaml
$ kubectl edit rc myweb-rc
$ kubectl edit rc/myweb-rc
์ ์ธํ ์ค๋ธ์ ํธ ๊ตฌ์ฑ
$ kubectl apply -f myweb-rc.yaml
ReplicationController -> ReplicaSets
apiVersion: apps/v1
kind: ReplicaSets
metadata:
name: myweb-rs
spec:
replicas: 3
selector:
matchLabels:
app: web
env: dev
template:
metadata:
labels:
app: web
env: dev
spec:
containers:
- name: myweb
image: ghcr.io/c1t1d0s7/go-myweb
ports:
- containerPort: 8080
protocol: TCP
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myweb-rs-set
spec:
replicas: 3
selector:
matchExpressions:
- key: app
operator: In
values:
- web
- key: env
operator: Exists
template:
metadata:
labels:
app: web
env: dev
spec:
containers:
- name: myweb
image: ghcr.io/c1t1d0s7/go-myweb
ports:
- containerPort: 8080
protocol: TCP
$ cd ~/kubespray
ํ๋๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์ข
๋ฃ๋ ๋๊น์ง ๊ณ์ํด์ ํ๋๋ฅผ ์คํํ๋ค
์์ ํ ์ข
๋ฃ๋ฅผ ๋ณด์ฅ