nyl 0.9.4__tar.gz → 0.10.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. nyl-0.10.0/.changelog/0.10.0.toml +31 -0
  2. {nyl-0.9.4 → nyl-0.10.0}/.github/workflows/docker.yaml +18 -6
  3. {nyl-0.9.4 → nyl-0.10.0}/.github/workflows/python.yaml +1 -1
  4. {nyl-0.9.4 → nyl-0.10.0}/PKG-INFO +1 -1
  5. {nyl-0.9.4 → nyl-0.10.0}/argocd-cmp/Dockerfile +4 -3
  6. {nyl-0.9.4 → nyl-0.10.0}/argocd-cmp/plugin.yaml +12 -2
  7. {nyl-0.9.4 → nyl-0.10.0}/docs/content/changelog.md +21 -1
  8. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/argocd-plugin.md +77 -2
  9. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/configuration/environment.md +10 -0
  10. {nyl-0.9.4 → nyl-0.10.0}/pyproject.toml +2 -1
  11. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/__init__.py +13 -10
  12. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/template.py +1 -2
  13. nyl-0.10.0/src/nyl/daemon.py +339 -0
  14. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/profiles/__init__.py +20 -12
  15. {nyl-0.9.4 → nyl-0.10.0}/uv.lock +1 -2
  16. nyl-0.9.4/src/nyl/commands/argocd.py +0 -37
  17. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.7.0.toml +0 -0
  18. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.7.1.toml +0 -0
  19. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.7.2.toml +0 -0
  20. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.8.0.toml +0 -0
  21. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.8.1.toml +0 -0
  22. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.9.0.toml +0 -0
  23. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.9.1.toml +0 -0
  24. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.9.2.toml +0 -0
  25. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.9.3.toml +0 -0
  26. {nyl-0.9.4 → nyl-0.10.0}/.changelog/0.9.4.toml +0 -0
  27. {nyl-0.9.4 → nyl-0.10.0}/.envrc +0 -0
  28. {nyl-0.9.4 → nyl-0.10.0}/.github/workflows/docs.yaml +0 -0
  29. {nyl-0.9.4 → nyl-0.10.0}/.github/workflows/update-flake-lock.yaml +0 -0
  30. {nyl-0.9.4 → nyl-0.10.0}/.gitignore +0 -0
  31. {nyl-0.9.4 → nyl-0.10.0}/DEPRECATION_NOTICE.md +0 -0
  32. {nyl-0.9.4 → nyl-0.10.0}/README.md +0 -0
  33. {nyl-0.9.4 → nyl-0.10.0}/argocd-cmp/README.md +0 -0
  34. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/.envrc +0 -0
  35. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/.secrets.yaml +0 -0
  36. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/.sops.yaml +0 -0
  37. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/README.md +0 -0
  38. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/argocd.yaml +0 -0
  39. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/nyl-project.yaml +0 -0
  40. {nyl-0.9.4 → nyl-0.10.0}/argocd-with-nyl/nyl-secrets.yaml +0 -0
  41. {nyl-0.9.4 → nyl-0.10.0}/docs/content/index.md +0 -0
  42. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/applysets.md +0 -0
  43. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/cluster-connectivity.md +0 -0
  44. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/configuration/profiles.md +0 -0
  45. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/configuration/projects.md +0 -0
  46. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/configuration/secrets.md +0 -0
  47. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/configuration-api/profiles.md +0 -0
  48. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/configuration-api/secrets.md +0 -0
  49. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/glossary.md +0 -0
  50. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/basics.md +0 -0
  51. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/components.md +0 -0
  52. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/inlining/helmcharts.md +0 -0
  53. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/inlining/overview.md +0 -0
  54. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/inlining/postprocessor.md +0 -0
  55. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/locals.md +0 -0
  56. {nyl-0.9.4 → nyl-0.10.0}/docs/content/reference/templating/secrets.md +0 -0
  57. {nyl-0.9.4 → nyl-0.10.0}/docs/mkdocs.yml +0 -0
  58. {nyl-0.9.4 → nyl-0.10.0}/docs/pyproject.toml +0 -0
  59. {nyl-0.9.4 → nyl-0.10.0}/docs/uv.lock +0 -0
  60. {nyl-0.9.4 → nyl-0.10.0}/example/manifests/postgres.yaml +0 -0
  61. {nyl-0.9.4 → nyl-0.10.0}/example/nyl-profiles.toml +0 -0
  62. {nyl-0.9.4 → nyl-0.10.0}/example/nyl-profiles.yaml +0 -0
  63. {nyl-0.9.4 → nyl-0.10.0}/example/nyl-secrets.yaml +0 -0
  64. {nyl-0.9.4 → nyl-0.10.0}/example/secrets.yaml +0 -0
  65. {nyl-0.9.4 → nyl-0.10.0}/flake.lock +0 -0
  66. {nyl-0.9.4 → nyl-0.10.0}/flake.nix +0 -0
  67. {nyl-0.9.4 → nyl-0.10.0}/nix/uv.nix +0 -0
  68. {nyl-0.9.4 → nyl-0.10.0}/renovate.json +0 -0
  69. {nyl-0.9.4 → nyl-0.10.0}/slap.toml +0 -0
  70. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/README.md +0 -0
  71. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/__init__.pyi +0 -0
  72. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/dynamic/__init__.pyi +0 -0
  73. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/dynamic/client.pyi +0 -0
  74. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/dynamic/discovery.pyi +0 -0
  75. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/dynamic/exceptions.pyi +0 -0
  76. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/dynamic/resource.pyi +0 -0
  77. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/watch/__init__.pyi +0 -0
  78. {nyl-0.9.4 → nyl-0.10.0}/src/kubernetes/watch/watch.pyi +0 -0
  79. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/__init__.py +0 -0
  80. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/add.py +0 -0
  81. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/crds.py +0 -0
  82. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/new.py +0 -0
  83. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/profile.py +0 -0
  84. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/run.py +0 -0
  85. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/secrets.py +0 -0
  86. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/tools/__init__.py +0 -0
  87. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/tools/bcrypt.py +0 -0
  88. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/tools/sops.py +0 -0
  89. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/commands/tun.py +0 -0
  90. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/__init__.py +0 -0
  91. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/components.py +0 -0
  92. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/dispatch.py +0 -0
  93. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/dispatch_test.py +0 -0
  94. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/helmchart.py +0 -0
  95. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/helmchart_test.py +0 -0
  96. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/generator/statefulsecret.py +0 -0
  97. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/profiles/config.py +0 -0
  98. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/profiles/config_test.py +0 -0
  99. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/profiles/kubeconfig.py +0 -0
  100. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/profiles/tunnel.py +0 -0
  101. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/project/config.py +0 -0
  102. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/__init__.py +0 -0
  103. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/applyset.py +0 -0
  104. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/applyset_test.py +0 -0
  105. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/helmchart.py +0 -0
  106. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/helmchart_test.py +0 -0
  107. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/placeholder.py +0 -0
  108. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/postprocessor.py +0 -0
  109. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/postprocessor_test.py +0 -0
  110. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/resources/statefulsecret.py +0 -0
  111. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/__init__.py +0 -0
  112. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/config.py +0 -0
  113. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/config_test.py +0 -0
  114. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/kubernetes.py +0 -0
  115. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/null.py +0 -0
  116. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/sops.py +0 -0
  117. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/secrets/sops_test.py +0 -0
  118. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/templating.py +0 -0
  119. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/templating_test.py +0 -0
  120. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/di.py +0 -0
  121. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/fs.py +0 -0
  122. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/fs_test.py +0 -0
  123. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/kubectl.py +0 -0
  124. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/kubernetes.py +0 -0
  125. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/kvstore.py +0 -0
  126. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/loads.py +0 -0
  127. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/logging.py +0 -0
  128. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/shell.py +0 -0
  129. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/testing.py +0 -0
  130. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/typer.py +0 -0
  131. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/types.py +0 -0
  132. {nyl-0.9.4 → nyl-0.10.0}/src/nyl/tools/yaml.py +0 -0
  133. {nyl-0.9.4 → nyl-0.10.0}/testdata/helm-test-chart/Chart.yaml +0 -0
  134. {nyl-0.9.4 → nyl-0.10.0}/testdata/helm-test-chart/templates/sa.yaml +0 -0
  135. {nyl-0.9.4 → nyl-0.10.0}/testdata/helm-test-chart/values.yaml +0 -0
  136. {nyl-0.9.4 → nyl-0.10.0}/tests/__init__.py +0 -0
  137. {nyl-0.9.4 → nyl-0.10.0}/tests/conftest.py +0 -0
