k8s 部署 grafana

创建namespace

grafana-namespace.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: ns-grafana

拉取镜像

swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/rancher/mirrored-grafana-grafana:10.3.3

grafana的Deployment

grafana-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana
  namespace: ns-grafana
spec:
  replicas: 1
  selector:
    matchLabels:
      task: monitoring
      name: grafana
  template:
    metadata:
      labels:
        task: monitoring
        name: grafana
    spec:
      # hostNetwork: true
      containers:
      - name: grafana
        image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/rancher/mirrored-grafana-grafana:10.3.3
        ports:
        - containerPort: 3000
          protocol: TCP

如果使用Service模式部署可以注释hostNetwork: true

grafana的Service

grafana-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: monitoring-grafana
  name: grafana-service
  namespace: ns-grafana
spec:
  ports:
  - port: 80
    targetPort: 3000
    nodePort: 31880
    protocol: TCP
  selector:
    name: grafana
  type: NodePort

启动

kubectl apply -f grafana-namespace.yaml
kubectl apply -f .

查看

kubectl get pod -n ns-grafana
kubectl get svc -n ns-grafana

访问

http://10.0.2.12:31880

10.0.2.12为宿主机ip,31880为Service映射的port。默认登录账号密码 admin / admin

相关推荐
灼烧的疯狂21 分钟前
K8S + Jenkins 做CICD
容器·kubernetes·jenkins
wenyue11211 小时前
Revolutionize Your Kubernetes Experience with Easegress: Kubernetes Gateway API
容器·kubernetes·gateway
Python私教4 小时前
ubuntu搭建k8s环境详细教程
linux·ubuntu·kubernetes
O&REO5 小时前
单机部署kubernetes环境下Overleaf-基于MicroK8s的Overleaf应用部署指南
云原生·容器·kubernetes
politeboy5 小时前
k8s启动springboot容器的时候,显示找不到application.yml文件
java·spring boot·kubernetes
运维小文6 小时前
K8S资源限制之LimitRange
云原生·容器·kubernetes·k8s资源限制
登云时刻6 小时前
Kubernetes集群外连接redis集群和使用redis-shake工具迁移数据(二)
redis·容器·kubernetes
wuxingge15 小时前
k8s1.30.0高可用集群部署
云原生·容器·kubernetes
志凌海纳SmartX16 小时前
趋势洞察|AI 能否带动裸金属 K8s 强势崛起?
云原生·容器·kubernetes
锅总16 小时前
nacos与k8s service健康检查详解
云原生·容器·kubernetes