carnote
carnote

Reputation: 13

Error converting YAML to JSON: mapping values are not allowed in this context ( Azure context)

I did the following tutorial:

https://learn.microsoft.com/en-us/learn/modules/cloud-native-apps-orchestrate-containers/7-exercise-connect-container-to-web-app

I created the ingress.yaml file as follows:

#ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cna-express
  annotations:
    kubernetes.io/ingress.class: addon-http-application-routing
spec:
  rules:
  - host: cna-express.4d667ba6676144bbac81.westeurope.aksapp.io
      paths:
      - path: / # Which path is this rule referring to
        pathType: Prefix
        backend: # How the ingress will handle the requests
          service:
            name: cna-express # Which service the request will be forwarded to
            port: 
              name: http # Which port in that service

However, I have the following output:

error: error parsing ./ingress.yaml: error converting YAML to JSON: yaml: line 11: mapping values are not allowed in this context

Do you have any idea about what could be the issue? With my best

Upvotes: 0

Views: 1618

Answers (1)

Hamid Ostadvali
Hamid Ostadvali

Reputation: 232

You forgot to add http line. Try this one please:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cna-express
  annotations:
    kubernetes.io/ingress.class: addon-http-application-routing
spec:
  rules:
  - host: cna-express.4d667ba6676144bbac81.westeurope.aksapp.io
    http:
      paths:
      - path: / # Which path is this rule referring to
        pathType: Prefix
        backend: # How the ingress will handle the requests
          service:
            name: cna-express # Which service the request will be forwarded to
            port: 
              name: http # Which port in that service

Also you can use this documentation for more information about ingress: https://kubernetes.io/docs/concepts/services-networking/ingress/

Upvotes: 0

Related Questions