1

I'm pretty sure I have something misconfigured or missing something.

my home network is 10.11.0.0/16

I setup a kubernetes instance with

sudo kubeadm init --pod-network-cidr=10.166.0.0/16

Then I installed calico with

CALICO_IPV4POOL_CIDR=10.166.32.0/20

Then I setup MetalLB with

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.100.1-192.168.100.254

I used the tutorial at https://kubernetes.io/docs/tasks/access-application-cluster/service-access-application-cluster/ using NodePort and it works fine on the kubernetes machine:

kubectl describe services example-service
Name:                     example-service
Namespace:                default
Labels:                   app.kubernetes.io/name=load-balancer-example
Annotations:              <none>
Selector:                 app.kubernetes.io/name=load-balancer-example
Type:                     NodePort
IP:                       10.110.245.152
Port:                     <unset>  8080/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  30140/TCP
Endpoints:                10.166.32.243:8080,10.166.32.244:8080,10.166.32.245:8080 + 2 more...
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

I can access the pod on the kubernetes machine with

curl http://10.110.245.152:8080
Hello Kubernetes!

How to I enable other machines on my home network to access? When I try this on other machines it just hangs...

curl http://10.110.245.152:8080
phomlish
  • 139
  • 1
  • 2
  • 12

2 Answers2

3

The answer above does solve the issue, but the application still works on the non-common, kubernetes assigned port. I guess the idea is to have kubernetes cluster visible on the single IP and standard ports.

The MetalLb setup can provide bare-metal load balancer, or the 'LoadBalancer' service type, which is not provided by kubernetes by default. Your example above uses 'NodePort' type and in your service configuration, you should be able to replace 'NodePort' with 'LoadBalancer' type. If the configuration is correct, kubectl get service example-service should display both addresses from the internal kube network and the external IP address from MetalLb range you have configured. Something like in the example below:

kube-server:~$ kubectl get service keycloak-db -n keycloak-db 
NAME          TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
keycloak-db   LoadBalancer   10.109.91.158   192.168.1.243   8080:32434/TCP   33d

The other thing I noticed in your example is that the address range assigned in the MetalLb configuration (192.168.100.0/24) does not match your home network (10.11.0.0/16). If you don't have some routing in place, it would be better to reserve some IPs in the home network and use them in the MetalLb.

mnikolic
  • 517
  • 1
  • 3
  • 7
  • Thanks @mnikolic , i am not familiar with metallb. After reading your explanation i want to try it on my bare metal setup :). – confused genius Nov 02 '20 at 05:04
  • thanks @mkikolic. That worked great. I could not find instruction to change the pool in the docs but found some here: https://github.com/metallb/metallb/issues/308 – phomlish Nov 03 '20 at 05:29
2

shouldnt it be curl <kubernetes machine IP >:30140 if you are using NodePort service ?

confused genius
  • 731
  • 6
  • 18
  • Your username 'confused genius' is inaccurate. I recommend 'helpful genius' because your post works. Thanks you! – phomlish Nov 01 '20 at 07:46