0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vSphere with TanzuのWorkload Cluster上にPrometheusを立てる

Posted at

先日のHarborを立てた記事のついでにPrometheusを立てた時のメモ。

こちらによると、’22/10/31時点ではTKG1.6のパッケージを使えば良いことになっているので、リンク先のこちらの手順に従う。

前提条件

以下が前提条件となっている。

  • vSphere7.0u2以上のworkload clusterを構築済み
  • kubectlとtanzu-cli(v1.4以上)をインストール済み
  • Carvelツールが導入済み
  • yqのv4.5以上が導入済み

また、今回はこちらの記事の後に実施した内容となり、kapp-controller、PackageRepository、cert-manager、Contourのインストールは完了済みの状態からスタートした。

Prometheusのインストール

TKG1.6の公式ドキュメントに従う。vSphere with Tanzuのドキュメントには記載がない点は注意。

最初に利用可能なPrometheusのPackageのバージョンを取得する。

tanzu package available list prometheus.tanzu.vmware.com -A
export PROMETHEUS_VER=2.36.2+vmware.1-tkg.1

次にPrometheusの設定を行うために、設定ファイルを抽出する。

tanzu package available get prometheus.tanzu.vmware.com/$PROMETHEUS_VER --generate-default-values-file

抽出した設定ファイル(prometheus-default-values.yaml)に以下のようにstorageClassを設定する。

prometheus:
  pvc:
    storageClassName: xxxxx
alertmanager:
  pvc:
    storageClassName: xxxxx

Ingressも有効にする。最終的な変更箇所は以下のようになった。

@@ -20,7 +20,7 @@
   pvc:
     accessMode: ReadWriteOnce
     storage: 2Gi
-    storageClassName: default
+    storageClassName: xxxxx
   service:
     port: 80
     targetPort: 9093
@@ -28,14 +28,10 @@
 ingress:
   alertmanager_prefix: /alertmanager/
   alertmanagerServicePort: 80
-  enabled: false
+  enabled: true
   prometheus_prefix: /
   prometheusServicePort: 80
-  tlsCertificate:
-    ca.crt: ca
-    tls.crt: crt
-    tls.key: key
-  virtual_host_fqdn: prometheus.system.tanzu
+  virtual_host_fqdn: prometheus.tkg.tanzu
 kube_state_metrics:
   deployment:
     replicas: 1
@@ -694,6 +690,7 @@
   pvc:
     accessMode: ReadWriteOnce
     storage: 150Gi
+    storageClassName: xxxxx
   service:
     port: 80
     targetPort: 9090

コメントを削除し、先頭に'---'を挿入する。('---'がないとpackage install時に上手くファイルを解釈してくれない)

yq -i eval '... comments=""' prometheus-default-values.yaml
sed -i '1i ---' prometheus-default-values.yaml

作成した設定ファイルを使ってPrometheusをインストールする。

export NAMESPACE=my-packages
tanzu package install prometheus \
--package-name prometheus.tanzu.vmware.com \
--version $PROMETHEUS_VER \
--values-file prometheus-default-values.yaml \
--namespace $NAMESPACE
--create-namespace

公式ドキュメントによると、vSphere with Tanzuの場合、インストールのコマンドがFailed to get final advertise address: No private IP address found, and explicit IP not provided.というエラーメッセージとともにエラーで返ることがある模様。当方が検証した際は発生しなかったが、発生する場合はAlertManagerの引数を書き換えるoverlayを当てる必要がある。(詳細はこちら参照)

動作確認

今回はContourを利用しているため、HTTPProxyリソースが作成されている。

$ kubectl get httpproxy -n tanzu-system-monitoring
NAME                   FQDN                   TLS SECRET       STATUS   STATUS DESCRIPTION
prometheus-httpproxy   prometheus.tkg.tanzu   prometheus-tls   valid    Valid HTTPProxy

Contourの場合のEndPointはEnvoyとなる。

$ kubectl get svc -n tanzu-system-ingress envoy
NAME    TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                      AGE
envoy   LoadBalancer   10.102.115.203   10.220.46.101   80:30763/TCP,443:31909/TCP   15h

試しに通信してみると、通信できていることが分かる。

$ curl  -H "Host: prometheus.tkg.tanzu" 10.220.46.101 --head
HTTP/1.1 301 Moved Permanently
location: https://prometheus.tkg.tanzu/
vary: Accept-Encoding
date: Tue, 01 Nov 2022 10:15:37 GMT
server: envoy
transfer-encoding: chunked

DNSサーバにIPとFQDNを登録してブラウザでアクセスすると、以下のようにPrometheusの画面にもアクセス出来る。

1667297832334.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?