Git Product home page Git Product logo

github-runners's Introduction

Step By Step Jenkins CI/CD Guide with Huawei Cloud ECS. (TLDR...)

  1. Programming language or framework to used is (.Net)
  2. CI/CD tool will be used (Jenkins)
  3. Source control management tool (GitLab)
  4. CI/CD environment (ECS)
  5. Application Environment (ECS)
  6. Special Request toward CICD pipeline
  • Need to get manual approval before deploy to production environment
  • Store the build artifact for each build.

1. Infrastucture

Prepare related infrastucture using terraform

export HW_ACCESS_KEY="2EHGMJTTJBTWTK1JIZKA"
export HW_SECRET_KEY="<- Your Huawei Secret Key ->"
export PROJECT_ID="0"
export PASSWORD="<- Your ECS password, will used for SSH ->"

terraform init
TF_VAR_secret_key=$HW_SECRET_KEY TF_VAR_access_key=$HW_ACCESS_KEY TF_VAR_password=$PASSWORD TF_VAR_project_ID=$PROJECT_ID terraform apply

2. Jenkins Deployment

#1. Install docker 
dnf install docker
systemctl start docker

#2. Deploy Jenkins To Docker
docker run --name jenkins-blueocean --restart=on-failure --detach \
  --volume jenkins-data:/var/jenkins_home \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --privileged \
  --user=root --publish 8080:8080 --publish 50000:50000 jenkins/jenkins:lts-jdk17

# 3. Get "first time login" password
docker exec jenkins-blueocean cat /var/jenkins_home/secrets/initialAdminPassword

# 4. Copy the password to your jenkins browser.
# 5. Install default plugin
# 6. Create first admin user

alt text alt text alt text alt text

Jenkins Agent

First, we will turn off of using node executor, which this action will not allow to run pipeline together with Jenkins application, instead we will run pipeline on isolate environment call agents which we will configure in next few step. This is the best practice recommended by Jenkins to improve security measure.

To turn off node executor follow below figure. alt text

Then we need to create agent to run pipeline. First, we need to install relative Jenkins plugin.Follow step from below figure. alt text

Then, we need to configure our agent. There are some important note before you follow below guide, the official image used as agent may have problem. You need to create your own image. Follow the below guide before going to the figure.

cd jenkins-agent
docker build -t swr.ap-southeast-3.myhuaweicloud.com/test-fq/jenkins-agent:latest .
docker push swr.ap-southeast-3.myhuaweicloud.com/test-fq/jenkins-agent:latest

alt text

# Agent Mounts
type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock
type=bind,src=/usr/bin/docker,dst=/usr/bin/docker

Pipeline Creation.

We have two requirement during pipeline design, first is store the dotnet artifact and request for approval before make deployment to production.

Before we create the pipeline, we first need to interconnect GitLab with this pipeline. Follow the figure below to perform this configuration.

alt text

Then you can start creating your first pipeline. Remember the pipeline also need to connect to your gitlab repository. Follow the figure below.

alt text

Then you need to configure your gitlab repo on how to trigger the pipeline when there is commit. Follow below figure.

alt text

Before proceeds, I will roughly talk about what the pipeline does. The pipeline will clone the latest push commit from GitLab, build the image, push to docker registry (SWR) then deploy to environment according to approval. Lastly, since my gitlab repository is in private mode, so I need to add credential to login to gitlab also.

Then we need to configure the credentials used in Jenkinsfile include docker registry credential and build name. Below is the figure we needed.

alt text

Demo.CICD-Build-Name: swr.ap-southeast-3.myhuaweicloud.com/test-fq/likecard-demo Demo.CICD-SWR-AK: <- Your HW access key get from HW cloud console -> Demo.CICD-SWR-SK: <- Follow below instruction ->

printf "Huawei Access Key Here (Get From Console)" | openssl dgst -binary -sha256 -hmac "Huawei Secret Key Here (Get From Console)" | od -An -vtx1 | sed 's/[ \n]//g' | sed 'N;s/\n//'

Then you can make a commit in your gitlab to check your pipeline execution. That all for this, thank you.

Email Notification configuration

Ref: https://www.youtube.com/watch?v=pAOJ9k2o67Q

alt text

github-runners's People

Contributors

oversampling avatar

Watchers

Lucian avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.