You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tool is designed to help deploy and manage Custom Resource Definitions (CRDs) in a Kubernetes cluster.
4
-
It applies all CRDs found in specified directories, providing a solution to some of the limitations of Helm when it comes to managing CRDs.
3
+
A Go library for deploying and managing Custom Resource Definitions (CRDs) in Kubernetes clusters.
4
+
It supports both applying (creating/updating) and deleting CRDs from individual files or directories (searched recursively).
5
+
6
+
This package is intended to be used programmatically in Go applications. An example CLI implementation is provided in [`examples/apply-crds/`](../../examples/apply-crds/) to demonstrate usage.
5
7
6
8
## Motivation
7
9
8
10
While Helm is commonly used for managing Kubernetes resources, it has certain restrictions with CRDs:
9
11
10
-
- CRDs placed in Helm's top-level `crds/` directory are not updated on upgrades or rollbacks.
11
-
- Placing CRDs in Helm’s `templates/` directory is not entirely safe, as deletions and upgrades of CRDs are not always handled properly.
12
+
- CRDs placed in a Helm chart's top-level `crds/` directory are installed once but not updated on upgrades or deleted on uninstalls.
13
+
- Placing CRDs in a Helm chart's `templates/` directory allows updates but can be risky since CRDs are deleted on uninstall unless protected with the `helm.sh/resource-policy: keep` annotation.
12
14
13
-
This tool offers a more reliable way to apply CRDs, ensuring they are createdor updated as needed.
15
+
This library offers a more reliable way to manage CRDs, ensuring they are created, updated, or deleted as needed.
You can build a custom binary using this library and deploy it as a Helm hook. Here's an example:
35
+
36
+
#### Pre-install/Pre-upgrade Hook
37
+
38
+
Apply CRDs before installation or upgrade:
32
39
33
40
```yaml
34
41
apiVersion: batch/v1
@@ -51,11 +58,10 @@ spec:
51
58
command:
52
59
- /apply-crds
53
60
args:
54
-
- --crds-dir=/crds/operator
61
+
- --crds-path=/opt/config/crds
62
+
- --operation=apply
55
63
```
56
64
57
-
> Note: the image must contain all your CRDs in e.g. the `/crds/operator` directory.
58
-
59
-
## Flags
65
+
#### Pre-delete Hook
60
66
61
-
- `-crds-dir` (required): Specifies a directory path that contains the CRD manifests in YAML format. This flag can be provided multiple times to apply CRDs from multiple directories.
67
+
By default, Helm does not delete CRDs when a chart is uninstalled. Use caution when deleting CRDs in a pre-delete Helm hook. Deleting a CRD also removes all associated Custom Resources (CRs), which can lead to data loss if users upgrade by uninstalling and reinstalling the chart.
0 commit comments