본문 바로가기

Cloud-native/Istio

[Istio]Deploy bookinfo sample application to demonstrate various Istio features

💡Environment
Client Version: v1.24.0
Kustomize Version: v4.5.4
Server Version: v1.24.12-eks-ec5523e
Namespace: bookinfo으로 변경 후 진행

Deploy sample application

# inject envoy proxy
kubectl label namespace bookinfo istio-injection=enabled

# apply bookinfo application
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml -n bookinfo

# veryfy deploy
➜ 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>"
<title>Simple Bookstore App</title>
  • kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}’
    • label이 app=ratings인 pod명 가져오기
  • -c ratings
    • kubectl exec 명령어를 실행할때 pod내에 컨테이너가 여러개인 경우 -c option으로 특정 container명을 지정해야 한다.

전체 구성 확인

➜ k get all -n bookinfo
NAME                                  READY   STATUS    RESTARTS   AGE
pod/details-v1-7d4d9d5fcb-pkcvh       2/2     Running   0          13s
pod/productpage-v1-66756cddfd-5t7jx   2/2     Running   0          12s
pod/ratings-v1-85cc46b6d4-mbns4       2/2     Running   0          13s
pod/reviews-v1-777df99c6d-ff46p       2/2     Running   0          13s
pod/reviews-v2-cdd8fb88b-5zd8k        2/2     Running   0          12s
pod/reviews-v3-58b6479b-56snz         2/2     Running   0          12s

NAME                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/details       ClusterIP   172.20.61.230    <none>        9080/TCP   13s
service/productpage   ClusterIP   172.20.196.146   <none>        9080/TCP   12s
service/ratings       ClusterIP   172.20.103.164   <none>        9080/TCP   13s
service/reviews       ClusterIP   172.20.7.203     <none>        9080/TCP   13s

NAME                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/details-v1       1/1     1            1           13s
deployment.apps/productpage-v1   1/1     1            1           12s
deployment.apps/ratings-v1       1/1     1            1           13s
deployment.apps/reviews-v1       1/1     1            1           13s
deployment.apps/reviews-v2       1/1     1            1           13s
deployment.apps/reviews-v3       1/1     1            1           12s

NAME                                        DESIRED   CURRENT   READY   AGE
replicaset.apps/details-v1-7d4d9d5fcb       1         1         1       13s
replicaset.apps/productpage-v1-66756cddfd   1         1         1       12s
replicaset.apps/ratings-v1-85cc46b6d4       1         1         1       13s
replicaset.apps/reviews-v1-777df99c6d       1         1         1       13s
replicaset.apps/reviews-v2-cdd8fb88b        1         1         1       12s
replicaset.apps/reviews-v3-58b6479b         1         1         1       12s

Open the application to outside traffic

➜ k apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
gateway.networking.istio.io/bookinfo-gateway created
virtualservice.networking.istio.io/bookinfo created

# verify
➜ istioctl analyze

✔ No validation issues found when analyzing namespace: bookinfo.
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo
spec:
  hosts:
  - "*"
  gateways:
  - bookinfo-gateway
  http:
  - match:
    - uri:
        exact: /productpage
    - uri:
        prefix: /static
    - uri:
        exact: /login
    - uri:
        exact: /logout
    - uri:
        prefix: /api/v1/products
    route:
    - destination:
        host: productpage
        port:
          number: 9080

Get gateway url and verify external access

➜ k get svc istio-ingressgateway -n istio-system
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP                                                                    PORT(S)                                      AGE
istio-ingressgateway   LoadBalancer   172.20.199.65   af78873b5044d49c7af9087bafb85262-1574793183.ap-northeast-2.elb.amazonaws.com   15021:30871/TCP,80:30569/TCP,443:32132/TCP   4h55m

View the dashboard

# apply addons that include Kiali
kubectl apply -f samples/addons

# Access the Kiali dashboard.
➜ istioctl dashboard kiali


# send request to sample application
for i in $(seq 1 1000); do curl -s -o /dev/null "<http://af78873b5044d49c7af9087bafb85262-1574793183.ap-northeast-2.elb.amazonaws.com/productpage>"; done

https://istio.io/latest/docs/examples/bookinfo/