gcloud setup deploy pipeline - devonfw/hangar GitHub Wiki

Setting up a Deploy pipeline on Google Cloud

In this section we will create a deploy pipeline on Google Cloud to deploy the project application on an already provisioned Kubernetes cluster. This pipeline will be configured in order to be triggered every time package pipeline is executed successfully on a commit for `release/*` and `develop` branches, requiring manual launch for other branches. By default, it depends on the environment provisioning pipeline being successfully run on beforehand and, depending on the Kubernetes provider, it consumes the artifact produced by that. It also consumes variable groups created by package and environment provisioning pipeline.

The creation of the pipeline will follow the project workflow, so a new branch named feature/deploy-pipeline will be created and the YAML file for the pipeline will be pushed to it.

Then, the new branch will be merged into the appropriate branch (provided in -b flag).

The script located at /scripts/pipelines/gcloud/pipeline_generator.sh will automatically create the new branch, create a deploy pipeline based on a YAML template appropriate for the project manifests files, create the Pull Request, and if it is possible, merge this new branch into the specified branch.

Prerequisites

  • This script will commit and push the corresponding YAML template into your repository, so please be sure your local repository is up-to-date (i.e you have pulled the latest changes with git pull).

  • The YAML containing Deployment object should be named application-deployment.yaml for allowing automated imagePullSecret injection.

Creating the pipeline using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <{pipeline_type} name> \
  -d <project local path> \
  --env-provision-pipeline-name <{pipeline_type} name> \
  --k8s-namespace <namespace> \
  --k8s-deploy-files-path <manifests path> \
  [--package-pipeline-name <{pipeline_type} name>] \
  [--k8s-image-pull-secret-name <secret name>] \
  [-b <branch>] \
machineType[  [-m <machine type for {pipeline_type} runner>]]
NOTE: The config file for the deploy pipeline is located at /scripts/pipelines/gcloud/templates/deploy/deploy-pipeline.cfg.

Flags

-c  --config-file                   [Required] Configuration file containing {pipeline_type} definition.
-n  --pipeline-name                 [Required] Name that will be set to the {pipeline_type}.
-d  --local-directory               [Required] Local directory of your project.
    --env-provision-pipeline-name   [Required] Environment provisioning {pipeline_type} name.
    --k8s-namespace                 [Required] Kubernetes namespace where the application will be deployed.
    --k8s-deploy-files-path         [Required] Path from the root of the project to the YAML manifests directory.
    --package-pipeline-name                    Package {pipeline_type} name.
    --k8s-image-pull-secret-name               Name for the generated secret containing registry credentials. Required when using a private registry to host images.

-b  --target-branch                            Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
machineType[-m, --machine-type                             Machine type for {pipeline_type} runner. Accepted values: E2_HIGHCPU_8, E2_HIGHCPU_32, N1_HIGHCPU_8, N1_HIGHCPU_32.]

Examples

./pipeline_generator.sh -c ./templates/deploy/deploy-pipeline.cfg -n quarkus-project-deploy -d C:/Users/$USERNAME/Desktop/quarkus-project --package-pipeline-name quarkus-project-package --env-provision-pipeline-name eks-provisioning --k8s-provider EKS --k8s-namespace hangar --k8s-deploy-files-path k8s -b develop {openBrowserFlag}

Appendix: accessing the application

Once the pipeline is executed and your application is deployed, you can list the hostname to access it by running locally:

kubectl get ingress -n <namespace>
⚠️ **GitHub.com Fallback** ⚠️