Abhijeet1234
Abhijeet1234

Reputation: 45

Getting error while creating the NodePort service in EKS cluster

I am trying to create Nodeport service in my EKS cluster however I am getting error as for: "network/minikube/orderers/services.yaml": map: map[name:endpoint] does not contain declared merge key: port. Can anybody help me to fix the issue.

My service.yaml file

apiVersion: v1
kind: Service
metadata:
  name: orderer0-service
  labels: {
    component: orderer0,
    type: orderer
  }
spec:
  type: NodePort
  ports:
    - name: endpoint
    - port: 7050
      targetPort: 7050
      nodePort: 30050
  selector:
    component: orderer0
    type: orderer

Upvotes: 0

Views: 245

Answers (2)

Sahadat Hossain
Sahadat Hossain

Reputation: 4351

ports: is representing list of ports, where by - you are separating the ports, (name, port, targetPort, nodePort) these four are combinedly representing one service port values, and you mistakenly included another list in (- port: 7050), your yaml should be like below,

  ports:
    - name: endpoint
      port: 7050
      targetPort: 7050
      nodePort: 30050

YAML:

apiVersion: v1
kind: Service
metadata:
  name: orderer0-service
  labels: {
    component: orderer0,
    type: orderer
  }
spec:
  type: NodePort
  ports:
    - name: endpoint
      port: 7050
      targetPort: 7050
      nodePort: 30050
  selector:
    component: orderer0
    type: orderer

Upvotes: 2

Arghya Sadhu
Arghya Sadhu

Reputation: 44569

The yaml has a problem.You don't need the - infront of port.It should be like below

apiVersion: v1
kind: Service
metadata:
  name: orderer0-service
  labels: {
    component: orderer0,
    type: orderer
  }
spec:
  type: NodePort
  ports:
    - name: endpoint
      port: 7050
      targetPort: 7050
      nodePort: 30050
  selector:
    component: orderer0
    type: orderer

Upvotes: 1

Related Questions