kubectl scale

概要

為 deployment、replica set、replication controller 或 stateful set 設定新的大小。

Scale 也允許使用者為擴展動作指定一個或多個先決條件。

如果指定了 --current-replicas 或 --resource-version,則會在嘗試擴展之前進行驗證,並保證在將擴展傳送到伺服器時,先決條件成立。

kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME)

範例

  # Scale a replica set named 'foo' to 3
  kubectl scale --replicas=3 rs/foo
  
  # Scale a resource identified by type and name specified in "foo.yaml" to 3
  kubectl scale --replicas=3 -f foo.yaml
  
  # If the deployment named mysql's current size is 2, scale mysql to 3
  kubectl scale --current-replicas=2 --replicas=3 deployment/mysql
  
  # Scale multiple replication controllers
  kubectl scale --replicas=5 rc/example1 rc/example2 rc/example3
  
  # Scale stateful set named 'web' to 3
  kubectl scale --replicas=3 statefulset/web

選項

--all

選取指定資源類型命名空間中的所有資源

--allow-missing-template-keys     預設值:true

如果為 true,當範本中缺少欄位或對應金鑰時,忽略範本中的任何錯誤。僅適用於 golang 和 jsonpath 輸出格式。

--current-replicas int     預設值:-1

目前大小的先決條件。要求資源的目前大小與此值相符才能擴展。-1 (預設值) 表示無條件。

--dry-run string[="unchanged"]     預設值:"none"

必須為 "none"、"server" 或 "client"。如果為 client 策略,則僅列印將傳送的物件,而不傳送。如果為 server 策略,則提交伺服器端請求而不持久化資源。

-f, --filename strings

檔案名稱、目錄或 URL,用於識別要設定新大小的資源檔案

-h, --help

scale 的說明

-k, --kustomize string

處理 kustomization 目錄。此旗標不能與 -f 或 -R 一起使用。

-o, --output string

輸出格式。選項包括:(json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file)。

-R, --recursive

以遞迴方式處理 -f、--filename 中使用的目錄。當您想要管理在同一個目錄中組織的相關資訊清單時很有用。

--replicas int

新的所需副本數。必要。

--resource-version string

資源版本的先決條件。要求目前的資源版本與此值相符才能擴展。

-l, --selector string

要篩選的選擇器 (標籤查詢),支援 '='、'==' 和 '!='。(例如 -l key1=value1,key2=value2)。符合的物件必須滿足所有指定的標籤約束。

--show-managed-fields

如果為 true,則在以 JSON 或 YAML 格式列印物件時保留 managedFields。

--template string

範本字串或範本檔案的路徑,在 -o=go-template、-o=go-template-file 時使用。範本格式為 golang 範本 [https://go.dev.org.tw/pkg/text/template/#pkg-overview]。

--timeout duration

在放棄擴展操作之前要等待的時間長度,零表示不等待。任何其他值都應包含對應的時間單位 (例如 1s、2m、3h)。

--as string

要模擬操作的使用者名稱。使用者可以是命名空間中的一般使用者或服務帳戶。

--as-group strings

要模擬操作的群組,可以重複此旗標以指定多個群組。

--as-uid string

要模擬操作的 UID。

--cache-dir string     預設值:"$HOME/.kube/cache"

預設快取目錄

--certificate-authority string

憑證授權單位的憑證檔案路徑

--client-certificate string

TLS 的用戶端憑證檔案路徑

--client-key string

TLS 的用戶端金鑰檔案路徑

--cluster string

要使用的 kubeconfig 叢集名稱

--context string

要使用的 kubeconfig context 名稱

--default-not-ready-toleration-seconds int     預設值:300

指出 tolerationSeconds,用於 notReady:NoExecute 容忍度,預設會新增至每個尚未具有此容忍度的 Pod。

--default-unreachable-toleration-seconds int     預設值:300

指出 tolerationSeconds,用於 unreachable:NoExecute 容忍度,預設會新增至每個尚未具有此容忍度的 Pod。

--disable-compression

如果為 true,則選擇退出伺服器所有請求的回應壓縮

--insecure-skip-tls-verify

如果為 true,則不會檢查伺服器的憑證是否有效。這會使您的 HTTPS 連線不安全

--kubeconfig string

用於 CLI 請求的 kubeconfig 檔案路徑。

--match-server-version

要求伺服器版本必須與用戶端版本相符

-n, --namespace string

如果存在,則為此 CLI 請求的命名空間範圍

--password string

API 伺服器的基本身份驗證密碼

--profile string     預設值: "none"

要擷取的設定檔名稱。選項之一 (none|cpu|heap|goroutine|threadcreate|block|mutex)

--profile-output string     預設值: "profile.pprof"

要將設定檔寫入的檔案名稱

--request-timeout string     預設值: "0"

在放棄單個伺服器請求之前等待的時間長度。非零值應包含對應的時間單位(例如 1s、2m、3h)。值為零表示請求永不逾時。

-s, --server string

Kubernetes API 伺服器的位址和埠

--storage-driver-buffer-duration duration     預設值: 1m0s

儲存驅動程式中的寫入操作將在此期間緩衝,並作為單個交易提交到非記憶體後端

--storage-driver-db string     預設值: "cadvisor"

資料庫名稱

--storage-driver-host string     預設值: "localhost:8086"

資料庫主機:埠

--storage-driver-password string     預設值: "root"

資料庫密碼

--storage-driver-secure

使用安全連線至資料庫

--storage-driver-table string     預設值: "stats"

資料表名稱

--storage-driver-user string     預設值: "root"

資料庫使用者名稱

--tls-server-name string

用於伺服器憑證驗證的伺服器名稱。如果未提供,則使用用於連線伺服器的主機名稱

--token string

用於 API 伺服器身份驗證的 Bearer 權杖

--user string

要使用的 kubeconfig 使用者名稱

--username string

API 伺服器的基本身份驗證使用者名稱

--version version[=true]

--version, --version=raw 列印版本資訊並退出;--version=vX.Y.Z... 設定回報的版本

--warnings-as-errors

將從伺服器收到的警告視為錯誤,並以非零的結束代碼退出

參見

  • kubectl - kubectl 控制 Kubernetes 叢集管理器

此頁面為自動產生。

如果您計劃回報此頁面的問題,請在您的問題描述中提及此頁面為自動產生。修正可能需要在 Kubernetes 專案的其他地方進行。

上次修改時間:2024 年 8 月 19 日下午 5:14 PST:Update kubectl reference for v1.31 (59df28c340)