@@ -0,0 +1,31 @@
1
+ release-date = "2025-05-07"
2
+
3
+ [[entries]]
4
+ id = "6bb3d13e-dc2d-4379-97e0-d61199dea43d"
5
+ type = "improvement"
6
+ description = "Remove `nyl argocd discovery` command and use a simpler yet probably sufficient `find` command in the `ConfigManagementPlugin` manifest instead"
7
+ author = "@NiklasRosenstein"
8
+
9
+ [[entries]]
10
+ id = "6c3b6427-756d-46d6-83a7-c3f565b64983"
11
+ type = "improvement"
12
+ description = "The ArgoCD CMP no longer logs to a file, users should check the pod logs instead"
13
+ author = "@NiklasRosenstein"
14
+
15
+ [[entries]]
16
+ id = "864f9e6a-98ec-44f5-bd38-e565709712a5"
17
+ type = "feature"
18
+ description = "Add `nyl-daemon` command which can be used to launch and communicate with a Nyl daemon process to forego Python process launch times"
19
+ author = "@NiklasRosenstein"
20
+
21
+ [[entries]]
22
+ id = "74bf9c2b-7e7d-4981-b7a3-11e2f2dd6e97"
23
+ type = "improvement"
24
+ description = "Support implicit default profile"
25
+ author = "@NiklasRosenstein"
26
+
27
+ [[entries]]
28
+ id = "4cb0fa4d-df4d-408c-a1aa-a31db4ce8574"
29
+ type = "improvement"
30
+ description = "Disable waiting for API server connectivity for now when activating a profile as it seems to be more a hinderance than a useful feature"
31
+ author = "@NiklasRosenstein"
@@ -29,15 +29,27 @@ jobs:
29
29
  username: ${{ github.actor }}
