forked from aws-ia/terraform-aws-eks-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aws-ia#2 from aws-samples/feature/helm-monitoring
Added mechanism to regularly check for helm chart updates
- Loading branch information
Showing
7 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Helm Chart Update | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
check: | ||
name: check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
- name: Run check | ||
working-directory: helm | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
python check_helm_charts.py | ||
cat ../terraform/modules/cluster/helm_versions.tf.json | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: Update helm charts | ||
title: 'chore: Update helm charts' | ||
body: | | ||
Auto-generated pull request to update Helm charts in `helm/charts.yaml` | ||
branch: update-helm-charts | ||
labels: | | ||
dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ vendor | |
builds | ||
|
||
public | ||
resources | ||
resources | ||
|
||
env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
charts: | ||
- name: aws-load-balancer-controller | ||
repository: https://aws.github.io/eks-charts | ||
chart: aws-load-balancer-controller | ||
constraint: '>=1.4.0 <1.5.0' | ||
- name: karpenter | ||
repository: https://charts.karpenter.sh | ||
chart: karpenter | ||
- name: aws-efs-csi-driver | ||
repository: https://kubernetes-sigs.github.io/aws-efs-csi-driver | ||
chart: aws-efs-csi-driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import yaml | ||
import requests | ||
import semantic_version | ||
import json | ||
|
||
def load_chart_requirements(): | ||
stream = open("charts.yaml", "r") | ||
|
||
charts = yaml.safe_load(stream) | ||
|
||
stream.close() | ||
|
||
return charts | ||
|
||
def load_terraform_variables(): | ||
f = open('../terraform/modules/cluster/helm_versions.tf.json') | ||
|
||
data = json.load(f) | ||
|
||
f.close() | ||
|
||
return data | ||
|
||
def save_terraform_variables(vars): | ||
with open('../terraform/modules/cluster/helm_versions.tf.json', 'w') as outfile: | ||
outfile.write('') | ||
json.dump(vars, outfile, indent=2, sort_keys=True) | ||
|
||
charts = load_chart_requirements() | ||
vars = { | ||
'//': "This file is auto-generated, do not modify manually", | ||
'variable': { | ||
'helm_chart_versions': { | ||
'default': {} | ||
} | ||
} | ||
} | ||
|
||
for chart in charts['charts']: | ||
url = '{}/index.yaml'.format(chart['repository']) | ||
resp = requests.get(url=url) | ||
data = yaml.safe_load(resp.content) | ||
|
||
entry = data['entries'][chart['chart']] | ||
|
||
selected_version = '' | ||
|
||
for version in entry: | ||
if 'constraint' in chart: | ||
if semantic_version.Version(version['version']) in semantic_version.NpmSpec(chart['constraint']): | ||
selected_version = version['version'] | ||
break | ||
else: | ||
selected_version = version['version'] | ||
break | ||
|
||
if selected_version == '': | ||
print('Valid version not found') | ||
else: | ||
print("Selected version {}:{}".format(chart['name'], version['version'])) | ||
|
||
vars['variable']['helm_chart_versions']['default'][chart['name']] = selected_version | ||
|
||
save_terraform_variables(vars) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
certifi==2021.10.8 | ||
charset-normalizer==2.0.12 | ||
idna==3.3 | ||
PyYAML==6.0 | ||
requests==2.27.1 | ||
semantic-version==2.9.0 | ||
urllib3==1.26.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
{ | ||
"//": "This file is auto-generated, do not modify manually", | ||
"variable": { | ||
"aws_load_balancer_controller_version": { | ||
"default": "1.4.1" | ||
"helm_chart_versions": { | ||
"default": { | ||
"aws-efs-csi-driver": "2.2.6", | ||
"aws-load-balancer-controller": "1.4.1", | ||
"karpenter": "0.9.0" | ||
} | ||
} | ||
} | ||
} |