ユーザ用ツール

サイト用ツール


サイドバー

このページの翻訳:



最近の更新



Tag Cloud

06_virtualization:05_container:19_kubernetes_scale

19 Kubernetes Scale

1.nginx用意

my-nginx.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx
spec:
  selector:
    matchLabels:
      run: my-nginx
  replicas: 1
  template:
    metadata:
      labels:
        run: my-nginx
    spec:
      containers:
      - name: my-nginx
        image: nginx
        ports:
        - containerPort: 80

デプロイ

kubectl create -f my-nginx.yaml

確認

# kubectl get deployments.apps my-nginx 
NAME       READY   UP-TO-DATE   AVAILABLE   AGE
my-nginx   1/1     1            1           5m19s

# kubectl get pod -l run=my-nginx
NAME                       READY   STATUS    RESTARTS   AGE
my-nginx-cf54cdbf7-jd8xc   1/1     Running   0          2m23s

スケールを増やす

kubectl scale deployment  my-nginx --replicas=3

確認

Podが3つに増えている

# kubectl get deployments.apps my-nginx 
NAME       READY   UP-TO-DATE   AVAILABLE   AGE
my-nginx   3/3     3            3           6m13s

# kubectl get pod -l run=my-nginx
NAME                       READY   STATUS    RESTARTS   AGE
my-nginx-cf54cdbf7-hgbdl   1/1     Running   0          27s
my-nginx-cf54cdbf7-j5lmk   1/1     Running   0          27s
my-nginx-cf54cdbf7-jd8xc   1/1     Running   0          6m32s

スケールを減らす

kubectl scale deployment  my-nginx --replicas=1

確認

Podが1つに減っている

# kubectl get pod -l run=my-nginx
NAME                       READY   STATUS    RESTARTS   AGE
my-nginx-cf54cdbf7-jd8xc   1/1     Running   0          7m19s

# kubectl get pod -l run=my-nginx
NAME                       READY   STATUS    RESTARTS   AGE
my-nginx-cf54cdbf7-jd8xc   1/1     Running   0          7m39s
06_virtualization/05_container/19_kubernetes_scale.txt · 最終更新: 2022/04/20 17:50 by matsui