Giter VIP home page Giter VIP logo

golang-argocd-template-generator's Introduction

ArgoCD-Tekton - Template Generator

Intro

This tool will generate all the necessary yaml files and folders for a project with multiple microservices.

It is meant to do the basic scaffolding and inject the relevant data as needed.

The are a couple of caveats

  • The files generated cannot be back engineered, i.e if changes are made to the generated files, and the genrator app is re-run, it will override all changes made.
  • Files that contain ENVARS need to be updated manually, it really is extremely difficult to create custom envars per project per microservice.

CICD folder structure

The folder structure is as follows :

./generated
      |
      --- <project-name>
                |
                --- environments
                |       |
                |       --- overlays
                |               |
                |               --- cicd
                |               |     |
                |               |     --- kustermization.yaml
                |               |
                |               --- dev
                |               |     |
                |               |     |
                |               |     --- namespace
                |               |     |     |
                |               |     |     --- limit-range.yaml
                |               |     |         namespace.yaml
                |               |     |         resource-quota.yaml
                |               |     |         servis-account-role-binding.yaml
                |               |     |
                |               |     --- kustermization.yaml
                |               |
                |               --- uat (same structure as dev)
                |               |
                |               --- prd (same structure as dev)
                |
                --- manifests
                      |
                      --- apps
                      |     |
                      |     --- microservice-A
                      |     |         |
                      |     |         --- base
                      |     |               |
                      |     |               --- deployment.yaml
                      |     |                   image-pull-secret.yaml
                      |     |                   route.yaml
                      |     |                   service.yaml
                      |     |                   service-account.yaml
                      |     |                   kustermization.yaml
                      |     |
                      |     --- microservice-B (same as microservice-A)
                      |     .
                      |     .
                      |     --- microservice-N (same as microservice-A)
                      |     |
                      |     --- namespace-cicd
                      |     |         |
                      |     |         --- base
                      |     |               |
                      |     |               --- limit-range.yaml
                      |     |                   namespace.yaml
                      |     |                   resource-quota.yaml
                      |     |                   kustermization.yaml
                      |     |
                      |     --- rbac
                      |           |
                      |           --- base
                      |                 |
                      |                 --- (list of user-rbac.yaml files)
                      |
                      --- tekton
                            |
                            --- pipelines
                            |       |
                            |       --- base
                            |             |
                            |             --- microservice-A-pipeline
                            |             |       |    
                            |             |       --- (list of pipeline files)
                            |             .
                            |             .
                            |             --- microservice-N-pipeline
                            |                     |    
                            |                     --- (list of pipeline files)
                            |
                            --- resources
                            |     |
                            |     --- base
                            |           |
                            |           --- git-http-seceret.yaml
                            |               notify-slack-webhook-seceret.yaml
                            |               pipeline-resource-git-http.yaml
                            |               pipeline-resource-git-infra-http.yaml
                            |               pipeline-role.yaml
                            |               smtp-auth.yaml
                            |               kustermization.yaml
                            |
                            --- tasks
                            |     |
                            |     --- base
                            |           |
                            |           --- patch-image.yaml
                            |               promote-image.yaml
                            |               veracode-scanner.yaml
                            |               kustermization.yaml
                            |
                            --- tools
                                  |
                                  --- base
                                        |
                                        --- argocd-appproject.yaml
                                            argocd-apps-cicd.yaml
                                            argocd-apps-dev.yaml
                                            argocd-apps-uat.yaml
                                            argocd-apps-prd.yaml

Usage

Config

Create a simple json file (config.json) - see the example-config.json file in this repo

So basically we are setting up the project name, defining the high level repo's, and telling the generator what microservices will be deployed in this app

Don't worry if you don't have all the microservices defined - its fairly easy to add to the current project.

N.B Remember that if you re-generate the templates any changes made in the genertated folder will be lots - so maybe keep a copy (backup) before re-generating

Steps Config

Use the example-steps.json file as is (you can create your own but leave this file intact its used to generate all yaml objects)

Build

Execute the following command in the directory where you have cloned this project (This assumes you have the golang sdk installed).

# for mac
env GOOS=darwin GOARCH=amd64 go build -o /build/generate

# for linux
env GOOS=linux GOARCH=amd64 go build -o /build/generate

Execute

Execute the following command once you have built the executable

./build/generate -c config.json -s steps.json -l debug

All the templates will be generated in the generated folder

Customization

NB

You can change any generated file as you see fit. As mentioned before if you re-generate all changes will be lost. So backup changes before re-generating

Basic customization

The main files to customize will be

  • ./generated//manifests/tekton/pipelines//base/pipeline-dev.yaml (pipeline flow, programming language base image etc)

There is another utility called merge-yaml.go, the generator will create a directory called current/ (for each app) Copy any current deployment yaml files that you have i,e

oc get deployment xyz -o yaml > current<app-name>/deployment.yaml

Optional

The merge function will take what is in the folder (current) and iterate through each yaml file and merge it with the generated deploy.yaml

golang-argocd-template-generator's People

Contributors

luigizuccarelli avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.