30
30
  password: ${{ secrets.GITHUB_TOKEN }}
31
31
 
32
+ - name: Docker meta
33
+ id: meta
34
+ uses: docker/metadata-action@v5
35
+ with:
36
+ images: ghcr.io/${{ github.repository }}/argocd-cmp
37
+ tags: |
38
+ type=schedule
39
+ type=ref,event=branch
40
+ type=ref,event=pr
41
+ type=semver,pattern={{version}}
42
+ type=semver,pattern={{major}}.{{minor}}
43
+ type=semver,pattern={{major}}
44
+ type=sha
45
+
32
46
  - name: Build and push Docker image
33
47
  uses: docker/build-push-action@v6
34
48
  with:
49
+ cache-from: type=gha
50
+ cache-to: type=gha,mode=max
35
51
  context: .
36
- push: true
37
52
  file: argocd-cmp/Dockerfile
38
- tags: |
39
- ghcr.io/helsing-ai/nyl/argocd-cmp:${{ github.sha }}
40
- ${{ github.ref_type == 'tag' && format('ghcr.io/helsing-ai/nyl/argocd-cmp:{0}', github.ref_name) || '' }}
41
- cache-to: type=registry,ref=ghcr.io/helsing-ai/nyl/argocd-cmp:cache,mode=max
42
- cache-from: type=registry,ref=ghcr.io/helsing-ai/nyl/argocd-cmp:cache
43
53
  platforms: linux/amd64,linux/arm64
54
+ push: true
55
+ tags: ${{ steps.meta.outputs.tags }}
@@ -43,7 +43,7 @@ jobs:
43
43
  chmod +x /usr/local/bin/sops
44
44
 
45
45
  - name: Install uv
46
- uses: astral-sh/setup-uv@v5
46
+ uses: astral-sh/setup-uv@v6
47
47
  with:
48
48
  version: "0.5.20"
49
49
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nyl
3
- Version: 0.9.4
3
+ Version: 0.10.0
4
4
  Summary: Advanced templating engine for Kubernetes and GitOps.
5
5
  Author-email: Niklas Rosenstein <rosensteinniklas@gmail.com>
6
6
  License: MIT
@@ -3,7 +3,7 @@
3
3
  #: -----------------
4
4
 
5
5
  FROM python:3.13-alpine AS build
