Home > Software design >  Kubernates: Unknown field "ClusterIP" in io.k8s.api.core.v1.ServiceSpec
Kubernates: Unknown field "ClusterIP" in io.k8s.api.core.v1.ServiceSpec

Time:08-31

I am working with spring boot with microservices. I dockerize my all microservices and now I am trying to create resource in kubernates cluster. I get error while create resource in cluster through running kubectl apply.

Here down is my configuration file for kubernates:

eureka-server.yml

kind: ConfigMap
apiVersion: v1
metadata:
  name: eureka-cm
data:
  eureka_service_address: http://eureka-0.eureka:8761/eureka

---

apiVersion: v1
kind: Service
metadata:
  name: eureka
  labels:
    app: eureka
spec:
  ClusterIP: None
  ports: 
  - port: 8761
    name: eureka
  selector:
    app: eureka

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: eureka
spec:
  selector:
    matchLabels:
      app: eureka
  serviceName: "eureka"
  replicas: 1
  template:
    metadata:
      labels:
        app: eureka
    spec:
      containers:
      - name: eureka
        image: username/eureka-server:latest
        imagePullPolicy: Always
        ports:
          - containerPort: 8761
        env:
          - name: EUREKA_SERVER_ADDRESS
            valueFrom:
              configMapKeyRef:
                name: eureka-cm
                key: eureka_service_address

---

apiVersion: v1
kind: Service
metadata:
  name: eureka-lb
  labels:
    app: eureka
spec:
  selector:
    app: eureka
  type: NodePort
  ports:
    - port: 80
      targetPort: 8761

Configuration file in spring boot for eureka server:

application.yml

server:
  port: 8761
eureka:
  instance:
    hostname: "${HOSTNAME}.eureka"
  client:
    registerWithEureka: false
    fetchRegistry: false
    service-url:
      defaultZone: ${EUREKA_SERVER_ADDRESS}
  server:
    waitTimeInMsWhenSyncEmpty: 0

Here down is my error I got while create resource in kubernates cluster:

error: error validating "./eureka-server.yml": error validating data: ValidationError(Service.spec): unknown field "ClusterIP" in io.k8s.api.core.v1.ServiceSpec; if you choose to ignore these errors, turn validation off with --validate=false

CodePudding user response:

Well the error message you get is essentially the answer to your question. The field ClusterIP does not exist, but it is actually called clusterIP, which you can easily find out by reading the API reference.

  • Related