<1> 인그레스
<2> pod 생성해 확인
<1> 인그레스
1
인그레스는 L7 로드 밸런서로 생각하면 되겠다.
HTTP 와 HTTPS 에 대해 서비스 한다.
카나리 업데이트도 가능
마스터 노드에 인그레스 생성, Node Port로 외부 노출
요청에 따른 Path 라우팅
2
로드 밸런서 구성?
사용자 연결 ------- Ingress --- Service ------Pod
// Ingress 앞에 보안장비등이 필요하다.
3
카나리 배포 구성 가능 ?
점진적 배포
10%만 배포 하고, 이상 없으면 나머지 배포를 늘린다.
사용자 연결 ------- Ingress --- Service (90%) ------Pod
Ingress --- Service (10%) ------Pod
4
/customer /order 등 경로에 따라 다른 Pod 연결 가능
5
인그레스 컨트롤러?
NGINX, Kong
6
LB , 카나리 배포, HTTPS 처리함
<2> pod 생성해 확인
// 추가 테스트 필요
// 쿠버네티스 버전 올라가면서 소스 수정 필요.
1
topasvga@cloudshell:~ (ap-seoul-1)$ cat << EOF > svc1-pod.yaml
> apiVersion: apps/v1
> kind: Deployment
> metadata:
> name: deploy1-websrv
> spec:
> replicas: 1 // pod 1개 생성
> selector:
> matchLabels:
> app: websrv
> template:
> metadata:
> labels:
> app: websrv
> spec:
> containers:
> - name: pod-web
> image: nginx
> ---
> apiVersion: v1
> kind: Service
> metadata:
> name: svc1-web
> spec:
> ports:
> - name: web-port
> port: 9001
> targetPort: 80
> selector:
> app: websrv
> type: ClusterIP
> EOF
2
topasvga@cloudshell:~ (ap-seoul-1)$ cat << EOF > svc2-pod.yaml
> apiVersion: apps/v1
> kind: Deployment
> metadata:
> name: deploy2-guestsrv
> spec:
> replicas: 2 // pod 2개 생성
> selector:
> matchLabels:
> app: guestsrv
> template:
> metadata:
> labels:
> app: guestsrv
> spec:
> containers:
> - name: pod-guest
> image: gcr.io/google-samples/kubernetes-bootcamp:v1
> ports:
> - containerPort: 8080
> ---
> apiVersion: v1
> kind: Service
> metadata:
> name: svc2-guest
> spec:
> ports:
> - name: guest-port
> port: 9002
> targetPort: 8080
> selector:
> app: guestsrv
> type: NodePort
> EOF
3
topasvga@cloudshell:~ (ap-seoul-1)$ cat << EOF > svc3-pod.yaml
> apiVersion: apps/v1
> kind: Deployment
> metadata:
> name: deploy3-adminsrv
> spec:
> replicas: 3 // pod 3개 생성
> selector:
> matchLabels:
> app: adminsrv
> template:
> metadata:
> labels:
> app: adminsrv
> spec:
> containers:
> - name: pod-admin
> image: k8s.gcr.io/echoserver:1.5
> ports:
> - containerPort: 8080
> ---
> apiVersion: v1
> kind: Service
> metadata:
> name: svc3-admin
> spec:
> ports:
> - name: admin-port
> port: 9003
> targetPort: 8080
> selector:
> app: adminsrv
> EOF
4
topasvga@cloudshell:~ (ap-seoul-1)$ kubectl get pods,svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 36m <none>
5
얼리어스
topasvga@cloudshell:~ (ap-seoul-1)$ alias k=kubectl
topasvga@cloudshell:~ (ap-seoul-1)$ complete -F __start_kubectl k
6
topasvga@cloudshell:~ (ap-seoul-1)$ k get ns,no,po,svc,deploy,rs,ing,ep
NAME STATUS AGE
namespace/default Active 7d13h
namespace/hello Active 15h
namespace/kube-node-lease Active 7d13h
namespace/kube-public Active 7d13h
namespace/kube-system Active 7d13h
NAME STATUS ROLES AGE VERSION
node/10.0.10.141 Ready node 7d12h v1.25.4
node/10.0.10.80 Ready node 7d12h v1.25.4
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 37m
NAME ENDPOINTS AGE
endpoints/oracle.com-oci <none> 14h
7
topasvga@cloudshell:~ (ap-seoul-1)$ kubectl apply -f svc1-pod.yaml
service/svc1-web created
Error from server (BadRequest): error when creating "svc1-pod.yaml": Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal string into Go struct field DeploymentSpec.spec.replicas of type int32
topasvga@cloudshell:~ (ap-seoul-1)$ kubectl apply -f svc2-pod.yaml
service/svc2-guest created
Error from server (BadRequest): error when creating "svc2-pod.yaml": Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal string into Go struct field DeploymentSpec.spec.replicas of type int32
topasvga@cloudshell:~ (ap-seoul-1)$ kubectl apply -f svc3-pod.yaml
service/svc3-admin created
Error from server (BadRequest): error when creating "svc3-pod.yaml": Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal string into Go struct field DeploymentSpec.spec.replicas of type int32
8
삭제
kubectl delete deploy,svc --all
감사합니다.