kubectl apply -f service.yml throws error

1/5/2019

error: error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context

This is my service.yml:

apiVersion: v1
 kind: Service
  metadata:
    name: eureka-service
spec:
  type: LoadBalancer
  ports:
    - port: 8761
      targetPort: 8761
  selector:
    app: eureka-naming-server

I don't know what's wrong with this service.yml. I have a running pod on Google Kubernetes with the labels: app eureka-naming-server

-- Emanuel Di Teresa
indentation
kubernetes
yaml

1 Answer

1/5/2019

In YAML block styles, structure is determined by indentation. Did you space the file as follows?:

apiVersion: v1
kind: Service
metadata:
  name: eureka-service
spec:
  type: LoadBalancer
  ports:
    - port: 8761
      targetPort: 8761
  selector:
    app: eureka-naming-server
-- jinbeom hong
Source: StackOverflow