728x90
<Kubernetes :: 쿠버네티스 클러스터 모니터링 서비스 KubeShark>
- KubeShark: Kubernetes 클러스터를 관리하고 모니터링하기 위한 오픈 소스 도구
- 클러스터의 리소스 사용, 네트워크 트래픽, 로그 등을 모니터링하고 시각화할 수 있는 다양한 기능을 제공
1. KubeShark 서비스 설치
ubuntu@k8s-master:~$ sh <(curl -Ls https://kubeshark.co/install)
2. KubeShark 접속
- ks tap로 접속 가능
ubuntu@k8s-master:~$ ks tap
>> http://127.0.0.1:8899로 접속 가능
- 제작한 가상 서버로 접속해야 함
3. 모니터링할 포드 생성
- mymotto image를 이용해 실습
A. deployment 생성
- 외부에서 mymotto 이미지를 이용해 레플리카 3개 생성하고 yaml 파일로 저장
PS C:\Users\admin\Downloads\k8s-pods> kubectl create deployment mymotto-deploy --image=*****/mymotto:1.0 --port=80 --replicas=3 --dry-run=client -o yaml > ./mymotto-deploy.yaml
<mymotto-deploy.yaml>
- "mymott-deploy"인 Kubernetes Deployment를 정의
- Deployment는 3개의 복제본 생성
- 각 복제본은 "*****/mymotto:1.0" 이미지를 사용하여 80번 포트에서 실행
- "node-role.kubernstes.io/master" 레이블을 가진 마스터 노드에서도 실행될 수 있도록 tolerations를 설정
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: mymotto-deploy
name: mymotto-deploy
spec:
replicas: 3
selector:
matchLabels:
app: mymotto-deploy
template:
metadata:
labels:
app: mymotto-deploy
spec:
containers:
- image: *****/mymotto:1.0
name: mymotto
ports:
- containerPort: 80
tolerations:
- effect: NoSchedule
key: node-role.kubernstes.io/master
# nodeSelector:
# node-role.kubernetes.io/master: ""
B. mymotto-deploy.yaml 적용
PS C:\Users\admin\Downloads\k8s-pods\mymotto> kubectl apply -f mymotto-deploy.yaml
<포드 생성 확인>
PS C:\Users\admin\Downloads\k8s-pods\mymotto> kubectl get deploy,po,svc -o wide | grep mymotto-deploy
C. mymotto 서비스 선언
- NodePort 유형으로 서비스 노출
- 클러스터 내의 모든 노드에서 8005 포트로 액세스
- 외부 IP 주소 192.168.56.101을 사용
PS C:\Users\admin\Downloads\k8s-pods\mymotto> kubectl expose deployment mymotto-deploy --name=mymotto-deploy-svc --port=8005 --target-port=80 --type=NodePort --external-ip=192.168.56.101
service/mymotto-deploy-svc exposed
<192.2168.56.101:8005로 서비스 선언 확인>
4. 모니터링 지정
ubuntu@k8s-master:~$ ks tap -n default "(calico*|mymotto)"
'클라우드 + DevOps > Kubernetes (k8s)' 카테고리의 다른 글
Kubernetes 쿠버네티스 :: 노드 스케줄링 실습 (0) | 2024.04.26 |
---|---|
Kubernetes :: Master 서버와 Node 연결 (0) | 2024.04.25 |
Kubernetes :: 라벨 및 네임스페이스 제작 실습 (0) | 2024.04.23 |
Kubernetes :: 사이드카 컨테이너 sidecar container 제작 실습 (0) | 2024.04.22 |
Kubernetes 쿠버네티스 :: StatefulSet 활용 (0) | 2024.04.22 |