【K8S运维知识汇总】第7天5:部署Grafana
文章目录准备基础镜像准备资源配置清单DNS解析应用资源配置清单浏览器验证安装插件k8s-app插件时钟插件 Clock Pannel饼图插件 Pie ChartD3 GaugeDiscrete插件检查插件接入普罗米修斯部分展示准备基础镜像https://hub.docker.com/r/grafana/grafanahttps://github.com/grafana/grafanahttps:/
·
文章目录
准备基础镜像
https://hub.docker.com/r/grafana/grafana
https://github.com/grafana/grafana
https://grafana.com/
[root@k8s7-200.host.com /opt/src]# docker image tag 6f18ddf9e552 harbor.od.com/infra/grafana:v5.4.2
[root@k8s7-200.host.com /opt/src]# docker push harbor.od.com/infra/grafana:v5.4.2
准备资源配置清单
[root@k8s7-200.host.com /data/k8s-yaml/grafana]# cat rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/cluster-service: "true"
name: grafana
rules:
- apiGroups:
- "*"
resources:
- namespaces
- deployments
- pods
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/cluster-service: "true"
name: grafana
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: grafana
subjects:
- kind: User
name: k8s-node
[root@k8s7-200.host.com /data/k8s-yaml/grafana]# cat deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: grafana
name: grafana
name: grafana
namespace: infra
spec:
replicas: 1
selector:
matchLabels:
name: grafana
template:
metadata:
labels:
app: grafana
name: grafana
spec:
containers:
- name: grafana
image: harbor.od.com/infra/grafana:v5.4.2
ports:
- containerPort: 3000
protocol: TCP
volumeMounts:
- mountPath: /var/lib/grafana
name: data
imagePullSecrets:
- name: harbor
securityContext:
runAsUser: 0
volumes:
- nfs:
server: k8s7-200
path: /data/nfs-volume/grafana
name: data
[root@k8s7-200.host.com /data/k8s-yaml/grafana]# cat service.yaml
apiVersion: v1
kind: Service
metadata:
name: grafana
namespace: infra
spec:
ports:
- port: 3000
protocol: TCP
selector:
app: grafana
type: ClusterIP
[root@k8s7-200.host.com /data/k8s-yaml/grafana]# cat ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: grafana
namespace: infra
spec:
rules:
- host: grafana.od.com
http:
paths:
- path: /
backend:
serviceName: grafana
servicePort: 3000
[root@k8s7-200.host.com /data/k8s-yaml/grafana]# mkdir -p /data/nfs-volume/grafana
DNS解析
grafana A 10.4.7.10
应用资源配置清单
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/grafana/rbac.yaml
clusterrole.rbac.authorization.k8s.io/grafana created
clusterrolebinding.rbac.authorization.k8s.io/grafana created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/grafana/deployment.yaml
deployment.apps/grafana created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/grafana/service.yaml
service/grafana created
[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/grafana/ingress.yaml
ingress.extensions/grafana created
浏览器验证
安装插件
k8s-app插件
安装方法一:
grafana-cli plugins install grafana-kubernetes-app
安装方法二:
https://grafana.com/api/plugins/grafana-kubernetes-app/versions/1.0.1/download
[root@hdss7-21 plugins]# wget https://grafana.com/api/plugins/grafana-kubernetes-app/versions/1.0.1/download -O grafana-kubernetes-app.zip
[root@hdss7-200 plugins]# unzip grafana-kubernetes-app.zip
时钟插件 Clock Pannel
grafana-cli plugins install grafana-clock-panel
饼图插件 Pie Chart
grafana-cli plugins install grafana-piechart-panel
D3 Gauge
grafana-cli plugins install briangann-gauge-panel
Discrete插件
grafana-cli plugins install natel-discrete-panel
重启Pod
检查插件
接入普罗米修斯
部分展示
更多推荐
已为社区贡献48条内容
所有评论(0)