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

本文详细描述了如何使用GrafanaYAML配置在Kubernetes中创建命名空间、部署和服务,包括设置镜像、节点选择、安全上下文和端口映射。展示了kubectl命令行操作来部署和检查服务状态。

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
一、prometheus简介 Prometheus是一个开源的系统监控和告警系统,现在已经加入到CNCF基金会,成为继k8s之后第二个在CNCF维护管理的项目,在kubernetes容器管理系统中,通常会搭配prometheus进行监控,prometheus支持多种exporter采集数据,还支持通过pushgateway进行数据上报,Prometheus再性能上可支撑上万台规模的集群。 二、prometheus架构图 三、prometheus组件介绍 1.Prometheus Server: 用于收集和存储时间序列数据。 2.Client Library: 客户端库,检测应用程序代码,当Prometheus抓取实例的HTTP端点时,客户端库会将所有跟踪的metrics指标的当前状态发送到prometheus server端。 3.Exporters: prometheus支持多种exporter,通过exporter可以采集metrics数据,然后发送到prometheus server端 4.Alertmanager: 从 Prometheus server 端接收到 alerts 后,会进行去重,分组,并路由到相应的接收方,发出报警,常见的接收方式有:电子邮件,微信,钉钉, slack等。 5.Grafana监控仪表盘 6.pushgateway: 各个目标主机可上报数据到pushgatewy,然后prometheus server统一从pushgateway拉取数据。 四、课程亮点 五、效果图展示 六、讲师简介 先超(lucky):高级运维工程师、资深DevOps工程师,在互联网上市公司拥有多年一线运维经验,主导过亿级pv项目的架构设计和运维工作 主要研究方向: 1.云计算方向:容器kubernetes、docker),虚拟化(kvm、Vmware vSphere),微服务(istio),PaaS(openshift),IaaS(openstack)等2.系统/运维方向:linux系统下的常用组件(nginx,tomcat,elasticsearch,zookeeper,kafka等),DevOps(Jenkins+gitlab+sonarqube+nexus+k8s),CI/CD,监控(zabbix、prometheus、falcon)等 七、课程大纲
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杰哥的技术杂货铺

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值