6
- COPY --from=ghcr.io/astral-sh/uv:0.6.14 /uv /bin/uv
6
+ COPY --from=ghcr.io/astral-sh/uv:0.7.2 /uv /bin/uv
7
7
 
8
8
  WORKDIR /opt/nyl
9
9
 
@@ -40,7 +40,7 @@ RUN \
40
40
  FROM fetch-bin-base AS argocd-bin
41
41
  # Find ArgoCD releases at https://github.com/argoproj/argo-cd/releases
42
42
  # renovate: datasource=github-releases depName=argocd packageName=argoproj/argo-cd
43
- ARG ARGOCD_VERSION=v2.14.10
43
+ ARG ARGOCD_VERSION=v2.14.11
44
44
  RUN curl -sSfLo /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/${ARGOCD_VERSION}/argocd-linux-$(cat /BINARY_ARCH) \
45
45
  && chmod +x /usr/local/bin/argocd \
46
46
  && upx /usr/local/bin/argocd \
@@ -68,7 +68,7 @@ RUN curl -fLO https://github.com/getsops/sops/releases/download/${SOPS_VERSION}/
68
68
 
69
69
  FROM fetch-bin-base AS kyverno-bin
70
70
  # renovate: datasource=github-releases depName=kyverno packageName=kyverno/kyverno
71
- ARG KYVERNO_VERSION=1.13.4
71
+ ARG KYVERNO_VERSION=1.14.1
72
72
  RUN \
73
73
  case "$(uname -m)" in \
74
74
  x86_64) KYVERNO_ARCH='x86_64' ;; \
@@ -92,6 +92,7 @@ COPY --from=sops-bin /usr/local/bin/sops /usr/local/bin/sops
92
92
  COPY --from=kyverno-bin /usr/local/bin/kyverno /usr/local/bin/kyverno
93
93
  COPY --from=build /opt/nyl /opt/nyl
94
94
  RUN ln -s /opt/nyl/.venv/bin/nyl /usr/local/bin/nyl
95
+ RUN ln -s /opt/nyl/.venv/bin/nyl-daemon /usr/local/bin/nyl-daemon
95
96
  COPY --chown=999 argocd-cmp/plugin.yaml /home/argocd/cmp-server/config/plugin.yaml
96
97
 
97
98
  # Validate Nyl can be run, plus various setup steps.
@@ -14,7 +14,9 @@ spec:
14
14
  command:
15
15
  - sh
16
16
  - -c
17
- - 'nyl --log-file=/var/log/nyl/${ARGOCD_APP_NAMESPACE}-${ARGOCD_APP_NAME}.log argocd discovery'
17
+ - |
18
+ cd $(git rev-parse --show-toplevel)
19
+ find -name 'nyl-secrets.*' || find -name 'nyl-project.*'
18
20
 
19
21
  # init:
20
22
  # command:
@@ -24,11 +26,19 @@ spec:
24
26
  # nyl version >&2
25
27
  # argocd version --client >&2
26
28
 
29
+ # We expect that the NYL_CMP_TEMPLATE_INPUT environment variable points to the file to be templated
30
+ # for the current invocation. This is necessary because Argo CD lacks native support for referring to a single file;
31
+ # it only supports directories via the `.spec.source.path` field in the Application resource.
27
32
  generate:
28
33
  command:
29
34
  - sh
30
35
  - -c
31
- - 'nyl --log-file=/var/log/nyl/${ARGOCD_APP_NAMESPACE}-${ARGOCD_APP_NAME}.log template --in-cluster .'
36
+ - |
37
+ if [ -n "${NYL_DAEMON_SOCK:-}" ]; then
38
+ nyl-daemon --socket=${NYL_DAEMON_SOCK:-} template --in-cluster .
39
+ else
40
+ nyl template --in-cluster .
41
+ fi
32
42
 
33
43
  parameters: {}
34
44
 
