Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mgoltzsche/khelm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 96a4ed3eb476372f264bef4f81a1c40d42d8a622
Choose a base ref
..
head repository: mgoltzsche/khelm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9de5d9077247e933b30ade301947f5b6a875bd42
Choose a head ref
Showing with 173 additions and 32,781 deletions.
  1. +1 −3 .gitignore
  2. +1 −1 Makefile
  3. +11 −23 README.md
  4. +2 −1 e2e/cli-tests.bats
  5. +0 −48 e2e/kpt-function-tests.bats
  6. +79 −0 e2e/kpt-krm-fn-tests.bats
  7. +2 −0 e2e/{kustomize-krm-tests.bats → kustomize-krm-fn-tests.bats}
  8. +2 −0 e2e/kustomize-plugin-tests.bats
  9. +0 −6 example/kpt/cache-dependencies/Kptfile
  10. +0 −11 example/kpt/cache-dependencies/Makefile
  11. +0 −5 example/kpt/cache-dependencies/README.md
  12. +0 −31 example/kpt/cache-dependencies/functions-local-chart-dependencies.yaml
  13. +0 −35 example/kpt/cache-dependencies/functions-remote-chart.yaml
  14. +0 −6 example/kpt/cert-manager/Kptfile
  15. +0 −31 example/kpt/cert-manager/helm-kustomize-pipeline.yaml
  16. +0 −4 example/kpt/cert-manager/kustomization/kustomization.yaml
  17. +0 −4 example/kpt/cert-manager/kustomization/namespace.yaml
  18. +0 −2 example/kpt/cert-manager/static/README.md
  19. +0 −26,515 example/kpt/cert-manager/static/generated-manifest.yaml
  20. +0 −19 example/kpt/cert-manager/static/inventory-template.yaml
  21. +5 −0 example/kpt/chart-to-kustomization/Makefile
  22. +15 −0 example/kpt/chart-to-kustomization/fn-config.yaml
  23. +0 −26 example/kpt/linkerd/Kptfile
  24. +0 −20 example/kpt/linkerd/Makefile
  25. +0 −12 example/kpt/linkerd/README.md
  26. +0 −6 example/kpt/linkerd/manifests/base/README.md
  27. +0 −3 example/kpt/linkerd/manifests/base/kustomization.yaml
  28. +0 −165 example/kpt/linkerd/manifests/config/generated-config.yaml
  29. +0 −12 example/kpt/linkerd/manifests/config/kustomization.yaml
  30. +0 −91 example/kpt/linkerd/manifests/helm-kustomize-pipeline.yaml
  31. +0 −14 example/kpt/linkerd/manifests/ingress/certificate.yaml
  32. +0 −26 example/kpt/linkerd/manifests/ingress/ingress.yaml
  33. +0 −15 example/kpt/linkerd/manifests/ingress/kustomization.yaml
  34. +0 −16 example/kpt/linkerd/manifests/ingress/kustomizeconfig.yaml
  35. +0 −4 example/kpt/linkerd/manifests/ktransform-namespaced/kustomization.yaml
  36. +0 −26 example/kpt/linkerd/manifests/ktransform/Kptfile
  37. +0 −136 .../kpt/linkerd/manifests/ktransform/crds/ktransform.mgoltzsche.github.com_secrettransforms_crd.yaml
  38. +0 −25 ...nkerd/manifests/ktransform/crds/ktransform.mgoltzsche.github.com_v1alpha1_secrettransform_cr.yaml
  39. +0 −2 example/kpt/linkerd/manifests/ktransform/crds/kustomization.yaml
  40. +0 −5 example/kpt/linkerd/manifests/ktransform/kustomization.yaml
  41. +0 −32 example/kpt/linkerd/manifests/ktransform/operator.yaml
  42. +0 −82 example/kpt/linkerd/manifests/ktransform/role.yaml
  43. +0 −11 example/kpt/linkerd/manifests/ktransform/role_binding.yaml
  44. +0 −4 example/kpt/linkerd/manifests/ktransform/service_account.yaml
  45. +0 −60 example/kpt/linkerd/manifests/patched/certificates.yaml
  46. +0 −36 example/kpt/linkerd/manifests/patched/config-transformer.yaml
  47. +0 −10 example/kpt/linkerd/manifests/patched/kustomization.yaml
  48. +0 −91 example/kpt/linkerd/manifests/patched/patches/apiservice-use-cert-secrets.yaml
  49. +0 −23 example/kpt/linkerd/manifests/patched/patches/apiserviceconfig-annotate-cabundle.yaml
  50. +0 −97 example/kpt/linkerd/manifests/patched/patches/proxy-use-identity-ca.yaml
  51. +0 −55 example/kpt/linkerd/manifests/patched/test.yaml
  52. +0 −4 example/kpt/linkerd/manifests/reloader/kustomization.yaml
  53. +0 −4 example/kpt/linkerd/manifests/reloader/namespace.yaml
  54. +0 −4,415 example/kpt/linkerd/manifests/static/linkerd/generated-manifest.yaml
  55. +0 −19 example/kpt/linkerd/manifests/static/linkerd/inventory-template.yaml
  56. +0 −144 example/kpt/linkerd/manifests/static/reloader/generated-manifest.yaml
  57. +0 −19 example/kpt/linkerd/manifests/static/reloader/inventory-template.yaml
  58. +0 −5 example/kpt/linkerd/manifests/viz/kustomization.yaml
  59. +0 −15 example/kpt/linkerd/manifests/viz/patches/apiservice-use-cert-secrets.yaml
  60. +0 −11 example/kpt/linkerd/manifests/viz/patches/apiserviceconfig-annotate-cabundle.yaml
  61. +0 −209 example/kpt/linkerd/test-config.json
  62. +0 −7 example/kpt/linkerd/values-viz.yaml
  63. +0 −16 example/kpt/linkerd/values.yaml
  64. +6 −0 example/kpt/local-chart/Makefile
  65. 0 example/kpt/{cache-dependencies → local-chart}/chart/Chart.yaml
  66. +9 −0 example/kpt/local-chart/chart/requirements.lock
  67. +3 −0 example/kpt/{cache-dependencies → local-chart}/chart/requirements.yaml
  68. +20 −0 example/kpt/local-chart/fn-config.yaml
  69. +4 −0 example/kpt/remote-chart/Makefile
  70. +13 −0 example/kpt/remote-chart/fn-config.yaml
  71. +0 −6 example/kpt/test-cases/Kptfile
  72. +0 −57 example/kpt/test-cases/kpt-functions.yaml
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,11 +5,9 @@

