Kubernetes로 Grafana 구성을 해본다.
Imperative
1
2
3
4
5
6
7
| $ kubectl create deployment grafana --image=grafana/grafana --port=3000
$ kubectl get pod -w
$ kubectl expose deployment grafana --type=NodePort --port=80 --target-port=3000
$ kubectl get services -w
$ minikube service grafana
|
1
2
3
| $ kubectl delete service/grafana
$ kubectl delete deployment/grafana
|
Declarative
- K8S가 지향하는 바로 Spec을 보고 다른 Kubelet이 보고 반영
- Docker-compose.yml과 같이 선언하여 사용
1
2
3
4
5
| $ chmod +x grafana_start.sh
$ chmod +x grafana_delete.sh
$ ./grafana_start.sh
$ ./grafana_delete.sh
|
1
2
3
| # grafana_start.sh
kubectl apply -f grafana_deploy.yml
minikube service grafana
|
1
2
| # grafana_delete.sh
kubectl delete -f grafana_deploy.yml
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| # grafana_deploy.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
labels:
app: grafana
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- name: grafana
image: grafana/grafana:latest
ports:
- name: http
containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: grafana
labels:
app: grafana
spec:
type: NodePort
ports:
- name: http
protocol: TCP
port: 80
targetPort: 3000
selector:
app: grafana
|