I have a kubernetes kind cluster with the following configuration:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
    kubeadmConfigPatches:
      - |
        kind: InitConfiguration
        imageGCHighThresholdPercent: 70
        evictionHard:
          nodefs.available: "0%"
          nodefs.inodesFree: "0%"
          imagefs.available: "70%"
        nodeRegistration:
          kubeletExtraArgs:
            node-labels: "ingress-ready=true"
    extraPortMappings:
      - containerPort: 80
        hostPort: 80
        protocol: TCP
      - containerPort: 443
        hostPort: 443
        protocol: TCP
Image version: docker.io/kindest/base:v20220305-b67a383f
I am trying to connect to my localhost by using ExternalName:
kind: Endpoints
apiVersion: v1
metadata:
  name: my-external-service
subsets:
  - addresses:
      - ip: 10.0.2.2
    ports:
      - port: 8080
---
kind: Service
apiVersion: v1
metadata:
  name: my-external-service
  labels:
    app: my-external-service
spec:
  ports:
    - port: 8080
      targetPort: 8080
      protocol: TCP
According to this answer: why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client, that IP should be the localhost in my local machine.
Then I run a container to debug this setup:
kubectl run -i --tty --rm debug --image=alpine --restart=Never -- sh
8.8.8.8 is pingable, but unfortunately I cannot ping 10.0.2.2.
What am I doing wrong?
 
    