@@ -1,3 +1,23 @@
1
+ ## 0.10.0 (2025-05-07)
2
+
3
+ <table><tr><th>Type</th><th>Description</th><th>PR</th><th>Issues</th><th>Author</th></tr>
4
+ <tr><td>Improvement</td><td>
5
+
6
+ Remove `nyl argocd discovery` command and use a simpler yet probably sufficient `find` command in the `ConfigManagementPlugin` manifest instead</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
7
+ <tr><td>Improvement</td><td>
8
+
9
+ The ArgoCD CMP no longer logs to a file, users should check the pod logs instead</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
10
+ <tr><td>Feature</td><td>
11
+
12
+ Add `nyl-daemon` command which can be used to launch and communicate with a Nyl daemon process to forego Python process launch times</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
13
+ <tr><td>Improvement</td><td>
14
+
15
+ Support implicit default profile</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
16
+ <tr><td>Improvement</td><td>
17
+
18
+ Disable waiting for API server connectivity for now when activating a profile as it seems to be more a hinderance than a useful feature</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
19
+ </table>
20
+
1
21
  ## 0.9.4 (2025-04-22)
2
22
 
3
23
  <table><tr><th>Type</th><th>Description</th><th>PR</th><th>Issues</th><th>Author</th></tr>
@@ -141,6 +161,6 @@ Refactor `PostProcessor` implementation for generating policy files and invoking
141
161
  `PostProcessor` log for invoking Kyverno now lists the policy file paths that are going to be applied</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
142
162
  <tr><td>Fix</td><td>
143
163
 
144
- `nyl new chart` now generates 2-space indented YAML and has a more complete template</td><td></td><td><a href="https://github.com/NiklasRosenstein/nyl/issues/47">NiklasRosenstein/nyl#47</a></td><td>@NiklasRosenstein</td></tr>
164
+ `nyl new chart` now generates 2-space indented YAML and has a more complete template</td><td></td><td><a href="https://github.com/NiklasRosenstein/nyl/issues/47">47</a></td><td>@NiklasRosenstein</td></tr>
145
165
  </table>
146
166
 
@@ -4,13 +4,15 @@
4
4
 
5
5
  This page describes Nyl's integration as an [ArgoCD ConfigManagementPlugin][0].
6
6
 
7
- ## Installation
7
+ ## Installation (Simple)
8
8
 
9
9
  Config management plugins are installed as additional containers to the `argocd-repo-server` Pod. They launch the
10
10
  `argocd-cmp-server` binary and communicates with ArgoCD over gRPC via a socket file shared between the repo-server
11
11
  and the plugin container under `/home/argocd/cmp-server/plugins`.
12
12
 
13
- We recommend the following configuration:
13
+ The following configuration allows the `nyl-v1` plugin to be used for ArgoCD applications. It will cause the repo-server
14
+ to invoke the `nyl template --in-cluster .` command in the repository and the selected directory associated with the
15
+ application (see `.spec.source` of the `Application` resource).
14
16
 
