Merging Everything into the Same YAML Definition

Merge all the definitions explored until now into a single YAML file and then create objects using that file.

Looking into the merged file#

Consider this lesson a short intermezzo. We’ll merge the definitions we used in this chapter into a single YAML file.

You already had a similar example before, so there’s no need for lengthy explanations.

Let us look at the definition of go-demo-2.yml.

Definition of `go-demo-2`

The differences#

If you start searching for differences with the previous definitions, you will find a few.

  • The minReadySeconds, progressDeadlineSeconds, revisionHistoryLimit, and strategy fields are removed from the go-demo-2-api Deployment.

  • We used them mostly as a way to demonstrate their usage. But, since Kubernetes has sensible defaults, we omitted them from this definition.

  • You’ll also notice that there are two Services even though we created only one in this chapter. We did not need the go-demo-2-api Service in our examples since we didn’t need to access the API. But, for the sake of completeness, it is included in this definition.

  • Finally, the strategy for deploying the database is set to recreate. As explained earlier, it is more suited for a single-replica database, even though we did not mount a volume that would preserve the data.

Creating objects with the merged file#

Let’s create the objects defined in dgo-demo-2.yml. Remember, with --save-config we’re making sure we can edit the configuration later. The alternative would be to use kubectl apply instead.

Create 'go-demo-2'

The output of the latter command is as follows.

Output of the above command

All four objects (two Deployments and two Services) were created successfully.

Try it yourself#

List of all the commands used in this lesson are give below.

Commands used in this lesson

You can practice the commands in the following code playground by pressing the Run button and waiting for the cluster to set up.

/
go-demo-2.yml
Merge everything into the same YAML definition
Rolling Back Failed Deployments
Updating Multiple Objects
Mark as Completed
Report an Issue