Deploy a Web Application With Let’s Encrypt and Kubernetes Using Terraform on GCP (Part 2)


In previous article, we learnt how to deploy a real application made by ourselves. Assume that we had already built our application, the next question is how we maintain our code. In this part, we will talk about how to maintain our code and update our application.

If we deploy correctly, all the things look like above figure.

Make Change on Code

Suppose we want to edit a little bit of our code, let say add “!!!” after our “Here is Fib calculator” title. We may need change a code in terraform-k8s-calculator-letsencrypt/client/src/App.js like below.

      <div className="App">
        <header className="App-header">
          <img src={logo} alt="logo" width="10%" height="10%"/>
            Here is Fib calculator!!!
          <Link to="/">Home</Link>
          <Link to="/otherpage">Other Page</Link>
          <Route exact path="/" component={Fib} />
          <Route path="/otherpage" component={OtherPage} />

Login DockerHub

Here I use Docker Hub to store our Docker Images. Of course, you can use GCP Container Registry to store your images, it is totally up to you.

To login Docker, please type:

docker login

And then type your own username and password.

Push Images Using Script

I have prepare a file, please change all the username as your own. The first few lines are to get the git commit SHA header. Then we save it as a variable and use it as our docker images tagging. In this way, we can easily keep track of the record.

Be friendly reminded that you feel free to build your code using real CI/CD approach, integrate with Jenkins for example.

Then we just have to run this script by typing:


It may take a little bit of time to rebuild all images and push to the DockerHub.

The we reload the page, we can see the change immediately. The reason is that our k8s yaml file is looking at the latest Docker image, so when we push the latest image it will automatically change accordingly.


Just like before, if we want to clean up all the things, we just have to type:

terraform destroy

Then choose “yes” to confirm.

Leave a Reply