Skip to content

Table of Content

GitLab CI/CD

[[GitLab CI/CD]]

CI/CD is a continuous method of software development, where you continuously build, test, deploy, and monitor iterative code changes.

This iterative process helps reduce the chance that you develop new code based on buggy or failed previous versions. GitLab CI/CD can catch bugs early in the development cycle, and help ensure that all the code deployed to production complies with your established code standards.

I have self-managed GitLab running in my environment, so what I need to use GitLab CI/CD are:

  • GitLab server
  • GitLab Runner registered to the GitLab
  • GitLab project with GitLab Runner assigned
  • ./.gitlab-ci.yaml file in the project

[[GitLab Runner]] instances are workers periodically checking in with GitLab to look for jobs to do, and whenever a GitLab project gets a new push and there is a job recipe file ./.gitlab-ci.yaml file, a runner instance takes it and does the work.

As also mentioned in MkDocs section, this site is generated and uploaded by GitLab CI/CD.

GitLab Runner

[[GitLab Runner]]

See [[building-home-lab-part-6]] for the deployment to Kubernetes cluster using Flux (GitOps) and helm.

building image

Use kaniko to build container images.

kaniko is a tool to build container images from a Dockerfile, inside a container or Kubernetes cluster.

latest release

Go to the repository or run below to check the latest available version.

curl -sfL "" | grep "tag_name"

example .gitlab-ci.yml

  KANIKO_CACHE_DIR: "/cache"
  KANIKO_VERSION: "v1.22.0-debug"
  VERSION: "0.1.1"


  - build

  stage: build
  retry: 2
    name: $HARBOR_HOST/cache-gcrio/kaniko-project/executor:$KANIKO_VERSION
    entrypoint: [""]
    - echo "{\"auths\":{\"$HARBOR_HOST\":{\"auth\":\"$(echo -n ${HARBOR_USERNAME}:${HARBOR_PASSWORD} | base64)\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor
      --build-arg "HARBOR_HOST=$HARBOR_HOST"
      --cache-dir /cache
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/build/Dockerfile"


# when there are changes in files under ./slides directory
    - changes:
          - slides/*