/example/**/charts
/example/**/tmpcharts
/example/kpt/*/output-*
/example/kpt/*/output*
/example/kpt/*/generated-*
/example/kpt/**/requirements.lock
/example/**/generated-manifest-without-secrets.yaml
/example/kpt/linkerd/dep
/example/kpt/cache-dependencies/chart/charts

dist/
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ export HELM_PLUGINS := $(BUILD_DIR)/helm-plugins
GORELEASER_VERSION ?= v1.9.2
GOLANGCI_LINT_VERSION ?= v1.46.2
# TODO: fix e2e tests and docu to make newer kpt versions work
KPT_VERSION ?= v0.39.2
KPT_VERSION ?= v1.0.0-beta.21
KUSTOMIZE_VERSION ?= v4.5.5
BATS_VERSION = v1.7.0
SOPS_VERSION = v3.7.3
34 changes: 11 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -43,53 +43,41 @@ Usage examples can be found in the [example](example) and [e2e](e2e) directories

### kpt function

The khelm kpt function templates a chart and returns the output as single manifest file or kustomization directory (when `outputPath` ends with `/`). The kustomization output can be used to apply further transformations by running a kustomize function afterwards.
The khelm kpt function templates a chart and returns the output as single manifest file or kustomization directory (when `outputPath` ends with `/`).

