Skip to content

Latest commit

 

History

History
86 lines (59 loc) · 4.35 KB

setup-deploy-pipeline.asciidoc

File metadata and controls

86 lines (59 loc) · 4.35 KB

Setting up the Deploy Pipeline

In this section we will create a deploy pipeline on Azure DevOps to deploy the application on kubernetes cluster. This pipeline will be configured to be triggered manually or triggered by a package pipeline depending on the branch.

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

Then, a Pull Request (PR) will be created in order to merge the new branch into the appropriate branch (provided in -b flag). The PR will be automatically merged if the repository policies are met. If the merge is not possible, either the PR URL will be shown as output, or it will be opened in your web browser if using -w flag.

The script located at /scripts/pipelines/azure-devops/pipeline_generator.sh will automatically create 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.

Note
The deploy pipeline will fail if the package pipeline executed on the same commit has failed.

Prerequisites

  • If it is private container registry, create secret for docker registry to pull image from private repository.

Note
Use extra secrets script to pull image from private container registry --secrets-value flag.
  • 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).

Creating the pipeline using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <pipeline name> \
  -d <project local path> \
  --deploy-files <deploy files> \
  --deploy-cluster <deploy cluster name> \
  --secrets-value <secretsValue> \
  --package-pipeline-name <package pipeline name> \
  [-b <branch>] \
  [-w]
Note
The config file for the deploy pipeline is located at /scripts/pipelines/azure-devops/templates/deploy/deploy-pipeline.cfg.

Flags

-c  --config-file             [Required] Configuration file containing pipeline definition.
-n  --pipeline-name           [Required] Name that will be set to the pipeline.
-d  --local-directory         [Required] Local directory of your project (the path should always be using '/' and not '\').
    --deploy-files            [Required] Path inside the remote repository where the manifest YAML files are located.
    --deploy-cluster          [Required] Name of the kubernetes cluster, AKS or EKS.
    --secrets-name                       Name of the secrets.
    --package-pipeline-name   [Required] Name of the Package pipeline.
-b  --target-branch                      Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-w                                       Open the Pull Request on the web browser if it cannot be automatically merged. Requires -b flag.

Examples

Quarkus project

./pipeline_generator.sh -c ./templates/deploy/deploy-pipeline.cfg -n quarkus-project-deploy -d C:/Users/$USERNAME/Desktop/quarkus-project --deploy-files manifest-path --deploy-cluster deploy-cluster-name --package-pipeline-name package-pipeline-name -b develop -w
Caution
Remember to write the path to the local repository with '/' and not '\' on Windows.

Appendix:

Interacting with the AKS cluster

In order to interact with your cluster download the artifact kubeconfig generated by the provision pipeline and execute the following command:

kubectl <kubectl command> --kubeconfig <kubeconfig path>

Once your successfully deploy application, get the hot name to access application in publicly by following command.

Note
kubectl get ingress -n <namespace> --kubeconfig <kubeconfig path>

Interacting with the EKS cluster

Before connecting to the EKS cluster, enable right access to the IAM user, please refer here.

Run the below command to connect to the AWS EKS cluster from your terminal

aws eks update-kubeconfig --name <eks-cluster-name> --region <aws region>

Now you can use kubectl command to get the hot name, access application in publicly.

Note
kubectl get ingress -n <namespace>