mentioned ip to endpoints are not getting configured in k8s

Viewed 44

i am trying to add IPs manually using endpoint object in yaml. however minikube cluster is getting its defaults ips of endpoints instead of mention in the yaml file. why?

yamlfile:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-app
  template:
    metadata:
      labels:
        app: nginx-app
    spec:
      containers:
      - name: nginx-container
        image: nginx:1.16
        ports:
        - containerPort: 80
---        
apiVersion: v1
kind: Endpoints
metadata:
  name: nginx-service
subsets:
    - ports:
      - port: 80
      addresses:
       - ip: 172.17.0.11           ---> configured ip
       - ip: 172.17.0.12           ---> configured ip
       - ip: 172.17.0.13           ---> configured ip
---        
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: NodePort
  selector:
    app: nginx-app
  ports:
    - protocol: TCP
      nodePort: 30464
      port: 90
      targetPort: 80

ips in endpoint output: (see 172.17.0.6, 172.17.0.7 and 172.17.0.8 while i have given 172.17.0.11, 172.17.0.12 and 172.17.0.13 in yaml)

/home/ravi/k8s>kubectl get endpoints
NAME            ENDPOINTS                                   AGE
kubernetes      192.168.49.2:8443                           36h
nginx-service   172.17.0.6:80,172.17.0.7:80,172.17.0.8:80   5m59s
1 Answers

I have tried replicating your issue and got the configured IP addresses for endpoints.

enter image description here

enter image description here

The changes might have occurred due to the namespaces also, Once check it .

Related