星期一, 2月 28, 2022

Kubecost 安裝小記

Kubecost 安裝小記


OS: openSUSE Leap 15.3

Kubenetes:  1.21.9 in  Azure AKS



今天要來實驗 kubecost 這個套件, 因為不管是 VM 還是 Container, 費用管理都是很重要的一門.

不過實驗的起因是這篇 SUSE 的 Blog


從上面看到 kubecost 可以使用 helm 用幾個步驟簡單的安裝, 就想說來試試看 :)


首先安裝 helm 套件


# zypper  search  helm


Loading repository data...

Reading installed packages...


S | Name                    | Summary                          | Type

--+-------------------------+----------------------------------+--------

  | helm                    | The Kubernetes Package Manager   | package



# zypper  install  helm


Loading repository data...

Reading installed packages...

Resolving package dependencies...


The following 2 NEW packages are going to be installed:

  helm helm-bash-completion


2 new packages to install.

Overall download size: 9.7 MiB. Already cached: 0 B. After the operation,

additional 52.3 MiB will be used.

Continue? [y/n/v/...? shows all options] (y): y



接下來安裝  Kubecost


先建立 kubecost 的 namespace

> kubectl  create  namespace  kubecost


namespace/kubecost created


接下來使用 helm 指令新增 repo 與安裝即可


> helm  repo  add  kubecost  https://kubecost.github.io/cost-analyzer/


"kubecost" has been added to your repositories


> helm  install  kubecost  kubecost/cost-analyzer  --namespace  kubecost  --set  kubecostToken="c2FrYW5hQGN5Y3Uub3JnLnR3xm343yadf78"


W0224 22:31:01.468899   15791 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+

W0224 22:31:01.671750   15791 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+

W0224 22:31:13.011883   15791 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+

W0224 22:31:13.011921   15791 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+

NAME: kubecost

LAST DEPLOYED: Thu Feb 24 22:31:00 2022

NAMESPACE: kubecost

STATUS: deployed

REVISION: 1

TEST SUITE: None

NOTES:

--------------------------------------------------Kubecost has been successfully installed. When pods are Ready, you can enable port-forwarding with the following command:

    

    kubectl port-forward --namespace kubecost deployment/kubecost-cost-analyzer 9090

    

Next, navigate to http://localhost:9090 in a web browser.


Having installation issues? View our Troubleshooting Guide at http://docs.kubecost.com/troubleshoot-install



這樣 kubecost 就安裝完成了, 只要 3 步驟

如同提示那樣, 透過 kubectl port-forward 來觀察 kubecost


> kubectl  port-forward  --namespace  kubecost  deployment/kubecost-cost-analyzer  9090


打開瀏覽器的 http://localhost:9090





點選要觀察的 Cluster

首先會出現 Overview 的介面, 但是一開始不會馬上出現資料, 他需要一段時間


放一段時間畫面大概如下



Cost Allocation 的部份可以依照你指定的分類來觀察費用

例如 7 天內按照 Namespace 來觀察



或是按照 Pod 來觀察



有不同的分類方式


Assets 則可以用不同的角度來看花費




Savings 則是最有趣也是最重要的區塊




這邊會根據你的使用量, 提出建議, 例如可以調整 Cluster nodes 的大小來進行節費


Health 的部份則會提出一些點來評估 Cluster 的健康度, 例如有沒有跨多 AZ, 是個不錯的參考



Alerts 還沒去試用, 改天來看看


相關資訊也可以參考官方文件


這邊也有 Azure 的文件


又向 Kubenetes 前進一步


~ enjoy it



Reference


沒有留言: