2
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 5 years have passed since last update.

オフラインのKubenetesにPrometheus/GrafanaをHelmチャートでインストールしたいので必要なファイルを集める

Last updated at Posted at 2019-06-19

オフラインのKubernetesにPrometheus/Grafanaを導入するために、オンライン環境で必要なファイルを集めたメモ。

Minikubeの起動

Minikubeを起動する。

$ minikube start
😄  minikube v1.3.1 on Darwin 10.14.6
🔥  Creating virtualbox VM (CPUs=4, Memory=4096MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.15.2 on Docker 18.09.8 ...
🚜  Pulling images ...
🚀  Launching Kubernetes ...
⌛  Waiting for: apiserver proxy etcd scheduler controller dns
🏄  Done! kubectl is now configured to use "minikube"
$

Tillerをデプロイする。

$ helm init
$HELM_HOME has been configured at /Users/sotoiwa/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
$

チャートの取得

リポジトリーを確認する。

$ helm repo list
NAME      	URL
stable    	https://kubernetes-charts.storage.googleapis.com
local     	http://127.0.0.1:8879/charts
loki      	https://grafana.github.io/loki/charts
iks-charts	https://icr.io/helm/iks-charts
ibm-charts	https://icr.io/helm/ibm-charts
$

リポジトリーを更新。

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "loki" chart repository
...Successfully got an update from the "iks-charts" chart repository
...Successfully got an update from the "ibm-charts" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete.
$

Prometheusのチャートを確認する。

$ helm search prometheus
NAME                                         	CHART VERSION	APP VERSION	DESCRIPTION
ibm-charts/ibm-netcool-piagent-prometheus-dev	0.2.0        	           	Prometheus metrics agent for Predictive Insights
stable/prometheus                            	8.15.1       	2.11.1     	Prometheus is a monitoring system and time series database.
stable/prometheus-adapter                    	1.2.0        	v0.5.0     	A Helm chart for k8s prometheus adapter
stable/prometheus-blackbox-exporter          	1.0.1        	0.14.0     	Prometheus Blackbox Exporter
stable/prometheus-cloudwatch-exporter        	0.4.9        	0.5.0      	A Helm chart for prometheus cloudwatch-exporter
stable/prometheus-consul-exporter            	0.1.4        	0.4.0      	A Helm chart for the Prometheus Consul Exporter
stable/prometheus-couchdb-exporter           	0.1.1        	1.0        	A Helm chart to export the metrics from couchdb in Promet...
stable/prometheus-mongodb-exporter           	2.2.0        	v0.7.0     	A Prometheus exporter for MongoDB metrics
stable/prometheus-mysql-exporter             	0.5.1        	v0.11.0    	A Helm chart for prometheus mysql exporter with cloudsqlp...
stable/prometheus-nats-exporter              	2.2.1        	0.5.0      	A Helm chart for prometheus-nats-exporter
stable/prometheus-node-exporter              	1.6.0        	0.18.0     	A Helm chart for prometheus node-exporter
stable/prometheus-operator                   	6.6.1        	0.31.1     	Provides easy monitoring definitions for Kubernetes servi...
stable/prometheus-postgres-exporter          	0.7.2        	0.5.1      	A Helm chart for prometheus postgres-exporter
stable/prometheus-pushgateway                	1.0.1        	0.9.1      	A Helm chart for prometheus pushgateway
stable/prometheus-rabbitmq-exporter          	0.5.2        	v0.29.0    	Rabbitmq metrics exporter for prometheus
stable/prometheus-redis-exporter             	3.0.1        	1.0.4      	Prometheus exporter for Redis metrics
stable/prometheus-snmp-exporter              	0.0.4        	0.14.0     	Prometheus SNMP Exporter
stable/prometheus-to-sd                      	0.2.0        	0.5.2      	Scrape metrics stored in prometheus format and push them ...
loki/loki                                    	0.13.0       	0.0.1      	Loki: like Prometheus, but for logs.
loki/loki-stack                              	0.15.0       	0.0.1      	Loki: like Prometheus, but for logs.
stable/elasticsearch-exporter                	1.7.0        	1.0.2      	Elasticsearch stats exporter for Prometheus
stable/helm-exporter                         	0.3.1        	0.4.0      	Exports helm release stats to prometheus
stable/karma                                 	1.1.18       	v0.42      	A Helm chart for Karma - an UI for Prometheus Alertmanager
stable/stackdriver-exporter                  	1.1.1        	0.6.0      	Stackdriver exporter for Prometheus
stable/weave-cloud                           	0.3.3        	1.3.0      	Weave Cloud is a add-on to Kubernetes which provides Cont...
stable/kube-state-metrics                    	2.3.0        	1.7.2      	Install kube-state-metrics to generate and expose cluster...
stable/kuberhealthy                          	1.2.6        	v1.0.2     	The official Helm chart for Kuberhealthy.
stable/mariadb                               	6.7.4        	10.3.17    	Fast, reliable, scalable, and easy to use open-source rel...
$

Grafanaのチャートを確認する。

$ helm search grafana
NAME          	CHART VERSION	APP VERSION	DESCRIPTION
stable/grafana	3.8.3        	6.2.5      	The leading tool for querying and visualizing time series...
$

最新のPrometheusとGrafanaのチャートをファイルに保存する。

$ helm fetch stable/prometheus
$ helm fetch stable/grafana
$ ls -l *.tgz
-rw-r--r--  1 sotoiwa  staff  16195  8 16 10:23 grafana-3.8.3.tgz
-rw-r--r--  1 sotoiwa  staff  22489  8 16 10:22 prometheus-8.15.1.tgz
$

イメージの取得

デフォルトのvaluesを取得する。

$ helm inspect values stable/prometheus > prometheus-default-values.yaml
$ helm inspect values stable/grafana > grafana-default-values.yaml
$

普通はこのデフォルト値とチャートのREADMEを参考に、valuesファイル適宜カスタマイズする。今回はデフォルトのまま試用する。

helm templateコマンドでマニフェストを生成し、必要なイメージを確認する。

$ helm template prometheus-8.15.1.tgz -f prometheus-default-values.yaml | grep "image:"
          image: "prom/node-exporter:v0.18.0"
          image: "prom/alertmanager:v0.18.0"
          image: "jimmidyson/configmap-reload:v0.2.2"
          image: "quay.io/coreos/kube-state-metrics:v1.6.0"
          image: "prom/pushgateway:v0.8.0"
          image: "jimmidyson/configmap-reload:v0.2.2"
          image: "prom/prometheus:v2.11.1"
$ helm template -f grafana-default-values.yaml grafana-3.8.3.tgz | grep "image:"
      image: "dduportal/bats:0.4.0"
      image: "dduportal/bats:0.4.0"
          image: "grafana/grafana:6.2.5"
$

これらをpullしてsaveする。

images=$(helm template prometheus-8.15.1.tgz -f prometheus-default-values.yaml | grep "image:" | awk '{print $2}' | awk -F'"' '{print $2}')
for image in $images
do
  tag=${image##*:}
  repo=${image%:*}
  filename=$(echo "${repo}_${tag}.tar.gz" | tr '/' '_')
  echo "repo: $repo"
  echo "tag: $tag"
  echo "filename: $filename"
  docker pull $image
  docker save $image | gzip > $filename
done
images=$(helm template -f grafana-default-values.yaml grafana-3.8.3.tgz | grep "image:" | awk '{print $2}' | awk -F'"' '{print $2}')
for image in $images
do
  tag=${image##*:}
  repo=${image%:*}
  filename=$(echo "${repo}_${tag}.tar.gz" | tr '/' '_')
  echo "repo: $repo"
  echo "tag: $tag"
  echo "filename: $filename"
  docker pull $image
  docker save $image | gzip > $filename
done

保存したファイルを確認。

$ ls -l *.tar.gz
-rw-r--r--  1 sotoiwa  staff  67834060  8 16 10:57 dduportal_bats_0.4.0.tar.gz
-rw-r--r--  1 sotoiwa  staff  90113835  8 16 10:58 grafana_grafana_6.2.5.tar.gz
-rw-r--r--  1 sotoiwa  staff   9641412  8 16 10:56 jimmidyson_configmap-reload_v0.2.2.tar.gz
-rw-r--r--  1 sotoiwa  staff  24853721  8 16 10:56 prom_alertmanager_v0.18.0.tar.gz
-rw-r--r--  1 sotoiwa  staff  10946390  8 16 10:56 prom_node-exporter_v0.18.0.tar.gz
-rw-r--r--  1 sotoiwa  staff  50601034  8 16 10:56 prom_prometheus_v2.11.1.tar.gz
-rw-r--r--  1 sotoiwa  staff   7764275  8 16 10:56 prom_pushgateway_v0.8.0.tar.gz
-rw-r--r--  1 sotoiwa  staff  11985628  8 16 10:56 quay.io_coreos_kube-state-metrics_v1.6.0.tar.gz
$

以上で完了。

参考

2
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
2
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?