kubectl config set

概要

在 kubeconfig 檔案中設定個別值。

PROPERTY_NAME 是一個以點分隔的名稱,其中每個符記代表一個屬性名稱或一個地圖鍵。地圖鍵不得包含點。

PROPERTY_VALUE 是您想要設定的新值。二進位欄位(例如 'certificate-authority-data')預期是 base64 編碼的字串,除非使用 --set-raw-bytes 旗標。

指定已存在的屬性名稱將會把新欄位合併到現有值之上。

kubectl config set PROPERTY_NAME PROPERTY_VALUE

範例

  # Set the server field on the my-cluster cluster to https://1.2.3.4
  kubectl config set clusters.my-cluster.server https://1.2.3.4
  
  # Set the certificate-authority-data field on the my-cluster cluster
  kubectl config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)
  
  # Set the cluster field in the my-context context to my-cluster
  kubectl config set contexts.my-context.cluster my-cluster
  
  # Set the client-key-data field in the cluster-admin user using --set-raw-bytes option
  kubectl config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true

選項

-h, --help

set 的說明

--set-raw-bytes 三狀態[=true]

當寫入 []byte PROPERTY_VALUE 時,直接寫入給定的字串,而無需 base64 解碼。

--as 字串

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

--as-group 字串

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

--as-uid 字串

要模擬操作的 UID。

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

預設快取目錄

--certificate-authority 字串

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

--client-certificate 字串

TLS 用戶端憑證檔案路徑

--client-key 字串

TLS 用戶端金鑰檔案路徑

--cluster 字串

要使用的 kubeconfig 叢集名稱

--context 字串

要使用的 kubeconfig 環境定義名稱

--default-not-ready-toleration-seconds 整數     預設值:300

指出針對 notReady:NoExecute 容忍度的 tolerationSeconds,預設情況下會將其添加到每個尚未具有此容忍度的 Pod。

--default-unreachable-toleration-seconds 整數     預設值:300

指出針對 unreachable:NoExecute 容忍度的 tolerationSeconds,預設情況下會將其添加到每個尚未具有此容忍度的 Pod。

--disable-compression

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

--insecure-skip-tls-verify

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

--kubeconfig 字串

使用特定的 kubeconfig 檔案

--match-server-version

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

-n, --namespace 字串

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

--password 字串

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

--profile 字串     預設值:"none"

要捕獲的配置檔案名稱。選項之一 (none|cpu|heap|goroutine|threadcreate|block|mutex)。

--profile-output 字串     預設值:"profile.pprof"

要將配置檔案寫入的檔案名稱。

--request-timeout 字串     預設值:"0"

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

-s, --server 字串

Kubernetes API 伺服器的位址和連接埠。

--storage-driver-buffer-duration 持續時間     預設值:1m0s

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

--storage-driver-db 字串     預設值:"cadvisor"

資料庫名稱

--storage-driver-host 字串     預設值:"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 Token

--user string

要使用的 kubeconfig 使用者名稱

--username string

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

--version version[=true]

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

--warnings-as-errors

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

參見

此頁面為自動產生。

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

上次修改時間:2024 年 8 月 19 日下午 5:14 PST:更新 v1.31 的 kubectl 參考文件 (59df28c340)