From 44318da8efdf092e049a43b8847aa15219e1aa64 Mon Sep 17 00:00:00 2001 From: hiteshmakol1 Date: Thu, 2 Jan 2025 15:02:52 +0530 Subject: [PATCH] Addition of Readme File for Helm Chart (#263) * ADDED README FILE * Removed Extra nodepool yaml file, fixed spacing * Added example field and comments in values.yaml * Add comments in ReadMe File * Modifed README file * Added example in README file * Added Example folder and modified README file --- charts/karpenter/README.md | 63 +++++++++++++++++++++ charts/karpenter/example/example.yaml | 67 ++++++++++++++++++++++ charts/karpenter/templates/node-pool.yaml | 68 ----------------------- charts/karpenter/templates/nodePool.yaml | 2 +- charts/karpenter/values.yaml | 6 ++ 5 files changed, 137 insertions(+), 69 deletions(-) create mode 100644 charts/karpenter/README.md create mode 100644 charts/karpenter/example/example.yaml delete mode 100644 charts/karpenter/templates/node-pool.yaml diff --git a/charts/karpenter/README.md b/charts/karpenter/README.md new file mode 100644 index 0000000..78ba730 --- /dev/null +++ b/charts/karpenter/README.md @@ -0,0 +1,63 @@ + +# Karpenter + +Karpenter is an open-source Kubernetes cluster autoscaler built for efficiency and speed. This Helm chart installs Karpenter in your Kubernetes cluster and can be used to manage your node pools for dynamically scaling your infrastructure. This chart supports automated deployment of Karpenter, including the creation of NodePools, EC2NodeClasses, IAM roles, and other necessary resources. + +To install Karpenter, use the following commands: + +```shell +$ helm repo add ot-helm https://ot-container-kit.github.io/helm-charts/ +$ helm install karpenter ot-helm/karpenter --namespace kube-system +``` + +To upgrade the setup: + +```shell +$ helm upgrade karpenter ot-helm/karpenter --install --namespace kube-system +``` + +To uninstall the chart: + +```shell +$ helm delete karpenter --namespace kube-system +``` + +### Pre-Requisites + +- Kubernetes => 1.18+ +- Helm => 3.X +- Karpenter Operator => 0.1.0 +- Open ID Connector (EKS) => https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html +- IAM Roles for Karpenter +- Add tags to subnets and security groups +- Update aws-auth ConfigMap + +### Parameters + +| **Name** | **Value** | **Description** | +|--------------------------------------------------------------------|:-------------------------------|------------------------------------------------| +| `karpenter.settings.clusterName` | `my-cluster` | The name of your Kubernetes cluster | +| `karpenter.serviceAccount.annotations.eks.amazonaws.com/role-arn` | Required | IAM role ARN for Karpenter controller | +| `karpenter.controller.resources.requests.cpu` | `1` | CPU request for Karpenter controller | +| `karpenter.controller.resources.requests.memory` | `1Gi` | Memory request for Karpenter controller | +| `karpenter.controller.resources.limits.cpu` | `1` | CPU limit for Karpenter controller | +| `karpenter.controller.resources.limits.memory` | `1Gi` | Memory limit for Karpenter controller | +| `nodePools` | [] | List of NodePools to be created | +| `nodePools.name` | default-nodepool | Name of the NodePool | +| `nodePools.labels` - If not required can be omitted | {} | Labels for the NodePool | +| `nodePools.annotations` - If not required can be omitted | {} | Annotations for the NodePool | +| `nodePools.requirements` - Can be empty [] | [] | Node requirements like CPU, memory, etc. | +| `nodePools.taints` - If not required can be omitted | [] | Taints for the NodePool | +| `nodePools.expireAfter` | 720h | Expiration duration for idle NodePools | +| `nodePools.limits.cpu` - Required Field | "1000m" | CPU limit for the NodePool | +| `nodePools.limits.memory`- If not required can be omitted | "2Gi" | Memory limit for the NodePool | +| `nodePools.disruption.consolidationPolicy` - Required Field | WhenEmptyOrUnderutilized | Consolidation policy for underutilized nodes | +| `nodePools.disruption.consolidateAfter` - Required Field | 1m | Time before consolidating underutilized nodes | + + +### Notes: + +- Refer to Example Folder for a example values.yaml file +- Karpenter automatically creates and manages NodePools as part of the installation process. +- Make sure to configure the IAM roles required by Karpenter for it to interact with EC2 instances and manage resources along with all prerequisites. +- The chart will ensure the Karpenter controller and NodePools are deployed correctly with all required configurations. \ No newline at end of file diff --git a/charts/karpenter/example/example.yaml b/charts/karpenter/example/example.yaml new file mode 100644 index 0000000..9b9fec1 --- /dev/null +++ b/charts/karpenter/example/example.yaml @@ -0,0 +1,67 @@ +# Custom values for chart +clusterName: test-cluster +awsPartition: aws +awsAccountId: 384961113000 +karpenterVersion: 1.1.1 + +# Karpenter chart overrides +karpenter: + settings: + clusterName: test-cluster + serviceAccount: + annotations: + eks.amazonaws.com/role-arn: arn:aws:iam::384961113000:role/KarpenterControllerRole-test-cluster + controller: + resources: + requests: + cpu: "1" + memory: "1Gi" + limits: + cpu: "1" + memory: "1Gi" + +nodePools: + - name: default + requirements: + - key: kubernetes.io/arch + operator: In + values: + - "amd64" + - key: kubernetes.io/os + operator: In + values: + - "linux" + - key: karpenter.sh/capacity-type + operator: In + values: + - "on-demand" + - key: karpenter.k8s.aws/instance-category + operator: In + values: + - "t" + - "m" + - "r" + - key: karpenter.k8s.aws/instance-generation + operator: Gt + values: + - "2" + nodeClass: + group: karpenter.k8s.aws + kind: EC2NodeClass + name: default # Name of the ec2nodeclass + expireAfter: 720h + limits: + cpu: "1000" + disruption: + consolidationPolicy: WhenEmptyOrUnderutilized + consolidateAfter: 1m + annotations: + example.com/owner: "my-team" + example.com/maintainer: "admin@company.com" + # taints: + # - key: "example.com/special-taint" + # value: "special-value" + # effect: "NoExecute" + labels: + environment: production + team: "engineering" \ No newline at end of file diff --git a/charts/karpenter/templates/node-pool.yaml b/charts/karpenter/templates/node-pool.yaml deleted file mode 100644 index ce4ac63..0000000 --- a/charts/karpenter/templates/node-pool.yaml +++ /dev/null @@ -1,68 +0,0 @@ -{{- range .Values.nodePools }} -apiVersion: karpenter.sh/v1 -kind: NodePool -metadata: - name: {{ .name }} -spec: - template: - metadata: - labels: -{{- if .labels }} -{{- range $key, $value := .labels }} - {{ $key }}: {{ $value }} -{{- end }} -{{- else }} - {} # Empty labels object if no labels are defined -{{- end }} - annotations: -{{- if .annotations }} -{{- range $key, $value := .annotations }} - {{ $key }}: {{ $value }} -{{- end }} -{{- else }} - {} # Empty annotations object if no annotations are defined -{{- end }} - spec: - requirements: -{{- if .requirements | len }} -{{- range .requirements }} - - key: {{ .key }} - operator: {{ .operator }} - values: -{{ toYaml .values | indent 12 }} -{{- if .minValues }} - minValues: {{ .minValues }} -{{- end }} -{{- end }} -{{- else }} - [] # In case requirements is empty, an empty array will be passed -{{- end }} - - taints: -{{- if .taints }} -{{- range .taints }} - - key: {{ .key }} - {{- if .value }} - value: {{ .value }} - {{- end }} - effect: {{ .effect }} -{{- end }} -{{- else }} - [] # Empty taints array if no taints are defined -{{- end }} - nodeClassRef: - group: {{ .nodeClass.group | default "karpenter.k8s.aws" }} - kind: {{ .nodeClass.kind | default "EC2NodeClass" }} - name: {{ .nodeClass.name }} - expireAfter: {{ .expireAfter | default "720h" }} - limits: -{{- if .limits.cpu }} - cpu: {{ .limits.cpu }} -{{- end }} -{{- if .limits.memory }} - memory: {{ .limits.memory }} -{{- end }} - disruption: - consolidationPolicy: {{ .disruption.consolidationPolicy | default "WhenEmptyOrUnderutilized" }} - consolidateAfter: {{ .disruption.consolidateAfter | default "1m" }} -{{- end }} diff --git a/charts/karpenter/templates/nodePool.yaml b/charts/karpenter/templates/nodePool.yaml index 9b027ba..11fc413 100644 --- a/charts/karpenter/templates/nodePool.yaml +++ b/charts/karpenter/templates/nodePool.yaml @@ -70,4 +70,4 @@ spec: disruption: consolidationPolicy: {{ .disruption.consolidationPolicy | default "WhenEmptyOrUnderutilized" }} consolidateAfter: {{ .disruption.consolidateAfter | default "1m" }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/karpenter/values.yaml b/charts/karpenter/values.yaml index bc3bcb9..6c3b9dd 100644 --- a/charts/karpenter/values.yaml +++ b/charts/karpenter/values.yaml @@ -25,6 +25,12 @@ karpenter: # NodePools define groups of nodes with specific requirements nodePools: - name: default # Name of the node pool, used for identification + limits: # Required Field + cpu: "1000" + memory: "1000Gi" + disruption: # Required Field + consolidationPolicy: WhenEmptyOrUnderutilized + consolidateAfter: 1m requirements: # Node pool requirements for instance types and other properties - key: kubernetes.io/arch operator: In # Specifies the architecture for nodes