首页 > 解决方案 > Accessing a service using a LoadBalancer in microk8s

问题描述

When exposing a service in minikube it is possible to see its url via the following:

minikube service [-n NAMESPACE] [--url] NAME

How do you achieve the same in microk8s?

Thank you

标签: kubernetesminikubemicrok8s

解决方案


Realizing this is an older post, but since I just recently implemented a dev install of MicroK8s, I though perhaps I could provide some of my findings.

Wanting a load balancer, I installed MetalLB, https://metallb.universe.tf/, which provides a baremetal LB for a cluster. While MicroK8s does offer an addon for this, I did a manual installation to help myself gain a better understanding.

I used the Layer 2 Configuration option, https://metallb.universe.tf/configuration/#layer-2-configuration which provided a very simple way to expose my services via a load balancer.

To use the config, I then added an annotation to the services that utilize it, indicating which address pool, which for my deployment, I simply call microk8s_pool.

metallb.universe.tf/address-pool: microk8s_pool

推荐阅读