실습)
릴리스를 통해 그라파나 - 프로메테우스를 구성하고 그라파나 대시보드에 접속해서 잘 되는지 확인
- pro라는 별칭으로 레포 추가
root@master:~# helm repo add pro https://prometheus-community.github.io/helm-charts
root@master:~# helm search repo stack
root@master:~# helm install pro pro/kube-prometheus-stack
root@master:~# kubectl get pod -o wide
- Grafana 접속을 위한 포트포워딩
root@master:~# export POD_NAME=$(kubectl get pod -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=pro" -o jsonpath="{.items[0].metadata.name}")
root@master:~# kubectl port-forward $POD_NAME 3000:3000
1. 외부 PC에서 접속
- 외부 PC에서 SSH 터널 열고 연결
root@worker-1:~# ssh -L 3000:localhost:3000 root@211.183.3.100
2. 웹 브라우저로 Grafana 접속
- NodePort 방식으로 외부 노출
root@master:~# kubectl get svc -n default | grep grafana
root@master:~# kubectl patch svc pro-grafana -n default -p '{"spec": {"type": "NodePort"}}'
root@master:~# kubectl get svc pro-grafana -n default
- 로그인 비번 찾기
root@master:~# kubectl get secret pro-grafana -o jsonpath="{.data.admin-password}" | base64 -d ; echo
- 릴리스 삭제
root@master:~# helm uninstall pro
- password로 검색해봐도 좋은데, 이미 grafana 항목을 살펴봄
- values엔 없었지만 일단 이렇게 서비스 타입을 지정했을때 되는지 확인
helm install gra pro/kube-prometheus-stack --set grafana.service.type=LoadBalancer
헬름 차트 생성
helm create mychart
root@master:~/mani/helm/mychart# vi my-values.yaml
image:
repository: nginx
tag: "1.14"
root@master:~/mychart# helm install myweb ./ -f my-values.yaml
root@master:~/mani/helm/mychart# kubectl get svc
root@master:~/mani/helm/mychart# curl 10.107.244.2
- 파드의 이미지 조회
root@master:~/mani/helm/mychart# kubectl describe pod myweb-mychart-d5b77bd69-xlrbs
- 기존의 my-values.yml을 아예 전혀 다른 이미지로 수정
root@master:~/mani/helm/mychart# vi my-values.yml
image:
repository: 61.254.18.30:5000/ipnginx
tag: "latest"
- 수정된 이미지로 업그레이드
root@master:~/mani/helm/mychart# helm upgrade myweb ./ -f my-values.yml
- myweb 릴리스의 버전 업데이트 내역
root@master:~/mani/helm/mychart# helm history myweb
- 기존 버전으로 돌아간걸 확인 가능
root@master:~/mani/helm/mychart# helm rollback myweb 1
헬름 레포지토리 구성
만든 차트를 웹서버 레포지토리에 push.
- push를 할 웹서버 설치
root@master:~/mani/helm/mychart# apt install -y nginx
- 동작
root@master:~/mani/helm/mychart# systemctl enable --now nginx
root@master:~/mani/helm/mychart# cd ..
root@master:~/mani/helm# pwd
/root/mani/helm
root@master:~/mani/helm# helm package ./mychart
- 생성한 차트를 웹루트디렉토리로 이동
mv mychart-0.1.0.tgz /var/www/html
- 해당 경로를 레포지토리화, 레포지토리화 되면 index.yaml이 생성됨
helm repo index /var/www/html
# 이 레포에 접근하는 사용자는 index.yaml 파일을 보고, 이 디렉토리가 레포지토리라는걸 인식
- 이렇게 하면 웹루트디렉토리 = 헬름 레포지토리
root@master:~/mani/helm# helm repo add myrepo http://211.183.3.100