Skip to content

Latest commit

 

History

History
140 lines (122 loc) · 4.08 KB

File metadata and controls

140 lines (122 loc) · 4.08 KB

DEVOPS Assignment

You are required to set up a GitLab server, create a CI/CD pipeline to build and push a Docker image, and set up monitoring. Steps:

  1. Set up a GitLab Server:
    • Install and configure a GitLab server on your local machine or use GitLab.com.
  2. Create a New Project in GitLab:
    • Create a new project repository in GitLab.
  3. Clone the Repository:
  4. Set up a GitLab Runner:
    • Install and configure a GitLab Runner that can execute CI jobs for your project.
  5. CI/CD Pipeline - Write a CI job which:
    • Builds the container image from the Dockerfile.multistage.
    • Pushes the built image to the GitLab container registry.
  6. Monitoring:
    • Set up monitoring using Prometheus and Grafana to visualize the health and performance of the application.
    • Create dashboards to monitor key metrics such as CPU usage, memory usage, and request rates.
  7. Documentation - Provide a README file with:
    • Instructions on how to set up the GitLab server and runner.
    • Steps to clone the repository and configure the CI/CD pipeline.
    • Details on how to access and interpret the monitoring dashboards.
    • Any assumptions, limitations, and potential improvements.

Solution

The gitlab url will be gitlab. For simplicity, place this line in your hosts file

127.0.0.1   gitlab
127.0.0.1   prometheus
127.0.0.1   grafana

Setup of the Gitlab Server and Runner

Copy the .env file.

cp .env.example .env

Launch the stack

docker compose up -d

Receive the root password from Gitlab container

docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

Configure Gitlab

  • login with root user
  • To import ping repo from Github
    • Admin -> Settings -> Import and export settings -> Import sources -> Github
  • Configure Runner
    • CI/CD -> Runners -> Create instance runner
    • copy token and paste to .env
    • register runner
    docker compose run --rm register-runner
    • grant gitlab-runner jobs access to docker daemon
      • Edit data/gitlab-runner/config/config.toml
      • Add line to [runners.docker]

Create Project

  • Plus -> Create new project
  • Clone the GitHub repo
git clone https://github.com/docker/docker-gs-ping
  • Add your GitLab repo as a new remote to the cloned local repo:
git remote set-url origin https://gitlab/root/docker-gs-ping.git
  • Rebase main on remote main and push
git pull origin main --rebase
git push -u origin main
  • Don't verify SSL certificates for this exercise
git config http.sslVerify "false"

Adapt Ping App

  • Added pipeline config
# .gitlab-ci.yml
  • Added metrics endpoint

Build and launch

  • In Gitlab project trigger the pipeline
  • Login to Gitlab container registry
docker login gitlab:5050 
  • Launch the app
docker compose --profile app up -d 

Monitoring in Grafana

Any assumptions, limitations, and potential improvements.

Improvements

  • Run in K8s cluster
  • Deploy app from pipeline
  • Ingress controller
  • Alerts, Incident detection
  • Log shipping
  • request tracing
  • Check against company standards and policies
  • retention policies for timeseries data, docker images, logs
  • backup and restore process
  • target hardware managed by infrastructure as code
  • deploy with GitOps approach
  • Pipeline branch management
  • Continuous Deployment
  • Issue valid certificates
  • Security!
    • Firewall rules on hosts
    • secure store for authentication credentials
  • SSO for all services
  • decentralized data storage
  • Continuous profiling