.
├── README.md
├── cloud-integration.json -> OCI Integration OpenCost用設定ファイル
└── local.yaml -> OpenCostイントール時パラメーター
- 環境はOCI Kubernetes Engineを利用
- OCIリソースの認可はAPIキー利用
- 事前にAPIキーを取得しておくこと
- helm3系をインストールしておくこと
OKEのプロビジョニングはこちらを参考に実施してください。 Worker NodeのスペックはVM.Standard.E5.Flexシェイプで2oCPU、16GB RAM × 3 Nodeで作成してください。
$ helm install prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \
--namespace prometheus-system --create-namespace \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \
-f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml
$ helm repo add grafana https://grafana.github.io/helm-charts
$ helm install my-grafana grafana/grafana --namespace monitoring
$ kubectl create namespace opencost
cloud-integration.json
の中身を環境に合わせ修正
{
"oci": {
"usageApi": [
{
"tenancyID": "<テナンシOICD>",
"region": "<ホームリージョン>",
"authorizer": {
"authorizerType": "OCIRawConfigProvider",
"tenancyID": "<テナンシOICD>",
"userID": "<ユーザOCID>",
"region": "<ホームリージョン>",
"fingerprint": "<APIキーのフィンガープリント>",
"privateKey": "<APIキーの秘密鍵>"
}
}
]
}
}
サンプル
{
"oci": {
"usageApi": [
{
"tenancyID": "ocid1.tenancy.oc1..aaaaaaaa3mb7xxxxxxxxxxxxxxxxxxxzitpdaymbuazc5tkguca",
"region": "us-ashburn-1",
"authorizer": {
"authorizerType": "OCIRawConfigProvider",
"tenancyID": "ocid1.tenancy.oc1..aaaaxxxxxxxxxxxxxxx4mczxxxxxxxxxxxxxxxc5tkguca",
"userID": "ocid1.user.oc1..aaaaaaaxxxxxxxxxxxxxxxhvpmxxxxxxxxxxxxxxxn47jeeyra",
"region": "us-ashburn-1",
"fingerprint": "71:01:81:7e:10:d6:30:4c:d1:db:06:d1:50:70:bb:03",
"privateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqbledDSq+DGwEggk9xxxxxxxxxxxxxxx3RAEtTkt14\nX1HytGI6pWT/HXdMob9RC+w=\n-----END PRIVATE KEY-----"
}
}
]
}
}
Kubernetesに登録
kubectl create secret generic cloud-costs --from-file=./cloud-integration.json --namespace opencost
$ helm upgrade opencost --repo https://opencost.github.io/opencost-helm-chart opencost \
--namespace opencost -f local.yaml
$ kubectl get deploy,svc -A
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/coredns 3/3 3 3 15d
kube-system deployment.apps/kube-dns-autoscaler 1/1 1 1 15d
monitoring deployment.apps/my-grafana 1/1 1 1 2d22h
opencost deployment.apps/opencost 1/1 1 1 13d
prometheus-system deployment.apps/prometheus-kube-state-metrics 1/1 1 1 15d
prometheus-system deployment.apps/prometheus-server 1/1 1 1 15d
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP,12250/TCP 15d
kube-system service/kube-dns ClusterIP 10.96.5.5 <none> 53/UDP,53/TCP,9153/TCP 15d
monitoring service/my-grafana ClusterIP 10.96.4.232 <none> 80/TCP 2d22h
opencost service/opencost ClusterIP 10.96.118.102 <none> 9003/TCP,9090/TCP 13d
prometheus-system service/prometheus-kube-state-metrics ClusterIP 10.96.171.253 <none> 8080/TCP 15d
prometheus-system service/prometheus-prometheus-node-exporter ClusterIP 10.96.127.106 <none> 9100/TCP 15d
prometheus-system service/prometheus-server ClusterIP 10.96.209.234 <none> 80/TCP 15d
$ kubectl port-forward --namespace opencost service/opencost 9003 9090
http://localhost:9090/
へのアクセス
Cloud CostsはUIで確認できるまで少し時間がかかる場合があります。
$ kubectl get secret --namespace monitoring my-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
458JaxxxxxxxxxxxxxewYSeUTqg
kubectl port-forward svc/my-grafana 8080:80 -n monitoring
http://localhost:8080/
へのアクセス
Connections
-> Add new connection
Prometheusをデータソースをクリック
以下のように入力
- Name:
prometheus
- Connection:
http://prometheus-server.prometheus-system
あとはデフォルトのまま、一番下のSave & test
をクリック
以下が表示されればOK
Dashboards
-> New
-> Import
をクリック
以下のように入力し、Load
をクリック
以下のように入力し、Import
をクリック
Dashboardが表示される