Exercise 11.1: Service Mesh
CP 노드에 연결된 터미널로 이동
Linkerd 설치
{ curl -sL run.linkerd.io/install | sh export PATH=$PATH:/root/.linkerd2/bin echo "export PATH=$PATH:/root/.linkerd2/bin" >> $HOME/.bashrc linkerd check --pre linkerd install --crds | kubectl apply -f - linkerd install | kubectl apply -f - linkerd check linkerd viz install --set dashboard.enforcedHostRegexp=" " | kubectl apply -f - linkerd check linkerd viz check --wait 1m0s }
Linkerd 대시보드 실행
{ linkerd viz dashboard & }
배포된 web Service를 외부 엑세스가 가능하도록 spec.type 값을 NodePort로 변경
kubectl patch svc web --patch '{"spec":{"type":"NodePort"}}' -n linkerd-viz
NodePort 확인 - 8084 포트에 맵핑된 NodePort
kubectl get svc web -n linkerd-viz
웹브라우저에서 ANY_NODE_IP:SERVICE_NODE_PORT 로 접속 - 아래 명령어로 주소 확인 가능
echo "$(curl -s ifconfig.io):$(kubectl -n linkerd-viz get svc web -o=jsonpath='{.spec.ports[?(@.port==8084)].nodePort}')"
데모 애플리케이션 배포
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Namespace metadata: name: accounting --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx-one labels: app: nginx-one namespace: accounting spec: selector: matchLabels: app: nginx-one replicas: 1 template: metadata: labels: app: nginx-one spec: containers: - image: nginx:1.20.1 name: nginx ports: - containerPort: 80 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: nginx-one namespace: accounting spec: type: NodePort selector: app: nginx-one ports: - port: 80 EOF
Linkerd 대시보드에 위에서 배포한 애플리케이션이 추가 되었는지 확인
배포된 Deployment에 Linkered 프록시 추가
kubectl -n accounting get deploy nginx-one -o yaml | \ linkerd inject - | kubectl apply -f -
배포된 Pod에 어떤 사항이 변경되었는지 확인
kubectl get pod -n accounting
Linkerd 대시보드에서 어떤 사항이 변경되었는지 확인
생성된 Service의 Cluster IP 주소 확인
kubectl get svc nginx-one -n accounting
생성된 Service로 트래픽 생성
watch -n 0.1 curl SERVICE_CLUSTER_IP
OR
watch -n 0.1 curl \ $(kubectl get svc nginx-one -o=jsonpath='{.spec.clusterIP}' -n accounting)
Linkerd 대시보드에서 해당 Service에 연결된 Deployment나 Pod의 지표 확인
Deployment의 Replicas 갯수를 5개로 조정
kubectl -n accounting scale deploy nginx-one --replicas=5
Service로 트래픽 생성
watch -n 0.1 curl SERVICE_CLUSTER_IP
OR
watch -n 0.1 curl \ $(kubectl get svc nginx-one -o=jsonpath='{.spec.clusterIP}' -n accounting)
Linkerd 대시보드에서 해당 Service에 연결된 Deployment나 Pod의 지표 확인
생성된 데모 어플리케이션 삭제 - Namespace를 삭제하면 해당 Namespace에 포함된 모든 리소스가 삭제됨
kubectl delete ns accounting
Last updated