kubectl apply edit-last-applied

概要

從預設編輯器編輯資源的最新 last-applied-configuration 註解。

edit-last-applied 命令可讓您直接編輯任何可透過命令列工具擷取的 API 資源。它會開啟由您的 KUBE_EDITOR 或 EDITOR 環境變數定義的編輯器,或回復為 Linux 的 'vi' 或 Windows 的 'notepad'。您可以編輯多個物件,但變更會一次套用一個。此命令接受檔案名稱以及命令列引數,但您指向的檔案必須是先前儲存的資源版本。

預設格式為 YAML。若要以 JSON 編輯,請指定 "-o json"。

--windows-line-endings 旗標可用於強制使用 Windows 行尾,否則將使用您作業系統的預設值。

如果更新時發生錯誤,磁碟上會建立一個暫存檔,其中包含您未套用的變更。更新資源時最常見的錯誤是另一個編輯器變更伺服器上的資源。發生這種情況時,您必須將變更套用至較新版本的資源,或更新您的暫存儲存副本以包含最新的資源版本。

kubectl apply edit-last-applied (RESOURCE/NAME | -f FILENAME)

範例

  # Edit the last-applied-configuration annotations by type/name in YAML
  kubectl apply edit-last-applied deployment/nginx
  
  # Edit the last-applied-configuration annotations by file in JSON
  kubectl apply edit-last-applied -f deploy.yaml -o json

選項

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

如果為 true,則當範本中的欄位或地圖金鑰遺失時,忽略範本中的任何錯誤。僅適用於 golang 和 jsonpath 輸出格式。

--field-manager string     預設值:"kubectl-client-side-apply"

用於追蹤欄位所有權的管理員名稱。

-f, --filename strings

用於編輯資源的檔案、目錄或 URL 檔案名稱

-h, --help

edit-last-applied 的說明

-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 中使用的目錄。當您想要管理在相同目錄中組織的相關資訊清單時很有用。

--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]。

--validate string[="strict"]     預設值:"strict"

必須是以下其中之一:strict (或 true)、warn、ignore (或 false)。 "true" 或 "strict" 將使用結構描述來驗證輸入,如果無效則會使請求失敗。如果 API 伺服器上啟用 ServerSideFieldValidation,它將執行伺服器端驗證,但如果未啟用,則會回復為較不可靠的用戶端驗證。"warn" 將警告未知或重複欄位,而不會封鎖請求 (如果 API 伺服器上啟用伺服器端欄位驗證),否則行為如同 "ignore"。"false" 或 "ignore" 將不會執行任何結構描述驗證,而是靜默捨棄任何未知或重複欄位。

--windows-line-endings

預設為您平台原生的行尾。

--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 環境定義名稱

--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 字串

要使用的 kubeconfig 使用者名稱

--username 字串

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

--version 版本[=true]

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

--warnings-as-errors

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

另請參閱

  • kubectl apply - 透過檔案名稱或標準輸入將組態套用到資源

此頁面為自動產生。

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

上次修改時間為 2024 年 12 月 12 日下午 2:44 PST:更新 v1.32 的 kubectl 參考文件 (5c2cfa02af)