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:
- Set up a GitLab Server:
- Install and configure a GitLab server on your local machine or use GitLab.com.
- Create a New Project in GitLab:
- Create a new project repository in GitLab.
- Clone the Repository:
- Clone the repository https://github.com/docker/docker-gs-ping into your GitLab project.
- Set up a GitLab Runner:
- Install and configure a GitLab Runner that can execute CI jobs for your project.
- 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.
- 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.
- 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.
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- Configure the Docker daemon to serve metrics https://docs.docker.com/engine/daemon/prometheus/
- docker-compose file contents
Copy the .env file.
cp .env.example .envLaunch the stack
docker compose up -dReceive the root password from Gitlab container
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password- 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]
- Edit
- 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"- Added pipeline config
# .gitlab-ci.yml- Added metrics endpoint
- In Gitlab project trigger the pipeline
- Login to Gitlab container registry
docker login gitlab:5050 - Launch the app
docker compose --profile app up -d - Access Dashboard on http://grafana:3000/
- Login with admin/admin
Any assumptions, limitations, and potential 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