Deploying the First Release

Learn how to deploy our first release to get started with Namespaces.

Looking into the definition#

We’ll start by deploying the go-demo-2 application and use it to explore Namespaces. The file is shown below.

Defintion of `go-demo-2`

The definition is the same as the one we used before, so we’ll skip the explanation of the YAML file. Instead, we’ll jump right away into the deployment.

Altering the definition#

Unlike previous cases, we’ll deploy a specific tag of the application. If this would be a Docker Swarm stack, we’d define the tag of the vfarcic/go-demo-2 image as an environment variable with the default value set to latest.

Unfortunately, Kubernetes does not have that option. Since we don’t believe that it is a good idea to create a different version of the YAML file for each release, we’ll use sed to modify the definition before passing it to kubectl.

Using sed to alter Kubernetes definitions is not a good solution. We should use a templating solution like, for example, Helm. However, we are focusing purely on Kubernetes.

Helm and other third-party products are out of the scope of this course. So, we’ll have to do with a workaround in the form of sed commands.

Altering the definition of `go-demo-2`
  • We declared environment variables IMG and TAG.

  • We cat the YAML file and piped the output to sed. It, in return, replaced image: vfarcic/go-demo-2 with image: vfarcic/go-demo-2:1.0.

  • The modified definition was piped to kubectl.

When the -f argument is followed with a dash (-), kubectl uses standard input (stdin) instead of a file. In our case, that input is the YAML definition altered by adding the specific tag (1.0) to the vfarcic/go-demo-2 image.

Verification#

Let’s confirm that the deployment rolled out successfully.

`go-demo-2` roll out status

We’ll check whether the application is deployed correctly by sending an HTTP request. Since the Ingress resource we just created has the host set to go-demo-2.com, we’ll have to “fake” it by adding Host: go-demo-2.com header to the request.

Calling the application `go-demo-2`

The output is as follows.

Output of 'curl'

The reason we jumped through so many hoops to deploy a specific release will be revealed soon. For now, we’ll assume that we’re running the first release in production.

Try it yourself#

A list of all the commands used in the lesson is given 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
Deploying first release

Getting Started with Cluster Division
Exploring Virtual Clusters
Mark as Completed
Report an Issue