1. 系统要求
最小化的软硬件要求
最小化硬件要求
- 磁盘空间: 1 GB
- 内存: 750 MiB (approx 750 MB)
- CPU: 250m (approx 2.5 cores)
2. k8s部署grafana步骤
1) 创建名字空间
kubectl create namespace my-grafana
2) 创建yaml
vim grafana.yaml
yaml包含如下三个资源对象
Object | Description |
---|---|
Persistent Volume Claim (PVC) | 存储声明 |
Service | 提供pod的网络访问 |
Deployment | 负责创建pod,并确保可以滚动更新和管理副本集 |
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:name: grafana-pvc
spec:accessModes:- ReadWriteOnceresources:requests:storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: grafananame: grafana
spec:selector:matchLabels:app: grafanatemplate:metadata:labels:app: grafanaspec:securityContext:fsGroup: 472supplementalGroups:- 0containers:- name: grafanaimage: grafana/grafana:latestimagePullPolicy: IfNotPresentports:- containerPort: 3000name: http-grafanaprotocol: TCPreadinessProbe:failureThreshold: 3httpGet:path: /robots.txtport: 3000scheme: HTTPinitialDelaySeconds: 10periodSeconds: 30successThreshold: 1timeoutSeconds: 2livenessProbe:failureThreshold: 3initialDelaySeconds: 30periodSeconds: 10successThreshold: 1tcpSocket:port: 3000timeoutSeconds: 1resources:requests:cpu: 250mmemory: 750MivolumeMounts:- mountPath: /var/lib/grafananame: grafana-pvvolumes:- name: grafana-pvpersistentVolumeClaim:claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:name: grafana
spec:ports:- port: 3000protocol: TCPtargetPort: http-grafanaselector:app: grafanasessionAffinity: Nonetype: LoadBalancer
3) 执行yaml
这里并没有创建pv,所以要确保有可用的pv使用(至少要有1Gi的pv可用),才可以执行如下的命令
kubectl apply -f grafana.yaml --namespace=my-grafana
4) 查看结果
kubectl get pv,pvc,deployment -n my-grafana
5) 访问grafana
kubectl get svc -n my-grafana
grafana的service采用的是NodePort方式暴露服务,因此可以通过映射的随机端口31483进行访问:
这里k8s部署grafana就算成功了