K8s可视化监控告警【2】--Grafana部署
1. app部署
apiVersion: v1
kind: ReplicationController
metadata:
name: grafana-core
namespace: kube-system
labels:
monitor: grafana
component: core
spec:
replicas: 1
template:
metadata:
labels:
monitor: grafana
component: core
spec:
tolerations:
- key: node-role.kubernetes.io/master
operation: Equal
effect: NoSchedule
containers:
- image: grafana/grafana:4.2.0
name: grafana-core
imagePullPolicy: IfNotPresent
# env:
resources:
# keep request = limit to keep this container in guaranteed class
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 100m
memory: 100Mi
env:
# The following env variables set up basic auth twith the default admin user and admin password.
- name: GF_AUTH_BASIC_ENABLED
value: "true"
- name: GF_AUTH_ANONYMOUS_ENABLED
value: "false"
# - name: GF_AUTH_ANONYMOUS_ORG_ROLE
# value: Admin
# does not really work, because of template variables in exported dashboards:
# - name: GF_DASHBOARDS_JSON_ENABLED
# value: "true"
readinessProbe:
httpGet:
path: /login
port: 3000
# initialDelaySeconds: 30
# timeoutSeconds: 1
volumeMounts:
- name: grafana-persistent-storage
mountPath: /var
volumes:
- name: grafana-persistent-storage
emptyDir: { }
---
apiVersion: v1
kind: Service
metadata:
name: grafana
namespace: kube-system
labels:
monitor: grafana
component: core
spec:
type: NodePort
ports:
- port: 3000 # 访问服务名即可跳转到对于目标容器端口
protocol: TCP
targetPort: 3000 # 容器开放端口
nodePort: 33000 # 绑定集群节点端口
selector:
monitor: grafana
component: core
访问URL:http://节点IP:33000
2. 添加数据源
3. 添加模板
访问http://节点IP:33000/dashboard/db/kubernetes-cluster-monitoring-via-prometheus?refresh=10s&orgId=1
还没有评论,来说两句吧...