Kubernetes之kubeadm集群监控篇—grafana 部署

grafana pod文件编写

# cat grafana.yaml 
apiVersion: v1
kind: Namespace
metadata:
  name: kube-prom
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana
  namespace: kube-prom
  labels:
    app: grafana
spec:
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      nodeSelector:
        disktype: ssd
      restartPolicy: Always
      containers:
      - image: registry.cn-beijing.aliyuncs.com/mayaping/grafana:7.2.1
        imagePullPolicy: IfNotPresent
        name: grafana
        ports:
        - containerPort: 3000
          protocol: TCP
          name: http
        readinessProbe:
          tcpSocket:
            port: 3000
          initialDelaySeconds: 5
          periodSeconds: 5
          timeoutSeconds: 1
          failureThreshold: 35
        securityContext:
          privileged: true
          runAsUser: 0
        volumeMounts:
        - name: data
          mountPath: /var/lib/grafana
        - name: config
          mountPath: /etc/grafana/grafana.ini
      volumes:
      - name: data
        hostPath:
          path: /opt/data/grafana
      - name: config
        hostPath:
          path: /opt/data/grafana/grafana.ini
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: grafana
  name: grafana
  namespace: kube-prom
spec:
  ports:
  - name: http
    port: 3000
    targetPort: 3000
    nodePort: 3000
    protocol: TCP
  type: NodePort
  selector:
    app: grafana

部署

# kubectl apply -f grafana.yaml 
namespace/kube-prom unchanged
deployment.apps/grafana created
service/grafana created

查看服务启动情况

# kubectl get pod  --namespace kube-prom 
NAME                                  READY   STATUS    RESTARTS   AGE
grafana-65b7894f98-trl4p              1/1     Running   0          10m
kube-state-metrics-765d5d646c-wnlhx   1/1     Running   0          25m
node-exporter-c4r24                   1/1     Running   0          25m
node-exporter-hlgrp                   1/1     Running   0          25m
node-exporter-pj52m                   1/1     Running   0          25m
prometheus-7749bcdfd8-8zp85           1/1     Running   0          26m

你可能感兴趣的:(Kubernetes,kubernetes,grafana,容器)