15
17
  ```yaml title="argocd-values.yaml"
16
18
  repoServer:
@@ -49,6 +51,75 @@ repoServer:
49
51
  If you do not wish to grant the plugin access to the Kubernetes API, you must disable this option and ensure that
50
52
  your manifests do not rely on features that require API access.
51
53
 
54
+ ## Installation (Daemon)
55
+
56
+ The above example will invoke the `nyl template` command again and again for each time an application's manifests are
57
+ refreshed by ArgoCD. This carries a bit of a performance penalty, since a new Nyl process is spawned each time and
58
+ loading its code from disk.
59
+
60
+ Nyl can also be used in a daemon mode, where a long-lived Nyl process is spawned listening for requests to perform
61
+ the `nyl template` operation. This carries less overhead on each refresh in ArgoCD because it uses the `nyl-daemon`
62
+ binary instead to communicate with the daemon, which is a much lighterweight process.
63
+
64
+ To enable this mode, you need to deploy two sidecar containers in the `argocd-repo-server` pod instead of one. The first
65
+ one is the `nyl-v1` plugin container, which will be used to communicate with the daemon. You tell it to connect with the
66
+ daemon instead by setting the `NYL_DAEMON_SOCK` environment variable, pointing to the shared Unix socket file between
67
+ the client and the daemon. The second container is the `nyl-daemon` container, which will run the daemon process.
68
+
69
+ ```diff title="argocd-values.yaml"
70
+ --- /tmp/simple
71
+ +++ /tmp/daemon
72
+ @@ -6,6 +6,8 @@
73
+ runAsNonRoot: true
74
+ runAsUser: 999
75
+ volumeMounts:
76
+ + - mountPath: /var/run/nyl
77
+ + name: var-run-nyl
78
+ - mountPath: /var/run/argocd
79
+ name: var-files
80
+ - mountPath: /home/argocd/cmp-server/plugins
81
+ @@ -20,8 +22,27 @@
82
+ value: /tmp/nyl-cache
83
+ - name: NYL_LOG_LEVEL
84
+ value: info
85
+ + - name: nyl-daemon
86
+ + image: ghcr.io/helsing-ai/nyl/argocd-cmp:{{ NYL_VERSION }}
87
+ + securityContext:
88
+ + runAsNonRoot: true
89
+ + runAsUser: 999
90
+ + command:
91
+ + - sh
92
+ + - -c
93
+ + - nyl-daemon --foreground --socket=/var/run/nyl/daemon.sock
94
+ + volumeMounts:
95
+ + - mountPath: /var/run/nyl
96
+ + name: var-run-nyl
97
+ + - mountPath: /tmp
98
+ + name: cmp-tmp
99
+ clusterRoleRules:
100
+ enabled: true
101
+ volumes:
102
+ - name: cmp-tmp
103
+ + emptyDir: {}
104
+ + - name: var-run-nyl
105
+ emptyDir: {}
106
+ ```
107
+
108
+ > Note how the daemon also needs to share the `/tmp` directory, as that is where ArgoCD clones the Git repository to.
109
+ > We also introduce a new `emptyDir` volume to share the daemon socket file between the two containers.
110
+
111
+ ### Advantages of the daemon mode
112
+
113
+ - Lower overhead on each refresh leads to faster application refresh times and CPU usage.
114
+ - Allows for direct and live access to logs from `nyl template` in the daemon container.
115
+ - Improved error message in the ArgoCD UI as no longer the _entire_ stderr output from `nyl template` is displayed,
116
+ but only the error message that caused the operation to fail.
117
+
118
+ ### Known issues in the daemon mode
119
+
120
+ - [ ] All relevant environment variables, including but not limited to `NYL_LOG_LEVEL` and `NYL_CACHE_DIR`, are
121
+ inherited from the request made by the client, which seems counter intuitive.
122
+
52
123
  ## Discovery
53
124
 
54
125
  The ArgoCD plugin runs `nyl argocd discovery` as the discovery command to determine if a repository is compatible with
@@ -71,6 +142,8 @@ spec:
71
142
  plugin:
72
143
  name: nyl-v1
73
144
  env:
145
+ - name: NYL_PROFILE
146
+ value: myprofile # Important when using ${{ values.VAR }} in manifests
74
147
  - name: NYL_CMP_TEMPLATE_INPUT
75
148
  value: '{{.path.filename}}'
76
149
  ```
@@ -108,6 +181,8 @@ spec:
108
181
  plugin:
109
182
  name: nyl-v1
110
183
  env:
184
+ - name: NYL_PROFILE
185
+ value: my-cluster
111
186
  - name: NYL_CMP_TEMPLATE_INPUT
112
187
  value: '{{.path.filename}}'
113
188
  destination:
@@ -45,3 +45,13 @@ This page summarizes all environment variables that are used by Nyl.
45
45
  ArgoCD plugin to allow specifying exactly which files should be templated as part of an ArgoCD application.
46
46
 
