How to deploy NextJS app to Kubernetes Cluster in GCP with Custom Domain?
Apr 1,2022
39 mins read
Nilesh Mahajan
Founder and Engineer
Introduction
NextJS is a popular framework to write react web applications. It has amazing features like Static Site Generation (SSG) and Server Side Rendering to make your web applications extremely fast and gives a boost to your SEO. It comes correctly configured with all the bells and whistles needed to make your react application production-ready.
But deploying an app to cloud environment requires quite a lot of configuration and learning new things. This tutorial guides you on how you can deploy NextJS application to a Kubernetes Cluster on Google Cloud Platform and then point your custom domain name to it.
Prerequisites
Domain Name In the last stage, we will pointing your custom domain name to your NextJS application hosted on Google Cloud Platform. You can buy domain names from various sites like NameCheap, Or Domain.Google.
Google Cloud Account You also need to have account created on Google Cloud Console with billing account setup. If you don't have one, you can create here.
Running on Google Cloud may incur charges. Please make sure you follow instructions in last step to clean up your cluster after you are done.
What you need?
Before we begin, we need below dependencies installed on your machine -
To confirm if your environment setup is correct, you can run simple version commands on your terminal as shown below
$ npm version
// ... some version information
$ gcloud version
// ... some version information
$ docker version
// ... some version information
$ kubectl version
// ... some version information
bash
If any of the dependencies are missing, please use the links given to setup your environment properly.
Expected Output
At the end of this codelab, you would be able to get your web application hosted on your custom domain name and served by a kubernetes cluster hosted in GCP