{"id":17927172,"url":"https://github.com/kostis-codefresh/gitops-environment-promotion","last_synced_at":"2026-02-02T00:03:47.389Z","repository":{"id":45861148,"uuid":"468356214","full_name":"kostis-codefresh/gitops-environment-promotion","owner":"kostis-codefresh","description":"Example for promoting a release between different GitOps environments","archived":false,"fork":false,"pushed_at":"2022-12-15T12:28:47.000Z","size":18,"stargazers_count":312,"open_issues_count":1,"forks_count":147,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-19T07:58:28.180Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codefresh.io/about-gitops/how-to-model-your-gitops-environments-and-promote-releases-between-them/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kostis-codefresh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-10T13:34:20.000Z","updated_at":"2025-06-19T06:55:26.000Z","dependencies_parsed_at":"2022-09-12T03:10:52.825Z","dependency_job_id":null,"html_url":"https://github.com/kostis-codefresh/gitops-environment-promotion","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kostis-codefresh/gitops-environment-promotion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kostis-codefresh%2Fgitops-environment-promotion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kostis-codefresh%2Fgitops-environment-promotion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kostis-codefresh%2Fgitops-environment-promotion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kostis-codefresh%2Fgitops-environment-promotion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kostis-codefresh","download_url":"https://codeload.github.com/kostis-codefresh/gitops-environment-promotion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kostis-codefresh%2Fgitops-environment-promotion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28996568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T23:10:54.274Z","status":"ssl_error","status_checked_at":"2026-02-01T23:10:47.298Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T21:01:03.573Z","updated_at":"2026-02-02T00:03:47.372Z","avatar_url":"https://github.com/kostis-codefresh.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to Model Your Gitops Environments\n\nThis is an example on how to model Kustomize folders for a GitOps application and promote releases\nbetween environments.\n\nRead the [full blog post](https://codefresh.io/about-gitops/how-to-model-your-gitops-environments-and-promote-releases-between-them/). You might want to see the [application source code as well](https://github.com/kostis-codefresh/gitops-promotion-source-code).\n\n## Folder structure\n\nThe base directory holds configuration which is common to all environments. It is not expected to change often. If you want to do changes to multiple environments at the same time it is best to use the “variants” folder.\n\nThe variants folder (a.k.a mixins, a.k.a. components) holds common characteristics between environments. It is up to you to define what exactly you think is “common” between your environments after researching your application as discussed in the previous section.\n\nIn the example application, we have variants for all prod and non-prod environments and also the regions. Here is an example of the prod variant that applies to ALL production environments.\n\n```yaml\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: simple-deployment\nspec:\n  template:\n    spec:\n      containers:\n      - name: webserver-simple\n        env:\n        - name: ENV_TYPE\n          value: \"production\"\n        - name: PAYPAL_URL\n          value: \"production.paypal.com\"   \n        - name: DB_USER\n          value: \"prod_username\"\n        - name: DB_PASSWORD\n          value: \"prod_password\"                     \n        livenessProbe:\n          httpGet:\n            path: /health\n            port: 8080\n```\n\nIn the example above we make sure that all production environments are using the production DB credentials, the production payment gateway and a liveness probe. These settings belong to the set of configuration that we don’t expect to promote between environments but we assume that they will be static across the application lifecycle.\n\nWith the base and variants ready we can now define every final environment with a combination of those properties.\n\nHere is an example of the staging ASIA environment:\n\n```yaml\napiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\n\nnamespace: staging\nnamePrefix: staging-asia-\n\nresources:\n- ../../base\n\ncomponents:\n  - ../../variants/non-prod\n  - ../../variants/asia\n\npatchesStrategicMerge:\n- deployment.yml\n- version.yml\n- replicas.yml\n- settings.yml\n```\n\nFirst we define some common properties. We inherit all configuration from base, from non-prod environments and for all environments in Asia.\n\nThe key point here is the patches that we apply. The version.yml and replicas.yml are self-explanatory. They only define the image and replicas on their own and nothing else.\n\nThe version.yml file (which is the most important thing to promote between environments) defines only the image of the application and nothing else.\n\n```yaml\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: simple-deployment\nspec:\n  template:\n    spec:\n      containers:\n      - name: webserver-simple\n        image: docker.io/kostiscodefresh/simple-env-app:2.0\n```\n\nThe associated settings for each release that we DO expect to promote between environments are also defined in settings.yml \n\n```yaml\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: simple-deployment\nspec:\n  template:\n    spec:\n      containers:\n      - name: webserver-simple\n        env:\n        - name: UI_THEME\n          value: \"dark\"\n        - name: CACHE_SIZE\n          value: \"1024kb\"\n        - name: PAGE_LIMIT\n          value: \"25\"\n        - name: SORTING\n          value: \"ascending\"    \n        - name: N_BUCKETS\n          value: \"42\"         \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkostis-codefresh%2Fgitops-environment-promotion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkostis-codefresh%2Fgitops-environment-promotion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkostis-codefresh%2Fgitops-environment-promotion/lists"}