Skip to content

Commit

Permalink
kubeval tweaks (#36)
Browse files Browse the repository at this point in the history
* kubeval changes
  • Loading branch information
WillPlatnick authored Apr 4, 2019
1 parent 9e65367 commit 0477bd9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version 5.0.0

Docker Image: quay.io/lifechurch/k8s-deploy-helper:5.0.0

## Feature

* DEPLOY: KDH will determine the Kubernetes version you are deploying against and run kubeval manifests specifically against that version.

* DEPLOY: You can now set KDH_SKIP_KUBEVAL variable to true in order to skip kubeval runs.

# Version 4.0.3

Docker Image: quay.io/lifechurch/k8s-deploy-helper:4.0.3
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ kubernetes
## Debugging
Starting in 3.0, k8s-deploy-helper renders all templates before trying to apply them. All rendered manifests are displayed in the runner for easy debugging. The rendered templates are put in ```/tmp/kubernetes``` if you want to grab them using GitLab artifacts for some reason. In addition, we now use kubeval.

## kubeval
KDH will try to figure out the version of Kubernetes you are deploying to, and then target kubeval specificaly for that version.

Optionally, you can set the KDH_SKIP_KUBEVAL variable to true in order to skip the use of kubeval.

## Canary Deploys
As of 3.0, k8s-deploy-helper will automatically support canary deployments via rewriting your deployment manifests. To use this functionality, you just need to be in a GitLab CI stage named canary, and k8s-deploy-helper will search for manifests where the ```track``` label is set to ```stable```.

Expand Down
13 changes: 9 additions & 4 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ kubectl create secret -n $KUBE_NAMESPACE \
-o yaml --dry-run | kubectl apply -n $KUBE_NAMESPACE -f -
echo "Registry secret created"

echo "Getting your Kubernetes version for kubeval purposes"
kube_version=$(kubectl version --short=true | grep Server | awk '{print $3}' | cut -d'-' -f1 | cut -d'v' -f2)

echo
export SECRET_KDH_DUMMY="useless"
echo "Creating secrets from GitLab variables"
Expand Down Expand Up @@ -119,15 +122,17 @@ if [ -d "$CI_PROJECT_DIR/kubernetes" ]; then
echo "Evaluating rendered manifests."
# Dump the templated manifests to the log for easier debugging and run kubeval against each
for filename in /tmp/kubernetes/*.yaml; do
echo "Checking for non-K8s native manifests"
echo "Checking for GKE native manifests"
if grep -q 'apiVersion: cloud.google.com' $filename; then
echo "Found non-native K8s manifest - skipping - $filename"
echo "Found GKE K8s manifest - skipping - $filename"
else
echo "Running kubeval against $filename"
echo
cat "$filename"
echo
kubeval $filename
if [ "x$KDH_SKIP_KUBEVAL" != "xtrue" ]; then
echo "Running kubeval against $filename"
kubeval -v $kube_version $filename
fi
fi
done
echo "Evaluation finished."
Expand Down

0 comments on commit 0477bd9

Please sign in to comment.