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.
We'll cover the following
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
.
The differences#
If you start searching for differences with the previous definitions, you will find a few.
-
The
minReadySeconds
,progressDeadlineSeconds
,revisionHistoryLimit
, andstrategy
fields are removed from thego-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.
The output of the latter command is as follows.
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.
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