퍼블릭 클라우드(AWS나 GCP)의 쿠버네티스는 기본적으로 로드밸런서를 지원하지만
로컬에서 설치한 쿠버네티스는 따로 설치해 주어야 합니다.
https://metallb.universe.tf/installation/
MetalLB, bare metal load-balancer for Kubernetes
Installation Before starting with installation, make sure you meet all the requirements. In particular, you should pay attention to network addon compatibility. If you’re trying to run MetalLB on a cloud platform, you should also look at the cloud compat
metallb.universe.tf
오픈소스 프로젝트인 metal lb를 설치해 줍니다.
kubectl edit configmap -n kube-system kube-proxy
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
[root@master ~]# cat configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.56.100-192.168.56.200
kubectl apply -f configmap.yaml
[root@master ~]# kubectl get all -n metallb-system
[root@master ~]# cat apache_LB.yaml
apiVersion: v1
kind: Service
metadata:
name: myapache-lb
spec:
ports:
- name: myweb-svc
port: 8001
targetPort: 80
selector:
app: nginx
type: LoadBalancer
kubectl apply -f apache_LB.yaml
kubectl get svc
확인해 봅니다.
'CLOUD > CUBE' 카테고리의 다른 글
쿠버네티스(Kubernetes) -볼륨(Volume) (0) | 2021.11.08 |
---|---|
쿠버네티스(Kubernetes) - Cluster IP, Nodeport (0) | 2021.11.08 |
쿠버네티스(Kubernetes) yaml file - replica, deployment (0) | 2021.11.06 |
쿠버네티스(kubernetes) yaml file - namespace, pod, service (0) | 2021.11.06 |
쿠버네티스 설치(Kubernetes install)하면서 발생한 에러 및 해결방법 (0) | 2021.10.30 |