I have configured a Kubernetes kind cluster to run a flask API. The flask App when run locally with flask run produces an IP which is the local machine assigned IP from the local network (192.168.100.19). My Nodemcu which also has an IP of (192.168.100.36) can talk to the Flask API.
However, things are different when I run the Flask app from the kind cluster. The kind nodes are in the network of 192.168.64.1 so my nodes' IPs are in that range. I used metallb to create the IP pools in that range as well so my Flask API is given a Loadbalancer IP of 192.168.63.200 This Flask API IP cannot be communicated with the Nodemcu IP of 192.168.100.36
I know this is all about networking and things. This is what I've tried and and none work
- ExtraPortMappings to bind the running container port to the local machine IP. In some instances, I changed the listenAddress to 0.0.0.0
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: iot-cluster05
nodes:
* role: control-plane
kubeadmConfigPatches:
* |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
* containerPort: 80
hostPort: 80
protocol: TCP
* containerPort: 443
hostPort: 443
protocol: TCP
* containerPort: 5000
hostPort: 5000
protocol: TCP
listenAddress: "192.168.100.19"
- Hardcode the local machine IP as the node-ip
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: iot-cluster01
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30000
hostPort: 80
protocol: TCP
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-ip: "192.168.100.19"
cluster-dns: "192.168.100.1"
- |
kind: ClusterConfiguration
apiServer:
extraArgs:
advertise-address: "192.168.100.19"
bind-address: "0.0.0.0"
controllerManager:
extraArgs:
bind-address: "0.0.0.0"
node-cidr-mask-size: "24"
allocate-node-cidrs: "true"
cluster-cidr: "10.244.0.0/16"
containerdConfigPatches:
- |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
Settings Details
- Metallb version 0.13.7
- Kind v0.18.0
- Docker v23.0.1