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
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 App Engine
Google App Engine is a fully managed Platform as a Service that can automatically scale up application instances under load, and scale down to zero when not used.
You can use the Google App Engine generator to generate and deploy JHipster application. Google App Engine generator supports monolith application, with Cloud SQL MySQL/PostgreSQL database.
- Generate a new monolith application:
- Run Google App Engine generator:
- Optionally create a new Cloud SQL instance if creating a brand new application
This generator will:
src/main/appengine/app.yamlthat describes the App Engine instance and scaling configuration.
- Add the App Engine plugin to Maven / Gradle.
To deploy: Please note that currently the Google App Engine generator only supports deployments to App Engine Standard (Java 11) environment.
Use the App Engine plugin to deploy:
./mvnw package appengine:deploy -DskipTests -Pgae,prod-gaeor using Gradle
./gradlew appengineDeploy -Pgae -Pprod-gae
If you are using Cloud SQL, you need to add Cloud SQL Client role to the App Engine service account. Refer, https://cloud.google.com/sql/docs/mysql/connect-app-engine#setting_up
In addition, Google App Engine provides a full suite of features to manage your application:
- Traffic Splitting - Deploy multiple versions of your application and split traffic to different versions. This is also great for canary new changes.
- Stackdriver Logging - Automatically capture and store application logs in centralized logging that can be searched, monitored, and exported.
- Error Reporting - Automatically extract errors and exceptions for the log and notify you of new errors.
- Cloud Debugger - Allow you to debug your production application without stopping the world. If you needed more log messages to diagnose the issue, add new log messages without redeploying/restarting your application.
You can watch a walk through of features in 2018 JHipster Conf video on the Google App Engine generator with Ray Tsang and Ludovic Champenois.
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
kubectlCLI if not already installed:
gcloud components install kubectl
- Create a new Google Kubernetes Engine cluster:
gcloud container clusters create mycluster
Once the cluster is created, you can use JHipster Kubernetes generator to generate the deployment descriptors.
- Generate Kubernetes deployment files:
- 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
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:
For full Kubernetes generator features, see Deploying to Kubernetes.