Skip to content

KyriakosTsalia/pod-info-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pod Info Application for the Pure GitOps project

Summary

This is a simple Go web application that exposes the main information about the pod it is running on. This repository is complementary to pure-gitops and contains the application source code, the Dockerfile and the .gitlab-ci.yml file.
The CI pipeline consists of four stages, each with a single job: build, package, test and deploy:

  • In the build stage, the Go executable is built using a Makefile that first formats and vets the code. Additionally, it substitutes an environment variable in the main.html file that represents the app version. This variable is inside an h1 tag that is hidden and only used for testing. The app version is unique and is a combination of GitLab's CI_PIPELINE_IID and CI_COMMIT_SHORT_SHA predefined variables.
  • In the package stage, the docker image is created, tagged using the CI_REGISTRY_IMAGE predefined variable and pushed to the project's container registry.
  • In the testing stage, using GitLab services, the image is tested locally inside the GitLab runner. The integration test is a simple grep on the app version.
  • In the deploy stage, which is only executed in the main/default branch, the manifest repository is first cloned, a new branch is created, then the new application image is substituted in the manifests/deployment.yaml file and finally a merge request is created. For this to work, and assuming the repositories are private/internal, the manifest repository should have the application repository included in its allowlist, so that the CI_JOB_TOKEN has the required read_repository permission. Moreover, a GitLab Personal Access Token is necessary for GitLab authentication in the merge creation step.

For the pipeline to work, four GitLab CI/CD variables must be configured in the project's settings: PERSONAL_ACCESS_TOKEN, TARGET_REPO_DEFAULT_BRANCH, TARGET_REPO_NAMESPACE and TARGET_REPO_PROJECT.

Some assumptions for the repository are that the default branch is protected (any new features are added using the "feature branch" workflow) and, when merging, fast-forward merges are created, source branches are deleted, commits are squashed and pipelines must be successful.


License

Copyright © 2023 Kyriakos Tsaliagkos

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

About

Go web application for the pure-gitops project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published