Issue: The YAML snippets in How Kubernetes works under the hood with Docker Desktop blog post are broken—mixes tabs and spaces

The How Kubernetes works under the hood with Docker Desktop | Docker blog post is informative; however, the examples are broken because the code snippets mix tabs and spaces and that’s not valid YAML.

For example, if you copy the following Kubernetes Service YAML snippet from the 2. Deploying and accessing applications section and paste into yq command then you get get the following error.

# Gotcha: This is broken because mixes tabs and spaces—see _2. Deploying and accessing applications_ section of
apiVersion: v1
kind: Service
  name: tutorial
      - name: 80-tcp
  	port: 80
  	protocol: TCP
  	targetPort: 80
	com.docker.project: tutorial
  type: LoadBalancer
  loadBalancer: {}

Then you get the following error.

$ pbpaste | yq
Error: bad file '-': yaml: line 7: found a tab character that violates indentation

If you look at the YAML document in a text editor like Sublime Text, then you can notice the mixed tabs and spaces—see screenshot.

Request: Please coordinate with Anca Iordache or someone else and fix those YAML snippets, since the article is very helpful; however, the broken YAML does affect the correctness of the examples.

That is indeed wrong. Thank you for reporting it and also sharing your way to validate the yaml content. I don’t know how the Docker blog works, but I had a code higlighting module once that broke the perfectly valid yaml. I can’t check it and I actually don’t know how one could report an issue on the docker blog directly.

Can you get that fixed @ajeetraina ?

Let me work with Docker team and get this fixed.

@mbigras I have got it fixed. Can you check and let me know.

That works! Thanks for your fix :slight_smile:. This is what I did to check:

  1. Navigate to 2. Deploying and accessing applications section.

  2. Copy that YAML.

  3. Paste into some tool that parses YAML—like that excellent yq CLI.

    $ pbpaste | yq
    apiVersion: v1
    kind: Service
      name: tutorial
    # ...

    Consider the following:

    1. Observation: Notice that the YAML succesfully parses—it works!
    2. Note: That command depends on pbcopy macOS CLI. On Linux, you can use something like xclip.