Skip to content

feat(lmc): charts for lm-container 8.1.0-rt01 #495

feat(lmc): charts for lm-container 8.1.0-rt01

feat(lmc): charts for lm-container 8.1.0-rt01 #495

name: K8S Matrix - Helm Lint and Test Charts
on: pull_request
jobs:
lint-test:
strategy:
# max-parallel: 5
matrix:
# k8sVersion: [v1.24.0, v1.23.5, v1.22.7, v1.21.10, v1.20.15, v1.19.16, v1.17.17, v1.16.15, v1.15.12, v1.14.10 ]
# k8sVersion: [v1.24.0, v1.23.5, v1.22.7, v1.21.10, v1.20.15, v1.19.16, v1.18.20, v1.17.17, v1.16.15, v1.15.12, v1.14.10, v1.13.12]
k8sVersion: [ v1.27.1, v1.26.4, v1.25.9, v1.24.13, v1.23.17, v1.22.17, v1.21.14, v1.20.15 ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.1
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: install masterminds/vert
run: go install github.com/Masterminds/vert@latest
- name: setup yq
run: sudo snap install yq
- name: Run chart-testing (list-changed)
id: list-changed
run: |
touch changed.txt
ct list-changed --config ct.yaml > changed.txt || echo "no chart changes"
changed=$(ct list-changed --config ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
otherschanged=$(egrep -v "argus" changed.txt || echo "")
if [[ -n "$otherschanged" ]]; then
echo "::set-output name=otherschanged::true"
fi
arguschanged=$(egrep "argus" changed.txt || echo "")
if [[ -n "$arguschanged" ]]; then
echo "::set-output name=arguschanged::true"
fi
lmutilchanged=$(grep "lmutil" changed.txt || echo "")
if [[ -n "$lmutilchanged" ]]; then
echo "::set-output name=lmutilchanged::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml --excluded-charts lmutil
- name: Run chart-testing (lint) - lmutil
if: steps.list-changed.outputs.lmutilchanged == 'true'
run: ct lint --validate-yaml=false --config ct.yaml --charts charts/lmutil
- name: Create kind cluster
uses: helm/kind-action@v1.5.0
with:
config: kind-conf.yaml
node_image: kindest/node:${{ matrix.k8sVersion }}
if: steps.list-changed.outputs.changed == 'true'
#- name: Pull images beforehand ct install
# run: |
# ksmVersion=$(yq charts/argus/Chart.yaml -o json | jq ".dependencies[] | select(. | .name == \"kube-state-metrics\")" | jq .version | tr -d '"')
# version=$(helm search repo -r prometheus/kube-state-metrics --version $ksmVersion -o json | jq ".[0].app_version" | tr -d '"')
# docker pull k8s.gcr.io/kube-state-metrics/kube-state-metrics:v$version
# cnm=$(kind get clusters)
# kind load docker-image k8s.gcr.io/kube-state-metrics/kube-state-metrics:v$version --name $cnm
# cscVersion=$(yq charts/collectorset-controller/Chart.yaml -o json | jq .appVersion | tr -d '"')
# argusVersion=$(yq charts/argus/Chart.yaml -o json | jq .appVersion | tr -d '"')
# docker pull logicmonitor/collectorset-controller:$cscVersion
# kind load docker-image logicmonitor/collectorset-controller:$cscVersion --name $cnm
# docker pull logicmonitor/argus:$argusVersion
# kind load docker-image logicmonitor/argus:$argusVersion --name $cnm
- name: Run chart-testing (install) - except argus
if: steps.list-changed.outputs.otherschanged == 'true'
run: |
export K8SVERSION=${{ matrix.k8sVersion }}
while read -r line ; do
echo "installing chart $line"
ct install --config ct.yaml --charts=$line && EXIT_CODE=$(echo $?) || EXIT_CODE=$(echo $?)
if [[ $EXIT_CODE -eq 0 ]]
then
echo "$line is installable on mentioned kubernetes version $K8SVERSION"
else
vc=$(yq $line/Chart.yaml -o json | jq ".kubeVersion" | tr -d '"' | tr -d "'")
echo $vc
v=$(vert "$vc" "$K8SVERSION" || echo "")
if [[ "v$v" == "$K8SVERSION" ]]
then
echo "Error: kubeVersion constraint expects chart to be installed on $K8SVERSION, but it failed to install"
sync
exit 2
else
echo "installation failed as per constraint"
fi
fi
done < <(ct list-changed --config ct.yaml | egrep -v "argus|lmutil")
- name: Run chart-testing (install) - only argus
if: steps.list-changed.outputs.arguschanged == 'true'
run: |
export K8SVERSION=${{ matrix.k8sVersion }}
vcs=$(vert ">= 1.16.0-0" "$K8SVERSION" || echo "")
if [[ "v$vcs" == "$K8SVERSION" ]]
then
kubectl apply -f charts/collectorset-controller/crds/collectorset.yaml
else
kubectl apply -f v1beta1-cs-crd.yaml
fi
while read -r line ; do
ct install --config ct.yaml --charts=$line && EXIT_CODE=$(echo $?) || EXIT_CODE=$(echo $?)
if [[ $EXIT_CODE -eq 0 ]]
then
echo "$line is installable on mentioned kubernetes version $K8SVERSION"
else
vc=$(yq $line/Chart.yaml -o json | jq ".kubeVersion" | tr -d '"' | tr -d "'")
echo $vc
v=$(vert "$vc" "$K8SVERSION" || echo "")
if [[ "v$v" == "$K8SVERSION" ]]
then
echo "Error: kubeVersion constraint expects chart to be installed on $K8SVERSION, but it failed to install"
sync
exit 3
else
echo "installation failed as per constraint"
fi
fi
done < <(echo "charts/argus")
if [[ "v$vcs" == "$K8SVERSION" ]]
then
kubectl delete -f charts/collectorset-controller/crds/collectorset.yaml
else
kubectl delete -f v1beta1-cs-crd.yaml
fi