47
47
  [^ArgoBuildEnv]: See [ArgoCD Build Environment](https://argo-cd.readthedocs.io/en/stable/user-guide/build-environment/).
48
+
49
+ ## Daemon mode
50
+
51
+ - `NYL_DAEMON_LOG_STDERR` &ndash; If set to `1`, the daemon in client mode will forward stderr output of the
52
+ template operation to the CMP plugin's stderr output. This may be useful for debugging purposes, but the same output
53
+ can also be inspected in the daemon container's logs. This is disabled by default to not show the stderr output
54
+ in the error message in the ArgoCD Web UI when the plugin fails.
55
+ - `NYL_DAEMON_SOCK` &ndash; This variable is only used by the ArgoCD CMP `plugin.yaml`. If set, it tells the plugin
56
+ to use the `nyl-daemon` in client mode instead of running `nyl template` directly and connect to the Nyl daemon using
57
+ a Unix socket as specified in the variable value.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "nyl"
7
- version = "0.9.4"
7
+ version = "0.10.0"
8
8
  description = "Advanced templating engine for Kubernetes and GitOps."
9
9
  authors = [
10
10
  {name = "Niklas Rosenstein", email = "rosensteinniklas@gmail.com"},
@@ -30,6 +30,7 @@ license = {text = "MIT"}
30
30
 
31
31
  [project.scripts]
32
32
  nyl = "nyl.commands:main"
33
+ nyl-daemon = "nyl.daemon:main"
33
34
 
34
35
  [tool.uv]
35
36
  dev-dependencies = [
@@ -4,6 +4,7 @@ applications directly or integrate as an ArgoCD ConfigManagementPlugin.
4
4
  """
5
5
 
6
6
  import atexit
7
+ from contextlib import ExitStack
7
8
  import json
8
9
  import os
9
10
  import shlex
@@ -91,14 +92,6 @@ def _callback(
91
92
  log_env[key] = value
92
93
  logger.debug("Nyl-relevant environment variables: {}", lazy_str(json.dumps, log_env, indent=2))
93
94
 
94
- atexit.register(
95
- # HACK: If we don't wrap it in a lambda, Loguru fails with "ValueError: call stack is not deep enough".
96
- # But we also need to wrap it so we capture the right end time.
97
- lambda *a: logger.debug(*a, time.perf_counter() - start_time),
98
- "Finished (nyl {}) in {:.2f}s",
99
- lazy_str(pretty_cmd, sys.argv),
100
- )
101
-
102
95
  PROVIDER.set_lazy(ProfileManager, lambda: ProfileManager.load(required=False))
103
96
  PROVIDER.set_lazy(SecretsConfig, lambda: SecretsConfig.load(dependencies=PROVIDER))
104
97
  PROVIDER.set_lazy(ProjectConfig, lambda: ProjectConfig.load(dependencies=PROVIDER))
@@ -111,6 +104,18 @@ def _callback(
111
104
  ),
112
105
  )
113
106
 
107
+ exit_stack = ExitStack()
108
+ PROVIDER.set(ExitStack, exit_stack)
109
+ atexit.register(exit_stack.close)
110
+
111
+ # HACK: If we don't wrap it in a lambda, Loguru fails with "ValueError: call stack is not deep enough".
112
+ # But we also need to wrap it so we capture the right end time.
113
+ def _finalize() -> None:
114
+ duration = time.perf_counter() - start_time
115
+ logger.debug("Finished (nyl {}) in {:.2f}s", lazy_str(pretty_cmd, sys.argv), duration)
116
+
117
+ exit_stack.callback(_finalize)
118
+
114
119
 
115
120
  @app.command()
116
121
  def version() -> None:
@@ -123,7 +128,6 @@ def version() -> None:
123
128
 
124
129
 
125
130
  from . import add # noqa: E402
126
- from . import argocd # noqa: E402
127
131
  from . import crds # noqa: F401,E402
128
132
  from . import new # noqa: E402
129
133
  from . import profile # noqa: E402
@@ -134,7 +138,6 @@ from . import tools # noqa: E402
134
138
  from . import tun # noqa: E402
135
139
 
136
140
  app.add_typer(add.app)
137
- app.add_typer(argocd.app)
138
141
  app.add_typer(new.app)
139
142
  app.add_typer(profile.app)
140
143
  app.add_typer(secrets.app)
@@ -15,7 +15,7 @@ from kubernetes.config.kube_config import load_kube_config
15
15
  from nyl.commands import PROVIDER, ApiClientConfig, app
16
16
  from nyl.generator import reconcile_generator
17
17
  from nyl.generator.dispatch import DispatchingGenerator
18
- from nyl.profiles import ProfileManager
18
+ from nyl.profiles import DEFAULT_PROFILE, ProfileManager
19
19
  from nyl.project.config import ProjectConfig
20
20
  from nyl.resources import API_VERSION_INLINE, NylResource
21
21
  from nyl.resources.applyset import APPLYSET_LABEL_PART_OF, ApplySet
@@ -28,7 +28,6 @@ from nyl.tools.kubernetes import populate_namespace_to_resources
28
28
  from nyl.tools.logging import lazy_str
29
29
  from nyl.tools.types import Manifest, Manifests
30
30
 
31
- DEFAULT_PROFILE = "default"
32
31
  DEFAULT_NAMESPACE_ANNOTATION = "nyl.io/is-default-namespace"
33
32
 
34
33