Skip to content

Instantly share code, notes, and snippets.

@garethr
Created December 6, 2017 16:30
Show Gist options
  • Save garethr/f38b7f6990021f9186759ba845cf0f78 to your computer and use it in GitHub Desktop.
Save garethr/f38b7f6990021f9186759ba845cf0f78 to your computer and use it in GitHub Desktop.
Demo from KubeCon metadata talk of kubetest
$ docker run -it -v ${PWD}:/examples garethr/kubetest --tests /examples/tests /examples/app1.yaml --verbose
INFO /examples/app1.yaml should indicate which team owns the deployment
apiVersion: apps/v1beta2 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template: # create pods using pod definition in this template
metadata:
# unlike pod-nginx.yaml, the name is not included in the meta data as a unique name is
# generated from the deployment name
labels:
app: nginx
team: team-shamu
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
#// vim: set ft=python:
def test_for_team_label():
if spec["kind"] == "Deployment":
labels = spec["spec"]["template"]["metadata"]["labels"]
assert_contains(labels, "team", "should indicate which team owns the deployment")
test_for_team_label()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment