A code that is never executed for users is essentially a digital waste product. To prevent this building of waste and to showcase the results of code on the Kubernetes environment, we can use the CI Dashboard, along with chaos testing.
The CI dashboard allows users to view the commit and release-based build and run a chaos test using litmus on a different platform with different versions of Kubernetes.
In this tutorial, we’ll go through all the necessary steps for setting up the CI dashboard:
- Create a project
- Push the code to GitHub
- Setup the CI of the project using Gitlab
- Select the chaos test from Litmus
- Add the script in Gitlab YAML to create pipelines for executing the chaos tests
- Build a CI dashboard(ex: openebs.ci ) to display the gitlab pipeline history and status
Step 1: Create a project
First, create a project and write some automated testing for it. You should also add the Dockerfile in the project to set up the CI.
Step 2: Put the codes on GitHub
Create a repository on GitHub and add a .gitignore file to ignore the auto-generated folder or file. Follow the script below to put changes into GitHub.
$ git init $ git add . $ git commit -s -m "Initial commit" $ git remote add origin <origin_url>.git $ git push origin master
Step 3: Setup the CI using gitlab
Add a .gitlab.yaml file to project and write the build and test steps.
(Ex: https://github.com/openebs/maya/blob/master/.gitlab-ci.yml). Import the project in gitlab from GitHub. Setup the gitlab pipeline environment variable to push the docker image, or any other, if required. Add the pipeline trigger command in .gitlab.yaml file.
Step 4: Selection of chaos test
Select the chaos test (litmus book) from the litmus repository or write your own litmus book if needed. This will be used to test the product performance on different Kubernetes versions and with different cloud vendors.
Step 5: Add script in gitlab.yaml
Create a repository for the execution of the platform-based pipeline. Add .gitlab.yaml file and related script to create a cluster, or use the executing cluster and run the different chaos tests in various stages of the pipeline.
Reference the .gitlab.yaml file
cleanup-packet: when: always image: chandankumar4/packet:v4 dependencies: - packet-cluster stage: CLUSTER-CLEANUP script: - chmod 755 ./script/packet-cleanup - ./script/packet-cleanup
Step 6: Build a CI dashboard
Create a project called Ci dashboard backend that will fetch the pipeline details from gitlab by accessing their API and exposing the same on different API after some enhancement. Create another project called Ci dashboard that will display the gitlab pipeline details by accessing the data from the back end API.
Step 7: Conclusion
CI dashboard will display the build history of the imported project and analyze the performance on different platforms and versions of Kubernetes.
OpenEBS CI Dashboard backend using Go and PostgreSQL. — openebs/ci-e2e-dashboard-go-backendgithub.comopenebs/maya
OpenEBS Maya extends Kubernetes capabilities to orchestrate CAS containers. — openebs/mayagithub.com