Build Docker image on Kubernetes using GitLab

GitLab: c2platform/examples/kubernetes/gitlab-docker-build 

This project demonstrates how we can build and release Docker image registry.gitlab.com/c2platform/examples/kubernetes/gitlab-docker-build on MicroK8s  Kubernetes cluster running on c2d-ks1 using GitLab Runner running in the cluster. In this project the GitLab Runner is installed in the namespace nja where the nj “helloworld” application is running.

Overview

Create Kubernetes cluster

Create local Kubernetes cluster on c2d-ks.

Install GitLab Runner

In this project Shared Runners are of course turned off. The stages / jobs defined in .gitlab-ci.yml  in this project will be delegated to Kubernetes running locally which we can do by installing a GitLab Runner inside the cluster.

Run pipeline

Navigate to gitlab-docker-build pipelines  and select Run pipeline to run the pipeline and create and release a Docker image.

The following jobs are defined:

  • Build: Builds the Docker image for the application
  • Prepare: Prepares the environment for the pipeline
  • Create release: Creates a release for the application (manual)
  • Push latest: Pushes the Docker image with the latest tag to the registry
  • Push tag: Pushes the Docker image with the tag name to the registry
  • deploy: Deploys the application to production (manual)
  • Test: Runs automated tests on the application
  • sast: Runs security tests on the application



Laatst gewijzigd 2024.11.11: nl gitlab projects (8ef2e3d)