1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Kubernetes Deploymentの起動をオンオフにする方法

Posted at

Kubernetesでは、kubectlコマンドを使ってデプロイメントのレプリカ数を変更することで、Podの起動をオンオフにできる。

前提条件

Kubernetesクラスターにアクセスできること

手順

1. デプロイメントの名前を確認

まず、対象のデプロイメント名を確認する。以下のコマンドで、クラスター内のデプロイメントを一覧表示できる。

kubectl get deployments

例として、デプロイメント名が example-deployment だと仮定する。

2. デプロイメントのPodを停止(オフ)する

デプロイメントをオフにするには、レプリカ数を 0 にスケールダウンする。これで、デプロイメントに関連する全てのPodが停止する。

kubectl scale deployment example-deployment --replicas=0

3. デプロイメントのPodを再起動(オン)する

デプロイメントを再びオンにするには、レプリカ数を必要な数にスケールアップする。例えば、3つのPodを再起動する場合は以下のコマンドを実行する。

kubectl scale deployment example-deployment --replicas=3

まとめ

kubectl scale コマンドを使うことで、デプロイメントのPodの数を簡単に変更できる。これにより、デプロイメントの起動をオンオフすることが可能になる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?