In opposite to the kustomize plugin approach kpt function outputs can be audited reliably when committed to a git repository, a kpt function does not depend on particular plugin binaries on the host and CD pipelines can run without dependencies to rendering technologies and chart servers since they just apply static mainfests (and eventually change values using `kpt cfg set`) to a cluster using `kpt live apply`.
In opposite to the kustomize plugin approach, kpt function outputs can be audited reliably when committed to a git repository, a kpt function does not depend on particular plugin binaries on the host and CD pipelines can run without dependencies to rendering technologies and chart servers since they just apply static mainfests to a cluster (e.g. using `kpt live apply`).

#### kpt function usage example

**NOTE:** Newer kpt versions don't support fully declarative khelm functions anymore since kpt doesn't allow network and file system access for them. See https://github.com/GoogleContainerTools/kpt/issues/2450

A kpt function can be declared as annotated _ConfigMap_ within a kpt project.
A kpt project can be initialized and used with such a function as follows:
Khelm can be used as an imperative kpt function only since it requires the chart to be mounted or network access to fetch a chart.
The kpt function can be invoked as follows, using a local _ConfigMap_ to specify the parameters:
```sh
mkdir example-project && cd example-project
kpt pkg init . # Creates the Kptfile
cat - > khelm-function.yaml <<-EOF
cat - > fn-config.yaml <<-EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: cert-manager-manifest-generator
name: cert-manager-manifest-generator-config
annotations:
config.kubernetes.io/function: |
container:
image: mgoltzsche/khelm:latest
network: true
config.kubernetes.io/local-config: "true"
data:
repository: https://charts.jetstack.io
chart: cert-manager
version: 0.9.x
name: my-cert-manager-release
name: myrelease
namespace: cert-manager
values:
webhook:
enabled: false
outputPath: output-manifest.yaml
EOF
kpt fn run --network . # Renders the chart into output-manifest.yaml
kpt fn eval --image mgoltzsche/khelm:latest --fn-config fn-config.yaml --network .
```
_For all available fields see the [table](#configuration-options) below._

Please note that, in case you need to refer to a local chart directory or values file, the source must be mounted to the function using e.g. `kpt fn run --mount="type=bind,src=$(pwd),dst=/source,rw=true" .`.
An [example kpt project](example/kpt/test-cases) and the corresponding [e2e test](e2e/kpt-function-test.sh) show how to do that.

Kpt can also be leveraged to pull charts from other git repositories into your own repository using the `kpt pkg sync .` [command](https://googlecontainertools.github.io/kpt/reference/pkg/) (with a corresponding dependency set up) before running the khelm function (for this reason the go-getter support has been removed from this project).
Please note that, in case you need to refer to a local chart directory or values file, the source must be mounted to the function using e.g. `kpt fn eval --mount="type=bind,src=$(pwd),dst=/source,rw=true" --image mgoltzsche/khelm --fn-config fn-config.yaml .`.
The [kpt examples](example/kpt) and corresponding [e2e tests](e2e/kpt-function-test.sh) show how to do that.

If necessary the chart output can be transformed using kustomize.
This can be done by declaring the khelm and a kustomize function orderly within a file and specifying the chart output kustomization as input for the kustomize function as shown in the [cert-manager example](example/kpt/cert-manager).
A more complex example that also manages a Helm chart from another git repository locally as kpt dependency can be found [here](example/kpt/linkerd).
Kpt can also be leveraged to sync charts from other git repositories into your own repository using the `kpt pkg get` and `kpt pkg update` [commands](https://kpt.dev/reference/cli/pkg/) (with a corresponding dependency set up) before running the khelm function.

#### Caching Helm Charts and repository index files

3 changes: 2 additions & 1 deletion e2e/cli-tests.bats
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@

bats_require_minimum_version 1.5.0

IMAGE=${IMAGE:-mgoltzsche/khelm:latest}
: ${IMAGE:=mgoltzsche/khelm:latest}

EXAMPLE_DIR="$(pwd)/example"
OUT_DIR="$(mktemp -d)"

48 changes: 0 additions & 48 deletions e2e/kpt-function-tests.bats

This file was deleted.

79 changes: 79 additions & 0 deletions e2e/kpt-krm-fn-tests.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bats

set -eu

: ${IMAGE:=mgoltzsche/khelm:latest}
EXAMPLE_CHART_NAMESPACE="`pwd`/example/namespace"
TMP_DIR="$(mktemp -d)"

teardown() {
rm -rf $TMP_DIR
}

@test "kpt fn should run example/kpt/local-chart" {
cd example/kpt/local-chart
rm -rf output
mkdir output
make fn
[ -f ./output/output.yaml ]
grep -q jenkins-role-binding ./output/output.yaml
}

@test "kpt fn should run cache chart dependency" {
cd example/kpt/local-chart
rm -rf output
mkdir output
kpt fn eval --image="$IMAGE" --fn-config=./fn-config.yaml \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,source=`pwd`/../..,target=/examples,rw=true" \
--as-current-user output --network
kpt fn eval --image="$IMAGE" --fn-config=./fn-config.yaml \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,source=`pwd`/../..,target=/examples,rw=true" \
--as-current-user output --truncate-output=false --network

[ -f ./output/output.yaml ]
grep -q jenkins-role-binding ./output/output.yaml
grep -qv myconfiga ./output/output.yaml
}

@test "kpt fn should run example/kpt/chart-to-kustomization" {
cd example/kpt/chart-to-kustomization
rm -rf output-kustomization
make fn

[ -f ./output-kustomization/configmap_myconfiga.yaml ]
[ -f ./output-kustomization/configmap_myconfigb.yaml ]
[ -f ./output-kustomization/kustomization.yaml ]
kustomize build ./output-kustomization | grep -q ' myconfiga'
}

@test "kpt fn should run example/kpt/remote-chart" {
cd example/kpt/remote-chart
rm -f output-remote.yaml
make fn

[ -f ./output-remote.yaml ]
grep -q cainjector ./output-remote.yaml
}

@test "kpt fn should cache remote chart" {
cd example/kpt/remote-chart
rm -f output-remote.yaml
kpt fn eval --as-current-user --network \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,src=$EXAMPLE_CHART_NAMESPACE,dst=/source" \
--image="$IMAGE" \
--fn-config=./fn-config.yaml .
[ -f ./output-remote.yaml ]
rm -f output-remote.yaml

ls -la $TMP_DIR/cache/khelm
kpt fn eval --as-current-user \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,src=$EXAMPLE_CHART_NAMESPACE,dst=/source" \
--image="$IMAGE" \
--fn-config=./fn-config.yaml .
[ -f ./output-remote.yaml ]
grep -q cainjector ./output-remote.yaml
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

set -eu

@test "kustomize Containerized KRM Function plugin should template cert-manager" {
MANIFEST="$(kustomize build --enable-alpha-plugins --network ./example/kustomize-krm/cert-manager)"
echo "$MANIFEST" | grep -q 'app: cert-manager'
2 changes: 2 additions & 0 deletions e2e/kustomize-plugin-tests.bats
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bats

set -eu

TMP_DIR="$(mktemp -d)"

teardown() {
6 changes: 0 additions & 6 deletions example/kpt/cache-dependencies/Kptfile

This file was deleted.

11 changes: 0 additions & 11 deletions example/kpt/cache-dependencies/Makefile

This file was deleted.

5 changes: 0 additions & 5 deletions example/kpt/cache-dependencies/README.md

This file was deleted.

This file was deleted.

35 changes: 0 additions & 35 deletions example/kpt/cache-dependencies/functions-remote-chart.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions example/kpt/cert-manager/Kptfile

This file was deleted.

31 changes: 0 additions & 31 deletions example/kpt/cert-manager/helm-kustomize-pipeline.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions example/kpt/cert-manager/kustomization/kustomization.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions example/kpt/cert-manager/kustomization/namespace.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions example/kpt/cert-manager/static/README.md

This file was deleted.

Loading