Skip to content

Commit cdbfd0c

Browse files
authored
Merge pull request #6 from appthrust/fix-gha2
add karpenter-aws-default-nodepool chart and ci: Add Helm chart release GitHub workflow
2 parents 97869dc + d277af1 commit cdbfd0c

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

.github/workflows/release-helm.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release Helm Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
plan:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
charts: ${{ steps.plan.outputs.charts }}
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Plan
20+
id: plan
21+
run: |
22+
CHART_PATHS=$(find charts -name 'Chart.yaml' -exec dirname {} \;)
23+
CHARTS_JSON=$(echo "${CHART_PATHS}" | while read -r path; do
24+
name=$(yq e '.name' "$path/Chart.yaml")
25+
version=$(yq e '.version' "$path/Chart.yaml")
26+
echo "{\"path\": \"$path\", \"name\": \"$name\", \"version\": \"$version\"}"
27+
done | jq -s -c)
28+
echo "charts=${CHARTS_JSON}" | tee -a "$GITHUB_OUTPUT"
29+
30+
push-chart:
31+
needs: [plan]
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
charts: ${{ fromJson(needs.plan.outputs.charts) }}
37+
38+
env:
39+
HELM_EXPERIMENTAL_OCI: 1
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Setup Helm
46+
uses: azure/setup-helm@v4
47+
48+
- name: Helm login
49+
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.repository_owner }} --password-stdin
50+
51+
- name: Package Helm Chart
52+
run: |
53+
helm package ${{ matrix.charts.path }} --destination packaged
54+
55+
- name: Push Helm Chart to GHCR
56+
run: |
57+
CHART_FILE=packaged/${{ matrix.charts.name }}-${{ matrix.charts.version }}.tgz
58+
helm push $CHART_FILE oci://ghcr.io/appthrust/charts

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ references
3131
aws-creds-secret.yaml
3232
debug
3333
dist
34+
35+
*.tgz
36+
.DS_Store
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: karpenter-aws-default-nodepool
3+
description: A Helm chart for creating EC2NodeClass and NodePool resources for Karpenter
4+
type: application
5+
version: 0.1.0
6+
appVersion: "1.0"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{- if not .Values.clusterName -}}
2+
{{- fail "The 'clusterName' value is required but not provided. Please set it in your values.yaml." -}}
3+
{{- end -}}
4+
---
5+
apiVersion: karpenter.k8s.aws/v1
6+
kind: EC2NodeClass
7+
metadata:
8+
name: {{ .Values.name }}
9+
spec:
10+
amiSelectorTerms:
11+
- alias: bottlerocket@latest
12+
role: {{ .Values.nodeRoleName | default (printf "%s-node" .Values.clusterName) | quote }}
13+
subnetSelectorTerms:
14+
- tags:
15+
karpenter.sh/discovery: {{ .Values.clusterName | quote }}
16+
securityGroupSelectorTerms:
17+
- tags:
18+
karpenter.sh/discovery: {{ .Values.clusterName | quote }}
19+
tags:
20+
karpenter.sh/discovery: {{ .Values.clusterName | quote }}
21+
---
22+
apiVersion: karpenter.sh/v1
23+
kind: NodePool
24+
metadata:
25+
name: {{ .Values.name }}
26+
spec:
27+
template:
28+
spec:
29+
nodeClassRef:
30+
group: karpenter.k8s.aws
31+
kind: EC2NodeClass
32+
name: {{ .Values.name }}
33+
requirements:
34+
- key: "karpenter.k8s.aws/instance-category"
35+
operator: In
36+
values: ["c", "m", "r"]
37+
- key: "karpenter.k8s.aws/instance-hypervisor"
38+
operator: In
39+
values: ["nitro"]
40+
- key: "karpenter.k8s.aws/instance-generation"
41+
operator: Gt
42+
values: ["2"]
43+
limits: {{ toYaml .Values.limits | nindent 4 }}
44+
disruption:
45+
consolidationPolicy: WhenEmptyOrUnderutilized
46+
consolidateAfter: 1m
47+
{{- with .Values.budgets }}
48+
budgets: {{ toYaml . | nindent 6 }}
49+
{{- end }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: default
2+
clusterName:
3+
budgets:
4+
limits:
5+
cpu: 1000
6+
nodeRoleName:

0 commit comments

Comments
 (0)