k8s 通过heml安装loki
通过heml去部署Loki,要先安装heml:
1
2
3
4
5
6
7
8
|
wget https: //get .helm.sh /helm-v2 .16.9-linux-amd64. tar .gz tar -xf helm-v2.16.9-linux-amd64. tar .gz -C /usr/local/ mv linux-amd64/ helm cat > /etc/profile .d /helm .sh <<EOF export PATH=$PATH: /usr/local/helm EOF source /etc/profile .d /helm .sh |
为tiller赋予权限:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
cat > helm-rbac.yaml <<EOF apiVersion: v1 kind: ServiceAccount metadata: name: tiller namespace: kube-system --- apiVersion: rbac.authorization.k8s.io /v1 kind: ClusterRoleBinding metadata: name: tiller roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: tiller namespace: kube-system EOF kubectl apply -f helm-rbac.yaml |
初始化tiller:
1
|
helm init --service-account tiller |
查看版本:
1
2
3
|
$ helm version Client: &version.Version{SemVer: "v2.16.9" , GitCommit: "8ad7037828e5a0fca1009dabe290130da6368e39" , GitTreeState: "clean" } Server: &version.Version{SemVer: "v2.16.3" , GitCommit: "1ee0254c86d4ed6887327dabed7aa7da29d7eb0d" , GitTreeState: "clean" } |
安装Loki:
先测试heml源:
1
|
helm search |
添加Loki源:
1
|
helm repo add loki https: //grafana .github.io /loki/charts |
查找Loki:
1
2
3
4
5
6
|
$ helm search loki NAME CHART VERSION APP VERSION DESCRIPTION loki /loki 0.30.1 v1.5.0 Loki: like Prometheus, but for logs. loki /loki-stack 0.38.1 v1.5.0 Loki: like Prometheus, but for logs. loki /fluent-bit 0.1.4 v1.5.0 Uses fluent-bit Loki go plugin for gathering logs and sen... loki /promtail 0.23.2 v1.5.0 Responsible for gathering logs and sending them to Loki |
安装:选择 loki/loki-stack 这个包,安装了就全都有了包括Loki和promtail
1
|
helm upgrade -- install loki loki /loki-stack --namespace monitoring |
在grafana中添加数据源:
Configuration->Data Source:选择Loki后在URL中填写k8s的dns解析地址或NodePort方式都可以。
1
|
http: //loki :3100 |
在左侧栏Explore中可查询日志等操作。
完