GitLab CI/CD implementation on Kubernetes Cluster (L4 And L7 Load Balancer)

 

  1. Login to Gitlab and create a project
Create project in Gitlab

2. Add Kubernetes cluster in created project

Select Kubernetes option under operations

3. Add existing cluster and fill up all the fields which is related to kube-config file.

Fill Kubernetes cluster info

4. Disable the Auto Dev-Ops for project. Go to settings->CI/CD->Expand Auto Dev-Ops and uncheck the Default to Auto DevOps Pipeline.

Disable auto DevOps

5. Create or Enable Runner for this project (Settings->CI/CD->Expand Runner) . Set up a specific Runner manually or Enable the shared runner (Created earlier by using link https://docs.gitlab.com/runner/install/linux-manually.html)

Enable Runner

6. Now Deploy the project with Docker file, gitlab ci/cd file and kubernetes template file. Gitlab CI/CD file named .gitlab-ci.yml and format is as below

#before_script:
# - sudo usermod -aG docker $USER
build:
script:
- docker build -t dokcer.io/library/nginx:$CI_COMMIT_SHA .
- docker login -u $USER -p $PASSWORD docker.io
- docker push docker.io/library/nginx:$CI_COMMIT_SHA
deploy:
script:
- sed "s/_TAG_/$CI_COMMIT_SHA/g" kubernetes.tpl.yml > kubernetes.yml;
- sed 's/_SERVER_/$SERVER/g; s/_TOKEN_/$TOKEN/g' demo_tpl.yml > kubeconfig.yml; cat kubeconfig.yml
- kubectl --kubeconfig=kubeconfig.yml apply -f kubernetes.yml

7. Download gitlab CI/CD on Kubernetes cluster with L4 Load Balancer : https://gitlab.com/vineetkumar03/gitlab-cicd-l4lb and for L7 Load Balancer: https://gitlab.com/vineetkumar03/gitlab-cicd-l7lb

8. Set Environment variable for use encrypted parameters like password and token values (Like $USER ,$PASSWORD,$TOKEN etc.) in GitLab project: settings — > CI/CD — > Expand Variables and define variable and its value.

Comments

Popular posts from this blog

Convert .iso Image to .qcow2 Image

THE ULTIMATE DOCKER CHEAT SHEET

Configuring Shared Folders in VMWare Workstation with a UBUNTU Guest OS and Windows Host