티스토리 뷰
참고: https://istio.io/docs/setup/install/istioctl/
1. Pre-requisite: 사전 준비사항
본 글에서는 1.4.6을 기준으로 설명합니다.
istio 1.5.0이 2020-03-07일 release되었으나, 테스트 결과 제대로 install이 안되기 때문입니다.
1) istio 설치파일 다운로드
- download
$ cd ~
최신 버전은 아래와 같이 다운로드 받습니다.
$ curl -L https://istio.io/downloadIstio | sh -
우리는 1.4.6을 다운로드 할것이므로 아래와 같이 수행합니다.
- https://github.com/istio/istio/tags 을 열고, 1.4.6을 클릭합니다. 설치할 OS에 맞는 링크 주소를 복사합니다.
- wget으로 다운로드하고, 압축을 해제 합니다.
$ wget https://github.com/istio/istio/releases/download/1.4.6/istio-1.4.6-linux.tar.gz
$ tar -xvf istio-1.4.6-linux.tar.gz
$ cd istio-1.4.6
- istio-1.4.6/bin 디렉토리를 PATH에 추가
$ vi ~/.bashrc
맨 아래에 추가 -> export PATH=$PATH:$HOME/istio-1.4.6/bin
저장/닫기하고, 아래 명령으로 shell을 실행합니다.
$ source ~/.bashrc
2) Pod, Service에 대한 요구사항
- 모든 Service Port는 name과 port가 쌍으로 존재해야 함
apiVersion: v1
kind: Service
metadata:
name: users-svc
spec:
selector:
tag: users
type: NodePort
ports:
- name: users-port1
port: 80
targetPort: 8080
- name: users-port2
port: 88
targetPort: 8088
- 모든 Pod는 1개 이상의 Service에 속해 있어야 함
- deployment는 app과 version LABEL을 정의할것을 권고함
apiVersion: apps/v1
kind: Deployment
metadata:
name: products-pod
spec:
...
template:
metadata:
name: products-pod
labels:
app: products
version: 0.0.2
spec:
...
- container는 UID 1337로 실행하면 안됨
- PSP(Pod Security Policy)가 적용되는 경우 Pod는 NET_ADMIN 권한이 필요함. securityContext에 정의해야 함.
단, istio CNI(Container Network Interface) Plugin을 설치한 경우는 필요 없음.
istio CNI plugin 설치 방법은 본 글의 "3. istio CNI plugin설치 및 이용하기'를 참조하세요.
2. istio 설치하기
1) 설치하기
istio설치는 목적별로 구성된 profile을 이용합니다.
profile 리스트는 아래 명령으로 확인할 수 있습니다. 또한 이는 ~/istio-1.4.6/install/kubernetes/operator/profiles에 YAML파일로 정의되어 있습니다.
$ istioctl profile list
각 profile의 설정 내용을 보고 싶으면 profile dump명령을 이용합니다.
$ istioctl profile dump <profile>
각 profile별 차이는 아래 링크를 참조하세요.
https://istio.io/docs/setup/additional-setup/config-profiles/
Installation Configuration Profiles
Describes the built-in Istio installation configuration profiles.
istio.io
먼저 istio-system 이라는 namespace를 생성합니다.
$ kubectl create ns istio-system
설치는 아래와 같이 profile을 지정하여 설치하며, profile 생략시에는 default 프로파일이 적용됩니다.
$ istioctl manifest apply --set profile=demo
deploy될 manifest파일들을 생성하여 설치하려면 아래와 같이 하십시오.
$ istioctl manifest generate --set profile=<profile> > <yaml파일명>
예) demo profile로 설치
$ istioctl manifest generate --set profile=demo > manifest-demo.yaml
$ kubectl apply -f manifest-demo.yaml
설치화면
설치 시작 후 아래 명령으로 pod 생성 모니터링합니다.
$ kubectl get pod -n istio-system -w
또한, kubectl get svc -n istio-system으로 생성된 service를 확인할 수 있습니다.
2) 설치 package chart 변경하기
설치시에 helm chart와 유사한 chart를 이용하여 deploy할 yaml파일을 만들고 그 yaml파일들을 apply합니다.
chart의 경로는 ~/istio-1.4.6/install/kubernetes/operator/charts입니다.
아래와 같이 helm chart와 동일한 구조를 갖고 있습니다.
사용할 chart의 경로를 바꾸려면 아래와 같이 installPackagePath 설정값을 바꾸십시오.
$ istioctl manifest apply --set installPackagePath=~/istio-releases/istio-1.4.6/install/kubernetes/operator/charts
3) 설치 옵션 변경하기
설치시에 ~/istio-1.4.6/install/kubernetes/operator/profiles에 정의되어 있는 YAML파일 내용을 이용합니다.
<profile>.yaml 파일의 내용을 보면 global항목 아래에 제반 옵션들이 정의되어 있습니다. 이를 아래와 같이 2가지 방법으로 재정의할 수 있습니다.
방법1) --set 파라미터 이용
$ istioctl manifest apply --set values.global.mtls.enabled=true --set values.global.controlPlaneSecurityEnabled=true
방법2) 재정의 YAML파일 이용
$ cp ~/istio-1.4.6/install/kubernetes/operator/profiles/default.yaml ./istio-config.yaml
istio-config.yaml을 열고 똑같은 항목은 없애고, 변경되는 항목만 남깁니다.
$ istioctl manifest apply -f ./istio-config.yaml
manifest YAML에서 변경할 수 있는 항목 설명은 아래 공식 사이트를 참조하십시오.
https://istio.io/docs/reference/config/
Configuration
Detailed information on configuration options.
istio.io
3. istio CNI plugin 설치 및 이용 하기
1) istio CNI plugin 설치
설치 시 --set으로 cni관련 옵션 설정을 하면 됩니다.
Managed kubernetes 환경(예: IKS, AKS, GKS 등)에 따라 옵션을 설정하는 방법이 다릅니다. 아래 링크를 참조하세요.
https://istio.io/docs/setup/additional-setup/cni/#hosted-kubernetes-settings
옵션 중 중요한 옵션은 아래와 같습니다. 전체 파라미터: https://istio.io/docs/setup/additional-setup/cni/#helm-chart-parameters
- values.cni.logLevel : CNI 로깅 . panic, fatal, error, warn, info,debug이고 default는 warn임
- values.cni.excludeNamespaces: istio CNI를 사용안할 namespace로 복수로 지정 가능함. default는 istio-system임
- cniBinDir: kubernetes가 사용하는 CNI(예: calico, flannel 등)의 bin 디렉토리 경로. default는 /opt/cni/bin임
- cniConfDir: kubernetes가 사용하는 CNI의 configration디렉토리. default는 /etc/cni/net.d임.
설치할 Managed kubernetes 환경(예: IKS, AKS, GKS 등)에 따라 적절한 옵션을 주어 설치합니다.
참고로 kubeadm을 이용해 설치한 vanilla kubernetes환경에서는 아래와 같이 하면 됩니다.
옵션이 1.4.6과 1.5.0이 조금 다릅니다.
1.4.6은 아래와 같습니다.
$ istioctl manifest apply --set profile=<profile> --set cni.enalbed=true --set cni.components.cni.enabled=true --set values.cni.logLevel=info
예1) istioctl manifest apply --set profile=demo --set cni.enalbed=true --set cni.components.cni.enabled=true --set values.cni.logLevel=info
만약 YAML파일을 만들어서 설치하고 싶으면 아래 예제와 같이 하십시오. profile명은 적절하게 바꾸십시오.
$ istioctl manifest generate --set profile=demo --set cni.enalbed=true --set cni.components.cni.enabled=true --set values.cni.logLevel=info -o install-istio
위와 같이 하면 install-istio/Base디렉토리 밑에 각 compoments디렉토리별로 yaml파일이 생성됩니다. 아래와 같이 실행하여 설치합니다.
$ kubectl apply -f install-istio
* TIP: yaml파일을 물리적으로 생성하지 않고 즉시 설치하려면 아래 예제와 같이 하십시오.
$ istioctl manifest generate --set profile=demo --set cni.enalbed=true --set cni.components.cni.enabled=true --set values.cni.logLevel=info | kubectl apply -f -
1.5.0은 아래와 같습니다.
$ istioctl manifest apply --set profile=<profile> --set components.cni.enabled=true --set values.cni.logLevel=info
예1) istioctl manifest apply --set profile=demo --set components.cni.enabled=true --set values.cni.logLevel=info
만약 YAML파일을 만들어서 설치하고 싶으면 아래 예제와 같이 하십시오. profile명은 적절하게 바꾸십시오.
$ istioctl manifest generate --set profile=demo --set components.cni.enabled=true --set values.cni.logLevel=info -o install-istio
위와 같이 하면 install-istio/Base디렉토리 밑에 각 compoments디렉토리별로 yaml파일이 생성됩니다. 아래와 같이 실행하여 설치합니다.
$ kubectl apply -f install-istio
* TIP: yaml파일을 물리적으로 생성하지 않고 즉시 설치하려면 아래 예제와 같이 하십시오.
$ istioctl manifest generate --set profile=demo --set components.cni.enabled=true --set values.cni.logLevel=info | kubectl apply -f -
* TIP: 옵션을 파일로 만들어서 지정하기
아래 예제와 같이 yaml파일을 만들고 -f <yaml path>로 설치 시 이용할 수 있습니다.
$ istioctl manifest apply --set profile=demo -f <option지정한 yaml 경로>
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
components:
cni:
enabled: true
values:
cni:
excludeNamespaces:
- istio-system
- kube-system
- foo_ns
- bar_ns
logLevel: info
2) istio CNI plugin 이용 하기
istio CNI plugin이 설치되면 service proxing할 때 기본 CNI(calico, flannel) 대신에 istio CNI가 이용됩니다.
istio CNI의 옵션을 변경하려면 deployment yaml의 annotation에 지정하시면 됩니다.
apiVersion: apps/v1
kind: Deployment
metadata:
name: ignored
spec:
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
spec:
containers:
- name: ignored
image: tutum/curl
command: ["/bin/sleep","infinity"]
istio CNI plugin key는 아래 링크를 참조하세요.
https://istio.io/docs/setup/additional-setup/cni/#traffic-redirection-parameters
init container 사용 시 오동작 방지
Pod배포 시 init container를 사용하는 경우에 istio CNI에 의해 잘못 proxying되어 오동작할 수 있습니다.
이때는 annotaion에 아래 key를 추가하여 오동작을 방지할 수 있습니다.
- traffic.sidecar.istio.io/excludeOutboundIPRanges : disable redirecting traffic to any CIDRs the init containers communicate with.
- traffic.sidecar.istio.io/excludeOutboundPorts : disable redirecting traffic to the specific outbound ports the init containers use.
4. Uninstall 하기
설치시에 사용했던 파라미터 그대로 yaml파일을 만들어서 삭제합니다.
$ istioctl manifest generate <parameter> | kubectl delete -f -
예)
$ istio manifest generate | kubectl delete -f -
$ istio manifest generate --set profile=demo | kubectl delete -f -
$ istio manifest generate --set profile=demo --set values.global.mtls.enabled=true --set values.global.controlPlaneSecurityEnabled=true | kubectl delete -f -
'Cloud > istio' 카테고리의 다른 글
05. Traffic Management: 서비스 Routing (0) | 2020.03.10 |
---|---|
04. Getting started (0) | 2020.03.06 |
99. Trouble shooting (0) | 2020.03.03 |
03. istio sidecar injection (0) | 2020.03.03 |
01. istio 란 ? (0) | 2020.02.04 |
- Total
- Today
- Yesterday
- agile
- 버라이어티가격
- micro service
- 도파밍
- 분초사회
- 마이크로서비스
- Event Sourcing
- CQRS
- 리퀴드폴리탄
- 애자일
- 스핀프로젝트
- 디토소비
- 육각형인간
- API Composition
- 마이크로서비스 패턴
- SAGA
- AXON
- 스포티파이
- 호모프롬프트
- spotify
- 돌봄경제
- 요즘남편 없던아빠
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |