kube-prometheus-stack による Goアプリケーションの監視
GoアプリのDockerイメージを作成する
docker build -t go-hello-app:v1 ./appKinDでKubernetes環境を構築する
kind create cluster --name <cluster_name>
kind get kubeconfig --name <cluster_name> > kubeconfig.yaml
export KUBECONFIG=./kubeconfig.yaml:~/.kube/configKinDクラスタにDockerイメージをロードする
kind load docker-image go-hello-app:v1 --name <cluster_name>
マニフェストを適用する
kubectl apply -f ./app/deployment.yaml
kubectl apply -f ./app/service.yaml
kubectl apply -f ./app/servicemonitor.yamlhelmfileでkube-prometheus-stackをデプロイする
helmfile syncポートフォワーディングを実行する
./port-fwd.shブラウザでアクセスする
| サービス名 | URL |
|---|---|
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:3000 |
| AlertManager | http://localhost:9093 |