// rollout 상태 체크
kubectl rollout status deployment/deployment명
// rollout history 체크
kubectl rollout history deployment/deployment명
(1) Recreate
(2) Rolling Update
// rolling update & roll back 체크
kubectl get replicasets
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-rs
labels:
app: myapp
tier: frontend
spec:
template:
metadata:
name: nginx
labels:
app: myapp
tier: frontend
spec:
containers:
- name: nginx-container
image: nginx:1.7.1 // 버전 변경
replicas: 3
selector:
matchLabels:
type: frontend
kubectl edit deployment deployment명
or
kubectl apply -f deployment.yaml
// 아래 커맨드 실행 시, defenition file에 자동 적용 안되므로 반영해줘야 한다.
kubectl set image deployment/deployment명 nginx=nginx:1.7.1
(3) Rollback
kubectl rollout updo deployment/deployment명
POD defenition file에 ENTRYPOINT & CMD 적용
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-3
spec:
containers:
- name: ubuntu
image: ubuntu
command:
- "sleep"
- "1200"
(1) Create ConfigMap
Imperative : defintion file 사용 x
kubectl create configmap <config-name> --from-literal=<key>=<value>
ex) kubectl create configmap app-config --from-literal=App_COLOR=blue
kubectl create configmap <config-name> --from-file=<path-to-file>
ex) kubectl create configmap app-config --from-file=app_config.properties
Declarative : defintion file 사용
confg-map.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
APP_COLOR: blue
APP_MORE: prod
kubectl create -f config-map.yaml
POD Definition File 적용
pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-3
spec:
containers:
- name: ubuntu
image: ubuntu
- envFrom:
- configMapRef:
name: app-config
kubectl get configmaps
kubectl describe configmaps
POD Definition File ENV 변경
// 실행중인 POD에 대한 yaml 파일 생성
kubectl get pod POD명 -o yaml > 파일명.yaml
kubectl delete pod 기존POD명
// 변경 후 실행
kubectl create -f 파일명.yaml
Imperative
kubectl create secret generic <secret-name> --from-literal=<key>=<value>
ex) kubectl create secret generic app-secret --from-literal=DB_Host=mysql
kubetl create secret generic <secret-name> --from-file=<path-to-file>
Declarative
secret-map.yaml
apiVersion: v1
kind: Secret
metadata:
name: app-secret
data:
DB_Host: mysql
DB_User: root
DB_Password: password
kubectl get secrets
kubectl describe secrets
pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-3
spec:
containers:
- name: ubuntu
image: ubuntu
envFrom:
- secretRef:
name: app-secret
mutlipod.yaml
apiVersion: v1
kind: Pod
metadata:
name: simple-webapp
spec:
containers:
- name: simple-webapp
image: simple-webapp
- name: log-agent
image: log-agent
// 특정 네임스페이스의 POD yaml 파일 생성
kubectl -n 네임스페이스명 get pod POD명 -o yaml > app.yaml