본문 바로가기

Kubernetes(k8s)/MetalLB

MetalLB

1.        MetalLB

 

         1.1.        정의

 

                          Kubernetes 사용 시 AWS, GCP, Azure와 같은 클라우드 플랫폼에서는 자체적으로

 

 

로드 밸런서를 제공해 주지만, 온프레미스 클러스터에서는 로드 밸런싱 기능을

제공하는 모듈을 추가적으로 설치해야 한다. MetalLBBareMetalLoadBalancer

약자로 베어메탈 환경에서 사용할 수 있는 로드 밸런서를 제공하는 오픈소스

프로젝트이다. 클라우드 환경의 서비스(로드밸런서 타입)와는 동작이 조금 다르다.

서비스(로드밸런서)의 External IP 전파를 위해서 표준 프로토콜인

ARP(IPv4)/NDP(IPv6),BGP를 사용한다. 데몬셋으로 speaker 파드를 생성하여

External IP를 전파한다.

         1.2.        설치 방법

 

1)    설정 파일 변경

# k8s의 addon.yml을 수정한다.
[admin1@ubu22-01 ~ (kubernetes-admin@cluster.local:nginx)]$
vi kubespray/inventory/mycluster/group_vars/k8s_cluster/addons.yml
...
# Registry deployment
registry_enabled:
true # true로 바꿔준다.
# registry_namespace: kube-system
# registry_storage_class: ""
# registry_disk_size: "10Gi"

 

2)    변경 사항 적용

[asd@ubu22-01 kubespray (kubernetes-admin@cluster.local:happy)]$ ansible-playbook -i inventory/mycluster/inventory.ini cluster.yml -b

PLAY RECAP **********************************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  
ubu22-01                   : ok=791  changed=16   unreachable=0    failed=0    skipped=1294 rescued=0    ignored=1  
ubu22-02                   : ok=497  changed=4    unreachable=0    failed=0    skipped=758  rescued=0    ignored=1  
ubu22-03                   : ok=497  changed=5    unreachable=0    failed=0    skipped=757  rescued=0    ignored=1  

수요일 16 8월 2023  18:53:48 +0900 (0:00:00.253)       0:14:19.749 ****************
===============================================================================
kubernetes-apps/metallb : Kubernetes Apps | Wait for MetalLB controller to be running ----------------------------------------------------------------------------------------------- 30.38s
container-engine/runc : Download_file | Download item ------------------------------------------------------------------------------------------------------------------------------- 16.18s
container-engine/crictl : Download_file | Download item ----------------------------------------------------------------------------------------------------------
------------------- 15.76s
container-engine/containerd : Download_file | Download item ------------------------------------------------------------------------------------------------------------------------- 15.64s
container-engine/nerdctl : Download_file | Download item ---------------------------------------------------------------------------------------------------------------------------- 15.35s
container-engine/crictl : Extract_file | Unpacking archive -------------------------------------------------------------------------------------------------------------------------- 13.20s
kubernetes-apps/helm : Download_file | Download item -------------------------------------------------------------------------------------------------------------------------------- 13.06s
download : Download_file | Download item -------------------------------------------------------------------------------------------------------------------------------------------- 12.93s
kubernetes/preinstall : Update package management cache (APT) ----------------------------------------------------------------------------------------------------------------------- 12.84s
container-engine/nerdctl : Extract_file | Unpacking archive ------------------------------------------------------------------------------------------------------------------------- 11.15s
container-engine/crictl : Download_file | Validate mirrors -------------------------------------------------------------------------------------------------------------------------- 11.14s
container-engine/runc : Download_file | Validate mirrors ---------------------------------------------------------------------------------------------------------------------------- 11.07s
container-engine/containerd : Download_file | Validate mirrors ---------------------------------------------------------------------------------------------------------------------- 10.84s
container-engine/nerdctl : Download_file | Validate mirrors ------------------------------------------------------------------------------------------------------------------------- 10.83s
kubernetes-apps/helm : Extract_file | Unpacking archive ------------------------------------------------------------------------------------------------------------------------------ 9.90s
kubernetes-apps/ansible : Kubernetes Apps | Start Resources -------------------------------------------------------------------------------------------------------------------------- 6.99s
download : Download_file | Validate mirrors ------------------------------------------------------------------------------------------------------------------------------------------ 6.57s
kubernetes-apps/helm : Download_file | Validate mirrors ------------------------------------------------------------------------------------------------------------------------------ 6.53s
kubernetes-apps/ansible : Kubernetes Apps | Lay Down CoreDNS templates -------------------------------------------------------------------
-------------------------------------------- 6.28s
download : Download | Download files / images ---------------------------------------------------------------------------------------------------------------------------------------- 6.25s

 

 

         1.3.        Troubleshooting

 

1)    proxy 관련 오류가 났을 때

 

# vi kubespray/inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml
---
# configure arp_ignore and arp_announce to avoid answering ARP queries from kube-ipvs0 interface
# must be set to true for MetalLB, kube-vip(ARP enabled) to work
kube_proxy_strict_arp:
true //false인 값을 true로 변경한다.

...