Skip to content

Commit 52c5030

Browse files
monotekctron
authored andcommitted
added kubeval
Signed-off-by: André Bauer <[email protected]>
1 parent 21ebaea commit 52c5030

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

Diff for: .github/ct.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
helm-extra-args: --timeout 600
1414
check-version-increment: true
1515
debug: true
16+
chart-dirs:
17+
- charts
18+
- packages
1619
chart-repos:
1720
- stable=https://kubernetes-charts.storage.googleapis.com/
1821
- bitnami=https://charts.bitnami.com

Diff for: .github/kubeval.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
#
3+
# use kubeval to validate helm generated kubernetes manifest
4+
#
5+
6+
# Copyright (c) 2019 Contributors to the Eclipse Foundation
7+
#
8+
# See the NOTICE file(s) distributed with this work for additional
9+
# information regarding copyright ownership.
10+
#
11+
# This program and the accompanying materials are made available under the
12+
# terms of the Eclipse Public License 2.0 which is available at
13+
# http://www.eclipse.org/legal/epl-2.0
14+
#
15+
# SPDX-License-Identifier: EPL-2.0
16+
17+
set -o errexit
18+
set -o pipefail
19+
20+
CHART_DIRS="$(git diff --find-renames --name-only "$(git rev-parse --abbrev-ref HEAD)" remotes/origin/master -- charts packages | grep '[cC]hart.yaml' | sed -e 's#/[Cc]hart.yaml##g')"
21+
HELM_VERSION="v3.1.1"
22+
KUBEVAL_VERSION="0.14.0"
23+
SCHEMA_LOCATION="https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/"
24+
25+
# install helm
26+
curl --silent --show-error --fail --location --output get_helm.sh https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get
27+
chmod 700 get_helm.sh
28+
./get_helm.sh --version "${HELM_VERSION}"
29+
30+
# install kubeval
31+
curl --silent --show-error --fail --location --output /tmp/kubeval.tar.gz https://github.com/instrumenta/kubeval/releases/download/"${KUBEVAL_VERSION}"/kubeval-linux-amd64.tar.gz
32+
sudo tar -C /usr/local/bin -xf /tmp/kubeval.tar.gz kubeval
33+
34+
# add helm repos to resolve dependencies
35+
helm repo add bitnami https://charts.bitnami.com
36+
helm repo add stable https://kubernetes-charts.storage.googleapis.com/
37+
38+
# validate charts
39+
for CHART_DIR in ${CHART_DIRS};do
40+
echo "helm dependency build..."
41+
helm dependency build "${CHART_DIR}"
42+
43+
echo "kubeval(idating) ${CHART_DIR##charts/} chart..."
44+
helm template "${CHART_DIR}" | kubeval --strict --ignore-missing-schemas --kubernetes-version "${KUBERNETES_VERSION#v}" --schema-location "${SCHEMA_LOCATION}"
45+
done

Diff for: .github/lint-scripts.sh

-2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,3 @@ while read -r FILE; do
2626
echo lint "${FILE}"
2727
shellcheck -x "${FILE}"
2828
done < "${TMP_FILE}"
29-
30-
rm "${TMP_FILE}"

Diff for: .github/workflows/ci.yaml

+23-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,32 @@ jobs:
4040
command: lint
4141
config: .github/ct.yaml
4242

43+
kubeval-chart:
44+
runs-on: ubuntu-latest
45+
needs: lint-chart
46+
strategy:
47+
matrix:
48+
k8s:
49+
- v1.12.10
50+
- v1.13.11
51+
- v1.14.10
52+
- v1.15.7
53+
- v1.16.4
54+
- v1.17.0
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v1
58+
- name: Run kubeval
59+
env:
60+
KUBERNETES_VERSION: ${{ matrix.k8s }}
61+
run: .github/kubeval.sh
62+
4363
install-chart:
4464
name: install-chart
4565
runs-on: ubuntu-latest
46-
needs: lint-chart
66+
needs:
67+
- lint-chart
68+
- kubeval-chart
4769
strategy:
4870
matrix:
4971
k8s:

0 commit comments

Comments
 (0)