LoadBalancer란?
- Public cloud (AWS,Azure, GCP 등)에서 운영 가능
- LoadBalancer를 자동으로 구성 요청
- NodePort를 예약 후 해당 nodeport로 외부 접근 허용
- definition
apiVersion: v1
kind: Service
metadata:
name: loadbalancer-service
spec:
type: LoadBalancer
selector:
app: webui
ports:
- protocol: TCP
port: 80
targetPort: 80
[ Hands - on ]
- LoadBalancer yaml 파일 생성 및 실행
vi loadbalancer-nginx.yaml
apiVersion: v1
kind: Service
metadata:
name: loadbalancer-service
spec:
type: LoadBalancer
selector:
app: webui
ports:
- protocol: TCP
port: 80
targetPort: 80
kubectl create -f vi loadbalancer-nginx.yaml
- LoadBalancer 생성 확인
kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 23m
loadbalancer-service LoadBalancer 10.0.236.121 20.89.37.3 80:31394/TCP 18s
- 외부 loadbalancer IP로 pod 접속 확인
- Internal loadbalancer 생성하기
vi internalloadbalancer-nginx.yaml
apiVersion: v1
kind: Service
metadata:
name: loadbalancer-service
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
type: LoadBalancer
selector:
app: webui
ports:
- protocol: TCP
port: 80
targetPort: 80
kubectl create -f internalloadbalancer-nginx.yaml
- internal LoadBalancer 생성 확인
kubectl get servic
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 98s
loadbalancer-service LoadBalancer 10.0.213.151 <pending> 80:30102/TCP 12
참고 :
https://www.youtube.com/watch?v=WaJyY5KvZj8&list=PLApuRlvrZKohaBHvXAOhUD-RxD0uQ3z0c&index=26
'INFRA > DevOps' 카테고리의 다른 글
Github Action과 AWS CodeDeploy를 활용한 CI/CD (0) | 2022.12.02 |
---|---|
[k8s] ExternalName (0) | 2022.11.28 |
[k8s] NodePort (0) | 2022.11.15 |
[K8s] Cluster IP (0) | 2022.11.09 |
[k8s] Cronjob (0) | 2022.11.01 |
댓글