Skip to content

Commit

Permalink
[HELM]: Move CRD resources to a separate folder as per helm standard
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydeokar authored and jdn5126 committed Dec 6, 2022
1 parent c5c31de commit e7e05b5
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 88 deletions.
1 change: 1 addition & 0 deletions charts/aws-vpc-cni/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
.idea/
*.tmproj
.vscode/
crds/kustomization.yaml
2 changes: 1 addition & 1 deletion charts/aws-vpc-cni/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: aws-vpc-cni
version: 1.2.0
version: 1.2.1
appVersion: "v1.12.0"
description: A Helm chart for the AWS VPC CNI
icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png
Expand Down
11 changes: 7 additions & 4 deletions charts/aws-vpc-cni/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This chart installs the AWS CNI Daemonset: https://github.com/aws/amazon-vpc-cni
## Prerequisites

- Kubernetes 1.11+ running on AWS
- Helm v3

## Installing the Chart

Expand All @@ -22,6 +23,8 @@ $ helm install --name aws-vpc-cni --namespace kube-system eks/aws-vpc-cni

To install into an EKS cluster where the CNI is already installed, see [this section below](#adopting-the-existing-aws-node-resources-in-an-eks-cluster)

To migrate helm release for aws-vpc-cni chart from v2 to v3, see [ Migrate from helm v2 to helm v3 ](#migrate-from-helm-v2-to-helm-v3)

## Configuration

The following table lists the configurable parameters for this chart and their default values.
Expand Down Expand Up @@ -69,7 +72,6 @@ The following table lists the configurable parameters for this chart and their d
| `serviceAccount.annotations` | Specifies the annotations for ServiceAccount | `{}` |
| `livenessProbe` | Livenness probe settings for daemonset | (see `values.yaml`) |
| `readinessProbe` | Readiness probe settings for daemonset | (see `values.yaml`) |
| `crd.create` | Specifies whether to create the VPC-CNI CRD | `true` |
| `tolerations` | Optional deployment tolerations | `[]` |
| `updateStrategy` | Optional update strategy | `type: RollingUpdate` |

Expand All @@ -81,9 +83,7 @@ $ helm install --name aws-vpc-cni --namespace kube-system eks/aws-vpc-cni --valu

## Adopting the existing aws-node resources in an EKS cluster

If you do not want to delete the existing aws-node resources in your cluster that run the aws-vpc-cni and then install this helm chart, you can adopt the resources into a release instead. This process is highlighted in this [PR comment](https://github.com/aws/eks-charts/issues/57#issuecomment-628403245). Once you have annotated and labeled all the resources this chart specifies, enable the `originalMatchLabels` flag, and also set `crd.create` to false on the helm release and run an update. If you have been careful this should not diff and leave all the resources unmodified and now under management of helm.

Here is an example script to modify the existing resources:
If you do not want to delete the existing aws-node resources in your cluster that run the aws-vpc-cni and then install this helm chart, you can adopt the resources into a release instead. Refer to the script below to import existing resources into helm. Once you have annotated and labeled all the resources this chart specifies, enable the `originalMatchLabels` flag. If you have been careful this should not diff and leave all the resources unmodified and now under management of helm.

WARNING: Substitute YOUR_HELM_RELEASE_NAME_HERE with the name of your helm release.
```
Expand All @@ -99,3 +99,6 @@ for kind in daemonSet clusterRole clusterRoleBinding serviceAccount; do
kubectl -n kube-system label --overwrite $kind aws-node app.kubernetes.io/managed-by=Helm
done
```

## Migrate from Helm v2 to Helm v3
You can use the [Helm 2to3 plugin](https://github.com/helm/helm-2to3) to migrate releases from Helm v2 to Helm v3. For a more detailed explanation with some examples about this migration plugin, refer to Helm blog post: [How to migrate from Helm v2 to Helm v3](https://helm.sh/blog/migrate-from-helm-v2-to-helm-v3/).
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{{- if .Values.crd.create -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: eniconfigs.crd.k8s.amazonaws.com
labels:
{{ include "aws-vpc-cni.labels" . | indent 4 }}
spec:
scope: Cluster
group: crd.k8s.amazonaws.com
Expand All @@ -21,4 +18,3 @@ spec:
plural: eniconfigs
singular: eniconfig
kind: ENIConfig
{{- end -}}
4 changes: 4 additions & 0 deletions charts/aws-vpc-cni/crds/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- customresourcedefinition.yaml
3 changes: 0 additions & 3 deletions charts/aws-vpc-cni/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ securityContext:
- "NET_ADMIN"
- "NET_RAW"

crd:
create: true

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand Down
3 changes: 0 additions & 3 deletions charts/aws-vpc-cni/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ securityContext:
- "NET_ADMIN"
- "NET_RAW"

crd:
create: true

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand Down
32 changes: 14 additions & 18 deletions config/master/aws-k8s-cni-cn.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/customresourcedefinition.yaml
# Source: crds/customresourcedefinition.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: eniconfigs.crd.k8s.amazonaws.com
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
spec:
scope: Cluster
group: crd.k8s.amazonaws.com
Expand All @@ -37,6 +20,19 @@ spec:
plural: eniconfigs
singular: eniconfig
kind: ENIConfig

---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
32 changes: 14 additions & 18 deletions config/master/aws-k8s-cni-us-gov-east-1.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/customresourcedefinition.yaml
# Source: crds/customresourcedefinition.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: eniconfigs.crd.k8s.amazonaws.com
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
spec:
scope: Cluster
group: crd.k8s.amazonaws.com
Expand All @@ -37,6 +20,19 @@ spec:
plural: eniconfigs
singular: eniconfig
kind: ENIConfig

---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
32 changes: 14 additions & 18 deletions config/master/aws-k8s-cni-us-gov-west-1.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/customresourcedefinition.yaml
# Source: crds/customresourcedefinition.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: eniconfigs.crd.k8s.amazonaws.com
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
spec:
scope: Cluster
group: crd.k8s.amazonaws.com
Expand All @@ -37,6 +20,19 @@ spec:
plural: eniconfigs
singular: eniconfig
kind: ENIConfig

---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
32 changes: 14 additions & 18 deletions config/master/aws-k8s-cni.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/customresourcedefinition.yaml
# Source: crds/customresourcedefinition.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: eniconfigs.crd.k8s.amazonaws.com
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
spec:
scope: Cluster
group: crd.k8s.amazonaws.com
Expand All @@ -37,6 +20,19 @@ spec:
plural: eniconfigs
singular: eniconfig
kind: ENIConfig

---
# Source: aws-vpc-cni/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-node
namespace: kube-system
labels:
app.kubernetes.io/name: aws-node
app.kubernetes.io/instance: aws-vpc-cni
k8s-app: aws-node
app.kubernetes.io/version: "v1.12.0"
---
# Source: aws-vpc-cni/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate-cni-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jq -c '.[]' $REGIONS_FILE | while read i; do
fi

$BUILD_DIR/helm template aws-vpc-cni \
--include-crds \
--set originalMatchLabels=true,\
--set init.image.region=$ecrRegion,\
--set init.image.account=$ecrAccount,\
Expand All @@ -93,7 +94,7 @@ jq -c '.[]' $REGIONS_FILE | while read i; do
mv $BUILD_DIR/helm_annotations_removed.yaml $NEW_METRICS_RESOURCES_YAML
done

$BUILD_DIR/helm template \
$BUILD_DIR/helm template --include-crds \
--namespace $NAMESPACE \
--output-dir $INDV_RESOURCES_DIR/ \
$SCRIPTPATH/../charts/aws-vpc-cni/
Expand Down

0 comments on commit e7e05b5

Please sign in to comment.