Kubernetes - Deployment
3569 ワード
Deployment - Kubernetes
この文章はクバーネディスの講座を参考に金泰民の大勢を整理したものだ.
ソース:https://www.inflearn.com/course/%EC%BF%A0%EB%B2%84%EB%84%A4%ED%8B%B0%EC%8A%A4-%EA%B8%B0%EC%B4%88/dashboard
🔍 テスト内容
構成の再作成
スクロール更新の設定
Dockerイメージはキム・テミンを使ったイメージです
まず、デプロイメントコントローラの使用方法を見てみましょう.
バージョンをアップグレードするには、さまざまな方法があります.Rolling Updatenと再作成方法を学びましょう.
🚀 Recreate
配置が作成されると、V 1のPodが作成されます.
アップグレード後、まずV 1上のPodを削除し、次にV 2上のPodを順次作成します.
欠点は、まずV 1のPodを削除する必要があり、これによりサービスがDown Timeになる可能性があることです.
今から始めましょう.
dp1.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: dp-1
spec:
selector:
matchLabels:
type: app
replicas: 2
strategy:
type: Recreate
revisionHistoryLimit: 1
template:
metadata:
labels:
type: app
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 10

では、Podと生成されたReplicaSetを見てみましょう.

PodとReplicaSetが作成されていることがわかります.
では、Podに接続するサービスを作成しましょう.
svc1.yaml
apiVersion: v1
kind: Service
metadata:
name: svc-1
spec:
selector:
type: app
ports:
- port: 8080
protocol: TCP
targetPort: 8080


これからやるべきことは、
サービスに接続し、Podのバージョンを無限ループで出力するコマンドを発行しましょう.
次に、無限ループを中心にバージョンを更新しましょう.
while true; do curl 10.109.168.121:8080/version; sleep 1; done

今バージョンを変えましょう
kubectl edit deployment dp-1 -o yaml


このように、サーバは一時的に切断され、バージョンアップが表示されます.
🚀 Rolling Update
アップグレードが実行されると、まずV 2 Podが作成されます.
次に、V 1 Podを削除します.
これは逐次漸進的な過程である.
この方法は導入中にDowntimeがありません!
実習しましょう.
dp2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name dp-2
spec:
selector:
matchLabels:
type: app2
replicas: 2
strategy:
type: RollingUpdate
minReadySeconds: 10
template:
metadata:
labels:
type: app2
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 0

サービスを作成します.
svc2.yaml
apiVersion: v1
kind: Service
metadata:
name: svc-2
spec:
selector:
type: app2
ports:
- port: 8080
protocol: TCP
targetPort: 8080

今、Recreateでやったように同じ練習をしてみましょう.
while true; do curl 10.102.205.50:8080/version; sleep 1; done
kubectl edit deployment dp-2 -o yaml

これにより、V 2の作成が完了し、ダウンロードせずにV 1を順次削除できます.
これで終わりです。🙋🏻♂️
Reference
この問題について(Kubernetes - Deployment), 我々は、より多くの情報をここで見つけました https://velog.io/@sungjin0757/Kubernetes-Deploymentテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol