自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

使用k9s簡化Kubernetes集群的管理!

譯文
云計算
我寫的Kubernetes管理文章通常提到管理集群的kubectl命令。不過最近有人指出k9s項目可以快速地查看和解決Kubernetes中的日常問題。本文介紹了如何入門。

【51CTO.com快譯】我寫的Kubernetes管理文章通常提到管理集群的kubectl命令。不過最近有人指出k9s項目可以快速地查看和解決Kubernetes中的日常問題。本文介紹了如何入門。

可以在Mac、Windows和Linux上進行安裝??梢栽?a >此處針對每款操作系統(tǒng)的說明。完成安裝后繼續(xù)下一步。

我將使用Linux和Minikube,后者是在個人計算機上運行Kubernetes的輕量級方法。按照本教程說明文檔裝它。

設置k9s配置文件

一旦安裝了k9s應用程序,最好從help命令入手。

 

  1. $ k9s help 
  2. K9s is a CLI to view and manage your Kubernetes clusters. 
  3. Usage: 
  4.   k9s [flags] 
  5.   k9s [command] 
  6. Available Commands: 
  7.   help        Help about any command 
  8.   info        Print configuration info 
  9.   version     Print version/build info 
  10. Flags: 
  11.   -A, --all-namespaces                 Launch K9s in all namespaces 
  12.       --as string                      Username to impersonate for the operation 
  13.       --as-group stringArray           Group to impersonate for the operation 
  14.       --certificate-authority string   Path to a cert file for the certificate authority 
  15.       --client-certificate string      Path to a client certificate file for TLS 
  16.       --client-key string              Path to a client key file for TLS 
  17.       --cluster string                 The name of the kubeconfig cluster to use 
  18.   -c, --command string                 Specify the default command to view when the application launches 
  19.       --context string                 The name of the kubeconfig context to use 
  20.       --demo                           Enable demo mode to show keyboard commands 
  21.       --headless                       Turn K9s header off 
  22.   -h, --help                           help for k9s 
  23.       --insecure-skip-tls-verify       If true, the server's caCertFile will not be checked for validity 
  24.       --kubeconfig string              Path to the kubeconfig file to use for CLI requests 
  25.   -l, --logLevel string                Specify a log level (info, warn, debug, error, fatal, panic, trace) (default "info") 
  26.   -n, --namespace string               If present, the namespace scope for this CLI request 
  27.       --readonly                       Disable all commands that modify the cluster 
  28.   -r, --refresh int                    Specify the default refresh rate as an integer (sec) (default 2) 
  29.       --request-timeout string         The length of time to wait before giving up on a single server request 
  30.       --token string                   Bearer token for authentication to the API server 
  31.       --user string                    The name of the kubeconfig user to use 
  32. Use "k9s [command] --help" for more information about a command. 

如你所見,我們可以用k9s配置許多功能。要開始的唯一步驟是編寫一個配置文件。info命令會把我們指向該應用程序查找的方向。

 

  1. $ k9s info 
  2.  ____  __.________ 
  3. |    |/ _/   __   \______ 
  4. |      < \____    /  ___/ 
  5. |    |  \   /    /\___ \ 
  6. |____|__ \ /____//____  > 
  7.         \/            \/ 
  8. Configuration:   /Users/jess/.k9s/config.yml 
  9. Logs:            /var/folders/5l/c1y1gcw97szdywgf9rk1100m0000gn/T/k9s-jess.log 
  10. Screen Dumps:    /var/folders/5l/c1y1gcw97szdywgf9rk1100m0000gn/T/k9s-screens-jess 
  11. 要添加文件,創(chuàng)建目錄(如果之前沒有),然后添加一個。 
  12. $ mkdir -p ~/.k9s/ 
  13. $ touch ~/.k9s/config.yml 

要添加文件,創(chuàng)建目錄(如果之前沒有),然后添加一個。

 

  1. $ mkdir -p ~/.k9s/  
  2. $ touch ~/.k9s/config.yml 

就本文而言,我們將使用來自k9s存儲庫的默認的config.yml推薦。維護者指出,該格式隨時有變,因此我們可以在此(https://github.com/derailed/k9s#k9s-configuration)獲取最新版本。

 

  1. k9s: 
  2.   refreshRate: 2 
  3.   headless: false 
  4.   readOnly: false 
  5.   noIcons: false 
  6.   logger: 
  7.     tail: 200 
  8.     buffer: 500 
  9.     sinceSeconds: 300 
  10.     fullScreenLogs: false 
  11.     textWrap: false 
  12.     showTime: false 
  13.   currentContext: minikube 
  14.   currentCluster: minikube 
  15.   clusters: 
  16.     minikube: 
  17.       namespace: 
  18.         active: "" 
  19.         favorites: 
  20.        - all 
  21.         - kube-system 
  22.         - default 
  23.       view
  24.         active: dp 
  25.   thresholds: 
  26.     cpu: 
  27.       critical: 90 
  28.       warn: 70 
  29.     memory: 
  30.       critical: 90 
  31.       warn: 70 

我們設置k9s以尋找本地minikube配置,于是我要證實minikube已聯(lián)機、隨時可用。

 

  1. $ minikube status 
  2. host: Running 
  3. kubelet: Running 
  4. apiserver: Running 
  5. kubeconfig: Configured 

運行k9s以探究Kubernetes集群

由于配置文件已設定、指向本地集群,我們現(xiàn)在可以運行k9s命令。

  1. $ k9s 

一旦你啟動了k9s,k9s文本型用戶界面(UI)會彈出。沒有命名空間的flag,它會顯示默認命名空間中的pod。


圖1

如果你在有許多pod的環(huán)境中運行,默認視圖可能讓人不知所措。另外,我們可以專注于特定的命名空間。退出該應用程序,運行k9s -n ,其中是現(xiàn)有的命名空間。在下圖中,我運行k9s -n minecraft,它顯示我那個出故障的pod。


圖2

所以一旦k9s啟動起來,你可以迅速處理諸多事務。

可通過快捷鍵來瀏覽操控k9s。我們總是可以使用箭頭鍵和回車鍵選擇所列的項。有幾個另外的通用鍵來查看不同的視圖:

0—顯示所有命名空間中的所有pod。


圖3

d—描述所選擇的pod。


圖4

l—顯示所選擇的pod的日志。


圖5

你可能注意到k9s已設置為使用Vim命令鍵,包括使用J鍵和K鍵上下移動。

快速查看不同的Kubernetes資源

是否需要查看不是pod的資源?輸入冒號(“:”)鍵后有許多快捷方式可用。然后,你可以使用以下命令來瀏覽。

:svc——跳轉(zhuǎn)到服務視圖。


圖6

:deploy——跳轉(zhuǎn)到部署視圖。


圖7

:rb——跳轉(zhuǎn)到角色綁定視圖,面向基于角色的訪問控制(RBAC)管理。


圖8

:namespace——跳回到命名空間視圖。


圖9

:cj——跳轉(zhuǎn)到計劃任務視圖,查看集群中的計劃任務。


圖10

對該應用程序而言最常用的工具是鍵盤;想在任何頁面上向上或向下,使用箭頭鍵。如果需要退出,記得使用Vim鍵綁定。輸入:q,按回車鍵離開。

使用k9s對Kubernetes排除故障的示例

出現(xiàn)問題時,k9s有何幫助?為了舉例說明,我讓幾個pod因配置錯誤而失效。下面你可以看到崩潰的Hello部署。一旦高亮顯示,按d運行describe命令,查看導致故障的原因。


圖11


圖12

略讀事件并不能告訴我們故障的原因。接下來,我按esc鍵,通過高亮顯示pod并輸入來查看日志。


圖13

遺憾的是,日志也沒有提供任何幫助(可能是由于從未正確配置部署),pod不會啟動。

然后我按esc退出,查看刪除pod會不會解決此問題。為此,我高亮顯示pod并使用。k9s在刪除之前提示用戶。


圖14

雖然我確實刪除了pod,但部署資源仍存在,因此新的pod會出現(xiàn)。無論出于何種原因(我們尚不知道),它也會繼續(xù)重啟、崩潰。

我將重復查看日志、描述資源,并使用e快捷方式來編輯運行中的pod來解決問題。在這種特定情況下,出故障的pod未配置成在該環(huán)境下運行。因此,不妨刪除部署以停止我們遇到的崩潰后重新啟動循環(huán)。

我們可以通過輸入:deploy并點擊回車鍵來進入部署。之后,我們高亮顯示,并按刪除。


圖15


圖16

這證明部署不見了!僅需敲幾下鍵即可清理這個出故障的部署。

k9s可靈活定制

因此,該應用程序有大量定制選項,連UI的配色方案都可以定制。以下是你可能感興趣的幾個可編輯選項:

  • 調(diào)整放置config.yml文件的位置
  • 將自定義別名添加到alias.yml文件
  • 在hotkey.yml文件中創(chuàng)建自定義熱鍵
  • 探究可用的插件或自行編寫插件

整個應用程序在YAML文件中加以配置,因此定制對任何Kubernetes管理員來說會很熟悉。

原文標題:Speed up administration of Kubernetes clusters with k9s,作者:Jessica Cherry

【51CTO譯稿,合作站點轉(zhuǎn)載請注明原文譯者和出處為51CTO.com】

責任編輯:未麗燕 來源: 51CTO.com
相關推薦

2024-06-07 09:44:10

K9s工具集群

2020-07-10 09:37:24

KubernetesK9s集群管理

2022-04-15 09:30:00

Kubernetes云計算多云

2024-02-21 07:48:37

KubeSlice云原生Kubernetes

2020-07-08 08:03:37

KubernetesLens集群

2020-03-31 12:50:34

樹莓派K3sKubernetes集

2023-11-02 09:00:00

Kubernetes集群

2023-11-07 08:23:05

2022-09-23 09:28:11

KubeSealKubernetesSecret

2019-09-27 16:32:17

虛擬機LinuxDocker

2023-09-11 14:21:00

2022-08-14 20:48:41

KubernetesArgoCD

2023-03-30 09:17:42

KubesprayKubernetesLinux

2021-02-07 08:00:00

Kubernetes集群云原生

2022-05-24 09:00:00

云計算Kubernetes安全

2020-09-09 07:00:00

Kubernetes集群容器

2020-07-27 18:52:34

Kubernetes集群工具

2022-01-17 11:05:11

CFSSLKubernetesLinux

2021-12-30 07:42:13

Kubernetes集群架構(gòu)

2022-09-05 08:26:29

Kubernetes標簽
點贊
收藏

51CTO技術棧公眾號