I run three VM’s with Ubuntu 22.04 and Kubernetes: v1.26.2
I’ve created a nginx service as follow:
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2023-03-13T12:42:03Z"
labels:
app: nginx
name: nginx
namespace: default
resourceVersion: "6147648"
uid: 586c1b14-bd4f-45c8-913a-edfaa71f1168
spec:
clusterIP: 10.100.238.2
clusterIPs:
- 10.100.238.2
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- nodePort: 32714
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
Now as the thing spins up I see:
n@k8s-control:~$ kubectl describe service nginx
Name: nginx
Namespace: default
Labels: app=nginx
Annotations: <none>
Selector: app=nginx
Type: NodePort
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.100.238.2
IPs: 10.100.238.2
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32714/TCP
Endpoints: 10.0.2.243:80
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
My machines are on a 192.168.10.0/24 Network. The ClusterIP (see above) is: 10.100.238.2
But this IP is (obviously) not reachable from my subnet, so all curl’s would fail.
However, reaching the Service via (e.g.) 192.168.10.11:80 works perfectly.
Why ?