Skip to content

Fix duplicate labels key in metadata in aggregator StatefulSet (cherry-pick #3053) #1306

Fix duplicate labels key in metadata in aggregator StatefulSet (cherry-pick #3053)

Fix duplicate labels key in metadata in aggregator StatefulSet (cherry-pick #3053) #1306

Workflow file for this run

name: Chart build
on:
workflow_dispatch: {}
# Normally using pull_request_target along with checking out the ref of the PR is not
# a good idea, but this is low risk since it's a Helm chart repo.
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
# pull_request:
# branches:
# - develop
jobs:
test-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
# Lint all chart values including those in the ci directory.
- name: Run chart-testing (lint)
run: ct lint --chart-dirs=cost-analyzer/ --charts cost-analyzer/ --validate-maintainers=false
# Run `helm template` on the main values file plus all those in the ci directory.
- name: Helm template
run: |
helm template cost-analyzer/ -f cost-analyzer/values.yaml > full.yaml
directory="cost-analyzer/ci"
for file in "$directory"/*; do
if [ -f "$file" ]; then
helm template cost-analyzer/ -f "$file" >> full.yaml
fi
done
# Run Kubeconform on the combined, templatized output across all tested values stored in `full.yaml`.
# Ensure all the rendered resources are valid.
- name: Kubeconform
uses: docker://ghcr.io/yannh/kubeconform:latest
with:
entrypoint: /kubeconform
args: "-summary -output text full.yaml"
# Test cluster versions.
deploy-chart:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
k8s-version:
- name: v1.20
version: v1.20.15
- name: v1.21
version: v1.21.14
- name: v1.22
version: v1.22.17
- name: v1.23
version: v1.23.17
- name: v1.24
version: v1.24.15
- name: v1.25
version: v1.25.11
- name: v1.26
version: v1.26.6
- name: v1.27
version: v1.27.3
- name: v1.28
version: v1.28.0
- name: v1.29
version: v1.29.0
needs: test-chart
name: ${{ matrix.k8s-version.name }} test
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Create KinD cluster
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
with:
version: v0.20.0
node_image: kindest/node:${{ matrix.k8s-version.version }}
kubectl_version: ${{ matrix.k8s-version.version }}
# Create necessary test files in the cluster. Some configurations of the chart
# require pre-existing files like Secrets in order for volume mounts to be valid. Without them,
# Pods won't come up and tests will fail.
- name: Create kubecost Namespace and test files
run: |
kubectl create ns kubecost
kubectl -n kubecost create -f .github/ci-files
# Install the chart with default values and check results.
- name: Install Kubecost chart
working-directory: ./cost-analyzer
run: helm install --wait --wait-for-jobs kubecost . -n kubecost
# run: ct install --namespace kubecost --chart-dirs=cost-analyzer/ --charts cost-analyzer/
- name: Wait for ready
run: kubectl wait -n kubecost --for=condition=ready pod --selector app.kubernetes.io/name=cost-analyzer --timeout=120s
- name: Run Helm tests
run: helm test -n kubecost kubecost
- name: Uninstall chart
run: helm uninstall kubecost -n kubecost --no-hooks --wait
- name: Cleanup all Pods in Kubecost Namespace
run: kubectl -n kubecost delete deployments,daemonsets,statefulsets,pods --all --force
# Loops over all the other values files in the ci directory and installs the chart, runs Helm tests, and uninstalls.
# Additional sleeps seem necessary for the main Kubecost Pod to be completely available, both frontend and backend.
- name: Install, test, remove chart for other values
id: loopingtests
run: |
directory="cost-analyzer/ci"
for file in "$directory"/*; do
if [ -f "$file" ]; then
echo "### Sleeping for 30 seconds ###"
sleep 30
echo "### Performing installation with values from $file ###"
helm install --wait --wait-for-jobs kubecost cost-analyzer/ -n kubecost -f "$file"
echo "### Waiting for cost-analyzer Pod readiness. ###"
kubectl wait -n kubecost --for=condition=ready pod --selector app.kubernetes.io/name=cost-analyzer --timeout=120s
echo "### Sleeping for 60 seconds longer. ###"
sleep 60
echo "### [DEBUG] Listing Pods in Kubecost Namespace. ###"
kubectl -n kubecost get pods
echo "### Performing helm tests ###"
helm test -n kubecost $(helm ls -n kubecost --all --short)
echo "### Performing uninstallation ###"
helm uninstall $(helm ls -n kubecost --all --short) -n kubecost --no-hooks --wait
echo "### Cleaning up all Pods and Pod controllers in Kubecost Namespace ###"
kubectl -n kubecost delete deployments,daemonsets,statefulsets,pods --all --force
fi
done