Skip to content

Commit c618915

Browse files
committed
Update validation tools. And conftest
1 parent 28c72f0 commit c618915

File tree

3 files changed

+94
-8
lines changed

3 files changed

+94
-8
lines changed

Dockerfile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
FROM python:3.8-alpine3.10
1+
FROM python:3.8.2-alpine3.11
22

3-
ARG APP_VERSION=1.0
3+
ARG APP_VERSION=2.0
44

55
# https://github.com/kubernetes/kubectl/releases
6-
ARG KUBECTL_VERSION=1.16.2
6+
ARG KUBECTL_VERSION=1.18.2
77

88
# https://github.com/instrumenta/kubeval/releases
9-
ARG KUBEVAL_VERSION=0.14.0
9+
ARG KUBEVAL_VERSION=0.15.0
1010

1111
# https://pypi.org/project/yamllint/
12-
ARG YAMLLINT_VERSION=1.18.0
12+
ARG YAMLLINT_VERSION=1.23.0
1313

1414
# https://github.com/kubernetes-sigs/kustomize/releases
15-
ARG KUSTOMIZE_VERSION=3.3.0
15+
ARG KUSTOMIZE_VERSION=3.5.4
16+
17+
# https://github.com/instrumenta/conftest/releases
18+
ARG CONFTEST_VERSION=0.18.1
1619

1720
# split layers into distinct components
1821
RUN apk add --no-cache ca-certificates curl
@@ -39,6 +42,16 @@ RUN mkdir /tmp/kustomize \
3942
&& chmod +x /usr/local/bin/kustomize \
4043
&& rm -rf /tmp/kustomize
4144

45+
# Install Conftest (https://www.conftest.dev/)
46+
RUN mkdir /tmp/conftest \
47+
&& curl -L -o /tmp/conftest/conftest.tar.gz \
48+
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz \
49+
https://github.com/instrumenta/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_x86_64.tar.gz
50+
&& tar xf /tmp/conftest/conftest.tar.gz -C /tmp/conftest \
51+
&& mv /tmp/conftest/conftest /usr/local/bin \
52+
&& chmod +x /usr/local/bin/conftest \
53+
&& rm -rf /tmp/conftest
54+
4255
# Install Kubectl
4356
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl \
4457
&& chmod +x /usr/local/bin/kubectl

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

README.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,54 @@
1-
# kubeval-tools
2-
Common Validation tools for Kubernetes Manifests, yamllint, kubeval, kustomize
1+
Kubernetes Validation Tools
2+
===========================
3+
4+
Common validation and linting tools for structured configuration data, including Kubernetes YAML Manifests.
5+
6+
Why?
7+
----
8+
9+
I wasn't able to find a single docker image that contained all of the major validation tools (of which there are several!) to validate Kubernetes YAML manifest files as part of a CI/CD process before being automatically deployed to Kubernetes. This repo isn't designed to cover how to use these individual tools, but the links below should lead you to documentation for using each tool. We have found it useful to use several tools during our CI process because some check certain aspects that others cannot.
10+
11+
Usage
12+
-----
13+
14+
Grab the latest image from Docker hub: [Deck15/kubeval-tools](https://hub.docker.com/r/deck15/kubeval-tools)
15+
16+
```sh
17+
docker run --rm -it deck15/kubeval-tools /bin/sh
18+
```
19+
20+
KubeVal
21+
-------
22+
23+
[kubeval](https://kubeval.instrumenta.dev/) is a tool for validating a Kubernetes YAML or JSON configuration file. It does so using schemas generated from the Kubernetes OpenAPI specification, and therefore can validate schemas for multiple versions of Kubernetes.
24+
25+
ConfTest
26+
--------
27+
[ConfTest](https://www.conftest.dev/) is a utility to help you write tests against structured configuration data. For instance you could write tests for your Kubernetes configurations, or Tekton pipeline definitions, Terraform code, Serverless configs or any other structured data.
28+
29+
Conftest relies on the Rego language from Open Policy Agent for writing the assertions.
30+
31+
YAMLLint
32+
--------
33+
[yamllint](https://yamllint.readthedocs.io/) is a linter for YAML files.
34+
35+
yamllint does not only check for syntax validity, but for weirdnesses like key repetition and cosmetic problems such as lines length, trailing spaces, indentation, etc.
36+
37+
Kustomize
38+
---------
39+
40+
[Kustomize](https://kustomize.io/) lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is.
41+
42+
kustomize targets kubernetes; it understands and can patch kubernetes style API objects. It's like make, in that what it does is declared in a file, and it's like sed, in that it emits edited text. Kustomize traverses a Kubernetes manifest to add, remove or update configuration options without forking.
43+
44+
Kustomize is particularly useful to use with tools like [ArgoCD](https://argoproj.github.io/argo-cd/user-guide/kustomize/), [FluxCD](https://docs.fluxcd.io/en/latest/references/fluxyaml-config-files/), or [Spinnaker](https://www.spinnaker.io/guides/user/kubernetes-v2/kustomize-manifests/) to enable shared manifests (resources) across multiple clusters or environments without duplicating code. Kustomize allows overrides, merges, and other configuration features.
45+
46+
KubeCTL
47+
-------
48+
49+
[kubectl](https://kubectl.docs.kubernetes.io/) is the Kubernetes cli version of a swiss army knife, and can do many things. One of those things is being able to do a dry-run validate on a yaml file.
50+
51+
```sh
52+
$ kubectl create --dry-run --validate -f invalid.yaml
53+
```
54+

0 commit comments

Comments
 (0)