Skip to content

Commit

Permalink
CP-22731: add insights-controller chart (#97)
Browse files Browse the repository at this point in the history
* CP-22731: include cz-insights-controller as subchart

* increase replicacount for tag server

* CP-22731: add beta testing

* update release process for insights controller

* update release workflow

* make most resources off by default

* update readme

* use global for secret names

* incorporate changes from 0.0.30-beta

* add beta release doc

* use local chart for testing

---------

Co-authored-by: josephbarnett <[email protected]>
  • Loading branch information
dmepham and josephbarnett authored Nov 14, 2024
1 parent d618ea4 commit 1a7a45c
Show file tree
Hide file tree
Showing 29 changed files with 1,102 additions and 188 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/build-and-publish-beta-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@ jobs:
- name: Install Helm
uses: azure/setup-helm@v3

- name: Build Dependencies
- name: Build Insights Controller Dependencies
run: helm dependency update charts/cloudzero-insights-controller/

- name: Package Insights Controller Chart
run: helm package charts/cloudzero-insights-controller/ --destination .deploy

- name: Build Cloudzero Agent Dependencies
run: helm dependency update charts/cloudzero-agent/

- name: Package Cloudzero Agent Chart
run: helm package charts/cloudzero-agent/ --destination .deploy

# Step 3: Determine Version
- name: Get Github Tag Version
id: version
Expand All @@ -63,6 +72,11 @@ jobs:
VERSION_LINE=$(awk '/version:/ && !done {print NR; done=1}' charts/cloudzero-agent/Chart.yaml)
sed -i ''$VERSION_LINE's/.*/version: ${{ env.NEW_VERSION }}/' charts/cloudzero-agent/Chart.yaml
- name: Update Chart Version for insights-controller
run: |
VERSION_LINE=$(awk '/version:/ && !done {print NR; done=1}' charts/cloudzero-insights-controller/Chart.yaml)
sed -i ''$VERSION_LINE's/.*/version: ${{ env.NEW_VERSION }}/' charts/cloudzero-insights-controller/Chart.yaml
- name: Validate Release Notes are Present
run: |
if [ ! -f "docs/releases/${{ env.NEW_VERSION }}.md" ]; then
Expand All @@ -84,7 +98,13 @@ jobs:
continue-on-error: true

# Step 7: Handle Artifacts and Update Pages
- name: Upload Chart as Artifact
- name: Upload Insight Controller Chart as Artifact
uses: actions/upload-artifact@v4
with:
name: agent-chart
path: .deploy/cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz

- name: Upload Cloudzero Agent Chart as Artifact
uses: actions/upload-artifact@v4
with:
name: agent-chart
Expand All @@ -97,6 +117,7 @@ jobs:
- name: Move release Tarball
run: |
cp .deploy/cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz ./beta/
cp .deploy/cloudzero-agent-${{ env.NEW_VERSION }}.tgz ./beta/
rm -fr .deploy
Expand Down
28 changes: 23 additions & 5 deletions .github/workflows/build-and-publish-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,28 @@ jobs:
VERSION_LINE=$(awk '/version:/ && !done {print NR; done=1}' charts/cloudzero-agent/Chart.yaml)
sed -i ''$VERSION_LINE's/.*/version: ${{ env.NEW_VERSION }}/' charts/cloudzero-agent/Chart.yaml
- name: Update Chart Version for insights-controller
run: |
VERSION_LINE=$(awk '/version:/ && !done {print NR; done=1}' charts/cloudzero-insights-controller/Chart.yaml)
sed -i ''$VERSION_LINE's/.*/version: ${{ env.NEW_VERSION }}/' charts/cloudzero-insights-controller/Chart.yaml
- name: Validate Release Notes are Present
run: |
if [ ! -f "charts/cloudzero-agent/docs/releases/${{ env.NEW_VERSION }}.md" ]; then
echo "Release notes for ${{ env.NEW_VERSION }} are missing. Please create a release notes file at charts/cloudzero-agent/docs/releases/${{ env.NEW_VERSION }}.md"
exit 1
fi
- name: Build Dependencies
- name: Build Insights Controller Dependencies
run: helm dependency update charts/cloudzero-insights-controller/

- name: Package Insights Controller Chart
run: helm package charts/cloudzero-insights-controller/ --destination .deploy

- name: Build Cloudzero Agent Dependencies
run: helm dependency update charts/cloudzero-agent/

# Step 5: Package and Commit Chart
- name: Package Chart
- name: Package Cloudzero Agent Chart
run: helm package charts/cloudzero-agent/ --destination .deploy

- name: Get Main Changelog Beginning Hash
Expand All @@ -104,18 +114,26 @@ jobs:
echo "::set-output name=changes::${CHANGES}"
# Step 7: Handle Artifacts and Update Pages
- name: Upload Chart as Artifact
- name: Upload Insight Controller Chart as Artifact
uses: actions/upload-artifact@v4
with:
name: agent-chart
path: .deploy/cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz

- name: Upload Cloudzero Agent Chart as Artifact
uses: actions/upload-artifact@v4
with:
name: agent-chart
path: .deploy/cloudzero-agent-${{ env.NEW_VERSION }}.tgz


- name: Checkout GH Pages
run: |
git checkout -f gh-pages
- name: Move release Tarball
run: |
cp .deploy/cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz ./
cp .deploy/cloudzero-agent-${{ env.NEW_VERSION }}.tgz ./
rm -fr .deploy
Expand All @@ -125,7 +143,7 @@ jobs:
- name: Save Index in GH Pages
run: |
# copy the new chart and index.yaml
git add cloudzero-agent-${{ env.NEW_VERSION }}.tgz index.yaml
git add cloudzero-insights-controller-${{ env.NEW_VERSION }}.tgz cloudzero-agent-${{ env.NEW_VERSION }}.tgz index.yaml
git commit -m "Updating ${{ env.NEW_VERSION }} Index"
git push origin gh-pages
continue-on-error: true
Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/test-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
env:
# Agent Chart settings (prom repo is to work around issue with chart-testing tool)
PROM_CHART_REPO: https://prometheus-community.github.io/helm-charts
CZ_CHART_REPO: https://cloudzero.github.io/cloudzero-charts
CZ_CHART_BETA_REPO: https://cloudzero.github.io/cloudzero-charts/beta
CLUSTER_NAME: cz-node-agent-ci
CLOUD_ACCOUNT_ID: '00000000'
CZ_API_TOKEN: 'fake-api-token'
Expand All @@ -46,6 +48,7 @@ jobs:
ct lint --debug --charts . \
--chart-repos=kube-state-metrics=$PROM_CHART_REPO \
--chart-repos=prometheus-node-exporter=$PROM_CHART_REPO \
--chart-repos=cloudzero-insights-controller=$CZ_CHART_BETA_REPO \
--helm-lint-extra-args "--set=existingSecretName=api-token,clusterName=$CLUSTER_NAME,cloudAccountId=$CLOUD_ACCOUNT_ID,region=$REGION"
# This job tests the chart on a KinD cluster
Expand Down Expand Up @@ -100,6 +103,18 @@ jobs:
echo "SKIP_VALIDATIONS=true" >>${GITHUB_ENV}
fi
- name: TEST PREP - Update dependency path for local insights-controller testing
run: |
full_path=$(pwd)/charts/cloudzero-insights-controller
awk -v dir="$full_path" '
/name: cloudzero-insights-controller/ {flag=1}
flag && /repository:/ {sub(/repository: .*/, "repository: file://" dir); flag=0}
{print}
' charts/cloudzero-agent/Chart.yaml > temp.yaml && mv temp.yaml charts/cloudzero-agent/Chart.yaml
cd charts/cloudzero-insights-controller
helm dependency update
cd ../../
# Install the chart using our temporary image
- name: TEST - Install the chart
id: test_chart_installation
Expand All @@ -108,23 +123,32 @@ jobs:
NAMESPACE: monitoring
# Agent Chart settings (prom repo is to work around issue with chart-testing tool)
PROM_CHART_REPO: https://prometheus-community.github.io/helm-charts
CZ_CHART_REPO: https://cloudzero.github.io/cloudzero-charts
CZ_CHART_BETA_REPO: https://cloudzero.github.io/cloudzero-charts/beta
CLUSTER_NAME: cz-node-agent-ci
CLOUD_ACCOUNT_ID: '00000000'
CZ_API_TOKEN: ${{ secrets.CZ_API_TOKEN || 'fake-api-token' }}
REGION: 'us-east-1'
run: |
run: |
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.crds.yaml
kubectl create namespace $NAMESPACE
kubectl create secret -n $NAMESPACE generic api-token --from-literal=value=$CZ_API_TOKEN
cd charts/cloudzero-agent
helm dependency update
ct install --charts . \
--chart-repos=kube-state-metrics=$PROM_CHART_REPO \
--chart-repos=prometheus-node-exporter=$PROM_CHART_REPO \
--chart-repos=cloudzero-insights-controller=$CZ_CHART_BETA_REPO \
--namespace $NAMESPACE \
--helm-extra-set-args "\
--set=existingSecretName=api-token \
--set=global.existingSecretName=api-token \
--set=host=dev-api.cloudzero.com \
--set=clusterName=$CLUSTER_NAME \
--set=cloudAccountId=$CLOUD_ACCOUNT_ID \
--set=region=$REGION \
--set=kube-state-metrics.enabled=true \
--set=prometheus-node-exporter.enabled=true"
--set=prometheus-node-exporter.enabled=true \
--set=tags.enabled=true \
--set=tags.labels.enabled=true \
--set=tags.labels.patterns[0]='.*' \
"
10 changes: 5 additions & 5 deletions charts/cloudzero-agent/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dependencies:
- name: kube-state-metrics
repository: https://prometheus-community.github.io/helm-charts
version: 5.15.3
- name: prometheus-node-exporter
repository: https://prometheus-community.github.io/helm-charts
version: 4.24.0
digest: sha256:827a33fa07fde17be0bf808e0beba3ca7b23c9fc1960580b2ba6d0ecc0b57a3f
generated: "2024-03-20T11:42:44.034766-04:00"
- name: cloudzero-insights-controller
repository: https://cloudzero.github.io/cloudzero-charts/beta
version: 0.0.1
digest: sha256:87c19ba797e44296e4ac2433e17f24b73bcda8c9ee8b4286bc31c0d7fd0f0224
generated: "2024-11-13T12:34:06.381064+01:00"
9 changes: 5 additions & 4 deletions charts/cloudzero-agent/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ dependencies:
version: "5.15.*"
repository: https://prometheus-community.github.io/helm-charts
condition: kube-state-metrics.enabled
- name: prometheus-node-exporter
version: "4.24.*"
repository: https://prometheus-community.github.io/helm-charts
condition: prometheus-node-exporter.enabled
- name: cloudzero-insights-controller
version: "0.0.1"
repository: https://cloudzero.github.io/cloudzero-charts/beta
condition: cloudzero-insights-controller.enabled
alias: tags
Loading

0 comments on commit 1a7a45c

Please sign in to comment.