Deploying to Google Cloud Platform
You can deploy JHipster applications to Google Cloud Platform and run on:
- Virtual machines with Google Compute Engine
- Containers in Kubernetes with Google Kubernetes Engine
- Platform as a Service with Google App Engine
You can obtain Google Cloud Platform free trial to deploy your applications. Please check the Always Free tiers for free usages up to the specified usage limits during and past the free trial.
Before you start
Install and authenticate with the gcloud SDK on your local environment to access gcloud
CLI. For more information, visit this link:
Deploy to Google Kubernetes Engine
Google Kubernetes Engine is a fully managed Kubernetes cluster as a service. Once provisioned, you can deploy your containers and JHipster applications using standard Kubernetes commands.
- Enable API:
gcloud services enable container.googleapis.com containerregistry.googleapis.com
- Install
kubectl
CLI if not already installed:gcloud components install kubectl
- Create a new Google Kubernetes Engine cluster:
gcloud container clusters create mycluster --zone us-central1-a --machine-type n1-standard-4
See GCP's zones and machine-types for other options.
Once the cluster is created, you can use JHipster Kubernetes generator to generate the deployment descriptors.
- Generate Kubernetes deployment files:
jhipster kubernetes
- If you want to use Google Container Registry to publish container images in a private registry:
- What should we use for the base Docker repository name set to
gcr.io/YOUR_PROJECT_ID
Build the container image.
- If you use Google Container Registry, you can build directly to the registry without local Docker daemon:
./mvnw package -Pprod jib:build
- Otherwise, build to Docker daemon:
./mvnw package -Pprod jib:dockerBuild
Deploy to Kubernetes cluster:
- Apply the Kubernetes configurations:
./kubectl-apply.sh
For full Kubernetes generator features, see Deploying to Kubernetes.
Enable HTTPS
To enable HTTPS for your cluster, see Ray Tsang's External Load Balancing docs.
You can force the use of HTTPS by adding the following configuration to your SecurityConfiguration.java
.
// Spring MVC
http.requiresChannel(channel -> channel
.requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null).requiresSecure());
// WebFlux
http.redirectToHttps(redirect -> redirect
.httpsRedirectWhen(e -> e.getRequest().getHeaders().containsKey("X-Forwarded-Proto")));
See Spring Security's Servlet and WebFlux documentation for more information.