Kubernetes - Istio

Doveloper·2022년 6월 2일
1

Kubernetes

목록 보기
9/9
post-thumbnail

2021-09-16 Kubernetes Istio study


Summary

  • 연구실 server - master에 Istio 설치

  • Istio sample app, service 배포

  • Istio dashboard 관찰


Istio 는 Application network 기능을 유연하고 쉽게 자동화 할 수 있는 networking layer의 service mesh 이다. 서비스 메쉬를 구현할 수 있는 오픈소스.

주요 특징

  • 트래픽 관리
  • 보안
  • 모니터링

Istio 설치

Istio download
curl -L https://istio.io/downloadIstio | sh -

Move to Istio package dir, path 추가

cd istio-1.11.2
export PATH=$PWD/bin:$PATH

Istio Install
istioctl install --set profile=demo -y 여기서 demo profile 외에 다른 profile도 존재.
default값으로 무난하게 setting된 것이 demo profile

여기까지 하면,

다음과 같이 pod가 생성됨.

이와같이 svc가 생성.

kubectl label namespace default istio-injection=enabled 로 default namespace를 istio enable 설정

sample app 배포

kubectl apply -f istio-1.11.2/samples/bookinfo/platform/kube/bookinfo.yaml 로 sample app 배포.

정상 동작하는지 확인. http request를 보내어 tilte을 읽어옴. Simple Bookstore라고 떠야 정상.
kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"

Application을 외부 traffic으로 열기.

kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml

gateway와 virtualservice 가 생성됨. (kubernetes object)

ingress IP와 Port 설정하기

istioctl analyze로 특이사항 없는지 한 번 확인하고, kubectl get svc istio-ingressgateway -n istio-system 으로 istio-ingressgateway를 확인한다. External-IP 가 존재하는지, none인지, pending인지에 따라 설정하는 방법이 상이하다.

https://istio.io/latest/docs/setup/getting-started/ 참고하여 설정한다.

현재 환경에서는 ExternalIP가 pending이므로 (none일때도 마찬가지.) 외부 load balancer 가 따로 없는 상태이다. 따라서 다음과 같이 설정한다.

export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].status.hostIP}')

$INGRESS_HOSTINGRESS_PORT을 echo로 확인하여 잘 뜨는지 확인.
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT로 GATEWAY_URL을 설정하고 echo로 확인해본다.

확인 -- echo "http://$GATEWAY_URL/productpage"

대시보드 생성

kubectl apply -f samples/addons 명령을 치면 jaeger, Kiali 대시보드와 istio-prometheus 등 여러가지가 생성된다.

kubectl rollout status deployment/kiali -n istio-system 으로 kiali deployment가 정상 ready 될 때 까지 확인하며 기다린다.

istioctl dashboard kiali 명령으로 dashboard 활성화.

kubectl edit svc/kiali -n istio-system 으로 kiali service에 externalIP를 추가해주고, 해당 IP와 port로 접속. (externalIPs: - masterIP로 해주었음.)

profile
Hungry Developer

0개의 댓글