skip to Main Content

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

2

Answers


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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search