Deploying to Google Cloud Platform Permalink to " Deploying to Google Cloud Platform"

Google Cloud Platform

You can deploy JHipster applications to Google Cloud Platform and run on:

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 Permalink to "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 Permalink to "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.

  1. Enable API: gcloud services enable container.googleapis.com containerregistry.googleapis.com
  2. Install kubectl CLI if not already installed: gcloud components install kubectl
  3. 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.

  1. Generate Kubernetes deployment files: jhipster kubernetes
  2. If you want to use Google Container Registry to publish container images in a private registry:
  3. What should we use for the base Docker repository name set to gcr.io/YOUR_PROJECT_ID

Build the container image.

  1. If you use Google Container Registry, you can build directly to the registry without local Docker daemon: ./mvnw package -Pprod jib:build
  2. Otherwise, build to Docker daemon: ./mvnw package -Pprod jib:dockerBuild

Deploy to Kubernetes cluster:

  1. Apply the Kubernetes configurations: ./kubectl-apply.sh

For full Kubernetes generator features, see Deploying to Kubernetes.

Enable HTTPS Permalink to "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.