티스토리 뷰

Cloud/Cloud Native

Metallb on Minikube

jacobbaek Jacob_baek 2020. 10. 27. 17:12

Minikube 상에서 손쉽게 MetalLB를 사용하는 방법에 대하여 알아보도록 하자.
(사실 addons enable 만 하면 되기 때문에 큰 어려움은 없다.)

가정

jacob@jacob-laptop:~$ minikube version
minikube version: v1.14.1
commit: b0389943568c59c1d5a35f739c02f5127eee6e56
jacob@jacob-laptop:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:20:10Z", > GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.3", GitCommit:"2e7996e3e2712684bc73f0dec0200d64eec7fe40", GitTreeState:"clean", BuildDate:"2020-05-20T12:43:34Z", > GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

How to do

먼저 minikube가 동작된다는 가정하에 아래와 같은 minikube addons list를 확인해보자.

jacob@jacob-laptop:~/workspace$ minikube addons list
|-----------------------------|----------|--------------|
|         ADDON NAME          | PROFILE  |    STATUS    |
|-----------------------------|----------|--------------|
| ambassador                  | minikube | disabled     |
| csi-hostpath-driver         | minikube | disabled     |
| dashboard                   | minikube | disabled     |
| default-storageclass        | minikube | enabled ✅   |
| efk                         | minikube | enabled ✅   |
| freshpod                    | minikube | disabled     |
| gcp-auth                    | minikube | disabled     |
| gvisor                      | minikube | disabled     |
| helm-tiller                 | minikube | enabled ✅   |
| ingress                     | minikube | enabled ✅   |
| ingress-dns                 | minikube | disabled     |
| istio                       | minikube | disabled     |
| istio-provisioner           | minikube | disabled     |
| kubevirt                    | minikube | disabled     |
| logviewer                   | minikube | disabled     |
| metallb                     | minikube | disabled     |
| metrics-server              | minikube | disabled     |
| nvidia-driver-installer     | minikube | disabled     |
| nvidia-gpu-device-plugin    | minikube | disabled     |
| olm                         | minikube | disabled     |
| pod-security-policy         | minikube | disabled     |
| registry                    | minikube | disabled     |
| registry-aliases            | minikube | disabled     |
| registry-creds              | minikube | disabled     |
| storage-provisioner         | minikube | enabled ✅   |
| storage-provisioner-gluster | minikube | disabled     |
| volumesnapshots             | minikube | disabled     |
|-----------------------------|----------|--------------|

metallb addon이 있는것을 확인할 수 있고 해당 addon은 disable 되어 있는 상황이다.
이와 같은 경우 service type을 NodePort로 생성해서 사용이 가능하다.
하지만 LoadBalancer type을 사용해야 하는 경우가 있으니 metallb를 enable 하여 사용해보자.

아래 명령어로 손쉽게 enable 하자.

jacob@jacob-laptop:~/workspace$ minikube addons enable metallb
🌟  The 'metallb' addon is enabled

아래와 같이 재확인시 metallb가 enable 된것을 확인할수 있다.

jacob@jacob-laptop:~/workspace$ minikube addons list
|-----------------------------|----------|--------------|
|         ADDON NAME          | PROFILE  |    STATUS    |
|-----------------------------|----------|--------------|
| ambassador                  | minikube | disabled     |
| csi-hostpath-driver         | minikube | disabled     |
| dashboard                   | minikube | disabled     |
| default-storageclass        | minikube | enabled ✅   |
| efk                         | minikube | enabled ✅   |
| freshpod                    | minikube | disabled     |
| gcp-auth                    | minikube | disabled     |
| gvisor                      | minikube | disabled     |
| helm-tiller                 | minikube | enabled ✅   |
| ingress                     | minikube | enabled ✅   |
| ingress-dns                 | minikube | disabled     |
| istio                       | minikube | disabled     |
| istio-provisioner           | minikube | disabled     |
| kubevirt                    | minikube | disabled     |
| logviewer                   | minikube | disabled     |
| metallb                     | minikube | enabled ✅   |
| metrics-server              | minikube | disabled     |
| nvidia-driver-installer     | minikube | disabled     |
| nvidia-gpu-device-plugin    | minikube | disabled     |
| olm                         | minikube | disabled     |
| pod-security-policy         | minikube | disabled     |
| registry                    | minikube | disabled     |
| registry-aliases            | minikube | disabled     |
| registry-creds              | minikube | disabled     |
| storage-provisioner         | minikube | enabled ✅   |
| storage-provisioner-gluster | minikube | disabled     |
| volumesnapshots             | minikube | disabled     |
|-----------------------------|----------|--------------|

다음과 같은 resource들이 생성됨을 확인할수 있다.

jacob@jacob-laptop:~$ kubectl get all -n metallb-system
NAME                              READY   STATUS    RESTARTS   AGE
pod/controller-5f98465b6b-nwlvp   1/1     Running   0          13m
pod/speaker-bnjkv                 1/1     Running   0          13m

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                 AGE
daemonset.apps/speaker   1         1         1       1            1           beta.kubernetes.io/os=linux   13m

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/controller   1/1     1            1           13m

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/controller-5f98465b6b   1         1         1       13m

metallb의 모든것이 만들어졌고 사용이 가능하나 어떤 외부 IP를 사용할지를 지정하지 않았다.
이를 지정해보자.

아래와 같은 kubectl edit 명령을 사용하여 앞서 생성된 ConfigMap내에 addresses 항목을 추가해보자.

jacob@jacob-laptop:~/workspace$ kubectl edit cm -n metallb-system
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.100.100-192.168.100.200 ### <===== IP range를 추가
...

저장하고 나오면 이제 부터 kubernetes상에 service의 type을 LoadBalancer로 사용이 가능해진다.

참고사이트

 

 

 

'Cloud > Cloud Native' 카테고리의 다른 글

Hashicorp Waypoint  (0) 2020.10.27
How to use Hashicorp Waypoint  (0) 2020.10.27
Metallb on Minikube  (0) 2020.10.27
starboard  (0) 2020.10.03
Octant  (0) 2020.10.02
nginx ingress with namespace  (0) 2020.08.24
댓글
댓글쓰기 폼
공지사항
최근에 달린 댓글
Total
50,236
Today
17
Yesterday
45
링크
«   2020/11   »
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          
글 보관함