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 committed Nov 18, 2022
1 parent 407fa7c commit 9326399
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
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
9 changes: 7 additions & 2 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,7 +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.
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. 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:

Expand All @@ -99,3 +101,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,9 @@
{{- 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 }}
k8s-app: aws-node
spec:
scope: Cluster
group: crd.k8s.amazonaws.com
Expand All @@ -21,4 +20,3 @@ spec:
plural: eniconfigs
singular: eniconfig
kind: ENIConfig
{{- end -}}
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 9326399

Please sign in to comment.