Name | make-argocd-fly JSON |
Version |
0.0.34
JSON |
| download |
home_page | None |
Summary | A project to generate ArgoCD application resources |
upload_time | 2024-03-27 22:19:25 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | GPLv3+ |
keywords |
argocd
kustomize
jinja2
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## Description
`make-argocd-fly` is a tool to generate Kubernetes manifests that can be deployed with ArgoCD in a multi cluster environments. It makes it easier to develop and maintain ArgoCD applications by providing a way to render Jinja2 and Kustomize files, run yaml and kube linters and automatically generate ArgoCD `Application` resources.
The idea is that you write your resources in YAML, Jinja2 or Kustomize (including helmCharts), write a configuration file that describes where to deploy them and then run `make-argocd-fly` to generate the final manifests. This way it is transparent what is being deployed and where, it is easier to maintain and develop the resources and it is easier to debug them.
## Features
- Jinja2 and Kustomize rendering
- ArgoCD `Application` resources are generated automatically
- `App-of-apps` pattern is natively supported
- Use `include` or `include_raw` in Jinja2 templates to render content of external files
- Global, per environment and per application Jinja2 variables
- Source resources can reside in subdirectories
## Usage
```
python3 -m venv .venv
. .venv/bin/activate
pip install make-argocd-fly
make-argocd-fly -h
usage: main.py [-h] [--root-dir ROOT_DIR] [--config-file CONFIG_FILE] [--render-apps RENDER_APPS] [--render-envs RENDER_ENVS] [--skip-generate] [--preserve-tmp-dir] [--yaml-linter] [--kube-linter]
[--loglevel LOGLEVEL]
Render ArgoCD Applications.
options:
-h, --help show this help message and exit
--root-dir ROOT_DIR Root directory
--config-file CONFIG_FILE
Configuration file
--render-apps RENDER_APPS
Comma separate list of applications to render
--render-envs RENDER_ENVS
Comma separate list of environments to render
--skip-generate Skip resource generation
--preserve-tmp-dir Preserve temporary directory
--yaml-linter Run yamllint against output directory (https://github.com/adrienverge/yamllint)
--kube-linter Run kube-linter against output directory (https://github.com/stackrox/kube-linter)
--loglevel LOGLEVEL DEBUG, INFO, WARNING, ERROR, CRITICAL
```
## Configuration
### config.yml
Example:
```
source_dir: source
output_dir: output
tmp_dir: .tmp
envs:
dev:
apps:
bootstrap: {}
extra_app_deployer: {app_deployer: bootstrap, project: default, destination_namespace: namespace_1}
app_1:
app_deployer: bootstrap
project: default
destination_namespace: namespace_1
vars:
argocd:
target_revision: custom_branch
subdirectory/app_2: {app_deployer: extra_app_deployer, project: default, destination_namespace: namespace_2}
vars:
argocd:
api_server: dev-api-server
var_3: value_X
prod:
apps:
app_1: {app_deployer: bootstrap, project: default, destination_namespace: namespace_1}
vars:
argocd:
api_server: prod-api-server
vars:
argocd:
namespace: argocd
repo_url: https://example.com/repo.git
target_revision: HEAD
sync_policy:
automated:
selfHeal: true
prune: true
allowEmpty: true
# https://www.arthurkoziel.com/fixing-argocd-crd-too-long-error/
syncOptions:
- ServerSideApply=true
finalizers:
- resources-finalizer.argocd.argoproj.io
var_1:
var_2: value_2
var_3: value_3
```
With this configuration file you can have kustomize overlays for `dev/prod` and use jinja2 variables like `{{ var_1.var_2 }} and {{ var_3 }}` in your source files.
### app parameters
- `app_deployer` - name of the application that will deploy this application
- `project` - ArgoCD project name
- `destination_namespace` - namespace where the application will be deployed
- `app_deployer_env` - (OPTIONAL) environment of the application that will deploy this application
- `vars` - (OPTIONAL) application specific jinja2 variables
## Jinja2 extensions
To render a template in the current jinja2 template, use the following block:
```
{%- filter indent(width=4) %}
{% include 'app_4/files/file.json.j2' %}
{% endfilter %}
```
To include file content in the current jinja2 template, use the following block:
```
{%- filter indent(width=4) %}
{% include_raw 'app_4/files/file.json' %}
{% endfilter %}
```
To perform a DNS lookup, use the following filter:
```
{{ 'example.com' | dig }}
```
Ansible filters are supported as well: https://pypi.org/project/jinja2-ansible-filters/
## Caveats
### Requirements
- `kustomize` and `helm` are expected to be installed locally.
- `kube-linter` is expected to be installed locally (https://github.com/stackrox/kube-linter).
- `libyaml` is expected to be installed locally for speeding up YAMLs generation.
- Comments are not rendered in the final output manifests.
### Currently supported directory structure
```
repo
source
(subdirectory/)app_1
base
yaml.yml(.j2)
kustomization.yml(.j2)
dev
yaml.yml(.j2)
kustomization.yml(.j2)
prod
yaml.yml(.j2)
kustomization.yml(.j2)
(subdirectory/)app_2
yaml.yml(.j2)
kustomization.yml(.j2)
(subdirectory/)app_3
yaml.yml(.j2)
(subdirectory/)app_4
yaml.yml(.j2)
files
file.json(.j2)
```
When kustomization overlays are used, kustomization base directory shall be named `base`, overlay directories shall be named after the corresponding environments names.
### kustomization.yml
Files referenced in the `resources` section shall be named after Kubernetes resource type + `_` + resource name. Example:
```
resources:
- Deployment_nginx.yml
- ServiceAccount_nginx-prod.yml
```
### Initial app-of-apps application
`bootstrap` application shall be deployed externally
### Variable names
The folloving variable names are reserved:
- __application
### Expected variables
The folloving variables are expected to be present:
- argocd.api_server
- argocd.namespace
- argocd.repo_url
- argocd.target_revision
### Optional variables
- argocd.sync_policy
- argocd.finalizers
- argocd.ignoreDifferences
## For developers
### Build instructions
https://setuptools.pypa.io/en/latest/userguide/quickstart.html
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
https://setuptools.pypa.io/en/latest/userguide/datafiles.html
https://packaging.python.org/en/latest/tutorials/packaging-projects/
https://packaging.python.org/en/latest/guides/single-sourcing-package-version/#single-sourcing-the-version
https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
### Preparation
```
python -m venv .venv
. .venv/bin/activate
python3 -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev_requirements.txt
```
### Execution
```
python main.py --root-dir <path>
```
### Packaging
```
<tag HEAD>
python -m build
python -m twine upload dist/*
```
### Profiling
```
python -m cProfile -o profile.pstats main.py --root-dir <path>
gprof2dot log.pstats [-z <function>] | dot -Tsvg -o profile.svg
```
Raw data
{
"_id": null,
"home_page": null,
"name": "make-argocd-fly",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "argocd, kustomize, jinja2",
"author": null,
"author_email": "Andrei Lapin <karandash8@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/5c/a2/e6fa1e128e4e711dd1f170f4e22bfc0b141384df24109ec841f7b2e76141/make-argocd-fly-0.0.34.tar.gz",
"platform": null,
"description": "## Description\n`make-argocd-fly` is a tool to generate Kubernetes manifests that can be deployed with ArgoCD in a multi cluster environments. It makes it easier to develop and maintain ArgoCD applications by providing a way to render Jinja2 and Kustomize files, run yaml and kube linters and automatically generate ArgoCD `Application` resources.\n\nThe idea is that you write your resources in YAML, Jinja2 or Kustomize (including helmCharts), write a configuration file that describes where to deploy them and then run `make-argocd-fly` to generate the final manifests. This way it is transparent what is being deployed and where, it is easier to maintain and develop the resources and it is easier to debug them.\n\n## Features\n- Jinja2 and Kustomize rendering\n- ArgoCD `Application` resources are generated automatically\n- `App-of-apps` pattern is natively supported\n- Use `include` or `include_raw` in Jinja2 templates to render content of external files\n- Global, per environment and per application Jinja2 variables\n- Source resources can reside in subdirectories\n\n## Usage\n```\npython3 -m venv .venv\n. .venv/bin/activate\npip install make-argocd-fly\n\nmake-argocd-fly -h\nusage: main.py [-h] [--root-dir ROOT_DIR] [--config-file CONFIG_FILE] [--render-apps RENDER_APPS] [--render-envs RENDER_ENVS] [--skip-generate] [--preserve-tmp-dir] [--yaml-linter] [--kube-linter]\n [--loglevel LOGLEVEL]\n\nRender ArgoCD Applications.\n\noptions:\n -h, --help show this help message and exit\n --root-dir ROOT_DIR Root directory\n --config-file CONFIG_FILE\n Configuration file\n --render-apps RENDER_APPS\n Comma separate list of applications to render\n --render-envs RENDER_ENVS\n Comma separate list of environments to render\n --skip-generate Skip resource generation\n --preserve-tmp-dir Preserve temporary directory\n --yaml-linter Run yamllint against output directory (https://github.com/adrienverge/yamllint)\n --kube-linter Run kube-linter against output directory (https://github.com/stackrox/kube-linter)\n --loglevel LOGLEVEL DEBUG, INFO, WARNING, ERROR, CRITICAL\n```\n\n## Configuration\n### config.yml\nExample:\n```\nsource_dir: source\noutput_dir: output\ntmp_dir: .tmp\n\nenvs:\n dev:\n apps:\n bootstrap: {}\n extra_app_deployer: {app_deployer: bootstrap, project: default, destination_namespace: namespace_1}\n app_1:\n app_deployer: bootstrap\n project: default\n destination_namespace: namespace_1\n vars:\n argocd:\n target_revision: custom_branch\n subdirectory/app_2: {app_deployer: extra_app_deployer, project: default, destination_namespace: namespace_2}\n vars:\n argocd:\n api_server: dev-api-server\n var_3: value_X\n prod:\n apps:\n app_1: {app_deployer: bootstrap, project: default, destination_namespace: namespace_1}\n vars:\n argocd:\n api_server: prod-api-server\nvars:\n argocd:\n namespace: argocd\n repo_url: https://example.com/repo.git\n target_revision: HEAD\n sync_policy:\n automated:\n selfHeal: true\n prune: true\n allowEmpty: true\n # https://www.arthurkoziel.com/fixing-argocd-crd-too-long-error/\n syncOptions:\n - ServerSideApply=true\n finalizers:\n - resources-finalizer.argocd.argoproj.io\n var_1:\n var_2: value_2\n var_3: value_3\n```\n\nWith this configuration file you can have kustomize overlays for `dev/prod` and use jinja2 variables like `{{ var_1.var_2 }} and {{ var_3 }}` in your source files.\n\n### app parameters\n- `app_deployer` - name of the application that will deploy this application\n- `project` - ArgoCD project name\n- `destination_namespace` - namespace where the application will be deployed\n- `app_deployer_env` - (OPTIONAL) environment of the application that will deploy this application\n- `vars` - (OPTIONAL) application specific jinja2 variables\n\n## Jinja2 extensions\nTo render a template in the current jinja2 template, use the following block:\n\n```\n{%- filter indent(width=4) %}\n{% include 'app_4/files/file.json.j2' %}\n{% endfilter %}\n```\n\nTo include file content in the current jinja2 template, use the following block:\n\n```\n{%- filter indent(width=4) %}\n{% include_raw 'app_4/files/file.json' %}\n{% endfilter %}\n```\n\nTo perform a DNS lookup, use the following filter:\n\n```\n{{ 'example.com' | dig }}\n```\n\nAnsible filters are supported as well: https://pypi.org/project/jinja2-ansible-filters/\n\n## Caveats\n### Requirements\n- `kustomize` and `helm` are expected to be installed locally.\n- `kube-linter` is expected to be installed locally (https://github.com/stackrox/kube-linter).\n- `libyaml` is expected to be installed locally for speeding up YAMLs generation.\n- Comments are not rendered in the final output manifests.\n\n### Currently supported directory structure\n```\nrepo\n source\n (subdirectory/)app_1\n base\n yaml.yml(.j2)\n kustomization.yml(.j2)\n dev\n yaml.yml(.j2)\n kustomization.yml(.j2)\n prod\n yaml.yml(.j2)\n kustomization.yml(.j2)\n (subdirectory/)app_2\n yaml.yml(.j2)\n kustomization.yml(.j2)\n (subdirectory/)app_3\n yaml.yml(.j2)\n (subdirectory/)app_4\n yaml.yml(.j2)\n files\n file.json(.j2)\n```\n\nWhen kustomization overlays are used, kustomization base directory shall be named `base`, overlay directories shall be named after the corresponding environments names.\n\n### kustomization.yml\nFiles referenced in the `resources` section shall be named after Kubernetes resource type + `_` + resource name. Example:\n\n```\nresources:\n - Deployment_nginx.yml\n - ServiceAccount_nginx-prod.yml\n```\n### Initial app-of-apps application\n`bootstrap` application shall be deployed externally\n\n### Variable names\nThe folloving variable names are reserved:\n- __application\n\n### Expected variables\nThe folloving variables are expected to be present:\n- argocd.api_server\n- argocd.namespace\n- argocd.repo_url\n- argocd.target_revision\n\n### Optional variables\n- argocd.sync_policy\n- argocd.finalizers\n- argocd.ignoreDifferences\n\n## For developers\n### Build instructions\nhttps://setuptools.pypa.io/en/latest/userguide/quickstart.html\nhttps://setuptools.pypa.io/en/latest/userguide/pyproject_config.html\nhttps://setuptools.pypa.io/en/latest/userguide/datafiles.html\nhttps://packaging.python.org/en/latest/tutorials/packaging-projects/\nhttps://packaging.python.org/en/latest/guides/single-sourcing-package-version/#single-sourcing-the-version\nhttps://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/\n\n### Preparation\n```\npython -m venv .venv\n. .venv/bin/activate\npython3 -m pip install --upgrade pip\npip install -r requirements.txt\npip install -r dev_requirements.txt\n```\n\n### Execution\n```\npython main.py --root-dir <path>\n```\n\n### Packaging\n```\n<tag HEAD>\npython -m build\npython -m twine upload dist/*\n```\n\n### Profiling\n```\npython -m cProfile -o profile.pstats main.py --root-dir <path>\ngprof2dot log.pstats [-z <function>] | dot -Tsvg -o profile.svg\n```\n",
"bugtrack_url": null,
"license": "GPLv3+",
"summary": "A project to generate ArgoCD application resources",
"version": "0.0.34",
"project_urls": null,
"split_keywords": [
"argocd",
" kustomize",
" jinja2"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7b1338c898028a80b3ccd61c74d2d6c8d2c50daa4f5a30b13ea92b13b102c012",
"md5": "2f9d2d3be976a139da648c6398a51604",
"sha256": "b3e6cd2921dbc1b413eb8210e305f9f801e2a9bd511e0dfff313079732119798"
},
"downloads": -1,
"filename": "make_argocd_fly-0.0.34-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2f9d2d3be976a139da648c6398a51604",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 55437,
"upload_time": "2024-03-27T22:19:24",
"upload_time_iso_8601": "2024-03-27T22:19:24.072440Z",
"url": "https://files.pythonhosted.org/packages/7b/13/38c898028a80b3ccd61c74d2d6c8d2c50daa4f5a30b13ea92b13b102c012/make_argocd_fly-0.0.34-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5ca2e6fa1e128e4e711dd1f170f4e22bfc0b141384df24109ec841f7b2e76141",
"md5": "3b3dce2478c38c836c06f478594411a3",
"sha256": "7224087fae076eacfac027e1f5160920b10c25fbecae13c1df0c6bedf0bf5acf"
},
"downloads": -1,
"filename": "make-argocd-fly-0.0.34.tar.gz",
"has_sig": false,
"md5_digest": "3b3dce2478c38c836c06f478594411a3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 38278,
"upload_time": "2024-03-27T22:19:25",
"upload_time_iso_8601": "2024-03-27T22:19:25.911638Z",
"url": "https://files.pythonhosted.org/packages/5c/a2/e6fa1e128e4e711dd1f170f4e22bfc0b141384df24109ec841f7b2e76141/make-argocd-fly-0.0.34.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 22:19:25",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "make-argocd-fly"
}