From 813a7787c1ab62d50d9f0f974df5a1e6078ff897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my-Christophe=20Schermesser?= Date: Tue, 14 May 2019 18:04:12 +0200 Subject: [PATCH] chore: lint yaml (#19) --- .markdownlint.yml | 1 + .yamllint | 6 ++++ 05-pods/01-simple-pod.yml | 5 +-- 06-label-annotation/01-simple-pod.yml | 5 +-- 06-label-annotation/02-nginx.yml | 5 +-- 07-deployment/01-simple-deployment.yml | 9 +++--- 08-service/01-simple-deployment.yml | 11 ++++--- 08-service/02-bash.yml | 5 +-- 08-service/03-simple-service.yml | 5 +-- 08-service/04-ingress.yml | 2 +- 09-cronjob/01-simple-cronjob.yml | 7 +++-- 09-cronjob/02-simple-job.yml | 9 +++--- 10-secrets/01-secrets.yml | 3 +- 11-probes/01-liveness-probe.yml | 19 ++++++------ 11-probes/02-readiness-probe.yml | 26 ++++++++-------- .../01-pod-anti-affinity.yml | 8 ++--- .../02-node-affinity.yml | 24 +++++++------- 14-pdb/kind.yml | 7 +++-- 15-hpa-vpa/02-hpa.yml | 3 +- 16-sidecar-containers/01-sidecar.yml | 29 ++++++++--------- 17-volumes/01-simple-mysql-pv.yml | 1 + 17-volumes/02-simple-mysql-pvc.yml | 1 + 17-volumes/03-simple-mysql-deployment.yml | 27 ++++++++-------- 17-volumes/04-simple-mysql-service.yml | 5 +-- 18-stateful-set/03-statefulset.yml | 31 ++++++++++--------- 99-good-practices/yamllint | 2 +- 26 files changed, 141 insertions(+), 115 deletions(-) create mode 100644 .yamllint diff --git a/.markdownlint.yml b/.markdownlint.yml index ae25882..d1c665c 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,2 +1,3 @@ +--- MD013: false # long lines MD034: false # bare urls diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..9779dcc --- /dev/null +++ b/.yamllint @@ -0,0 +1,6 @@ +extends: default + +rules: + line-length: disable + comments: + min-spaces-from-content: 1 diff --git a/05-pods/01-simple-pod.yml b/05-pods/01-simple-pod.yml index 6726fdc..375c00a 100644 --- a/05-pods/01-simple-pod.yml +++ b/05-pods/01-simple-pod.yml @@ -1,8 +1,9 @@ +--- apiVersion: v1 kind: Pod metadata: name: simple-pod spec: containers: - - name: simple-pod - image: mhausenblas/simpleservice:0.5.0 + - name: simple-pod + image: mhausenblas/simpleservice:0.5.0 diff --git a/06-label-annotation/01-simple-pod.yml b/06-label-annotation/01-simple-pod.yml index 5021941..65ae5b1 100644 --- a/06-label-annotation/01-simple-pod.yml +++ b/06-label-annotation/01-simple-pod.yml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: Pod metadata: @@ -7,5 +8,5 @@ metadata: tier: backend spec: containers: - - name: simple-pod - image: mhausenblas/simpleservice:0.5.0 \ No newline at end of file + - name: simple-pod + image: mhausenblas/simpleservice:0.5.0 diff --git a/06-label-annotation/02-nginx.yml b/06-label-annotation/02-nginx.yml index ee8b62a..02df998 100644 --- a/06-label-annotation/02-nginx.yml +++ b/06-label-annotation/02-nginx.yml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: Pod metadata: @@ -7,5 +8,5 @@ metadata: tier: frontend spec: containers: - - name: nginx - image: nginx + - name: nginx + image: nginx diff --git a/07-deployment/01-simple-deployment.yml b/07-deployment/01-simple-deployment.yml index e1688ea..a36bf24 100644 --- a/07-deployment/01-simple-deployment.yml +++ b/07-deployment/01-simple-deployment.yml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -13,7 +14,7 @@ spec: app: simple-deployment spec: containers: - - name: simple-pod - image: mhausenblas/simpleservice:0.4.0 - ports: - - containerPort: 9876 + - name: simple-pod + image: mhausenblas/simpleservice:0.4.0 + ports: + - containerPort: 9876 diff --git a/08-service/01-simple-deployment.yml b/08-service/01-simple-deployment.yml index da837f8..a36bf24 100644 --- a/08-service/01-simple-deployment.yml +++ b/08-service/01-simple-deployment.yml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -7,13 +8,13 @@ spec: selector: matchLabels: app: simple-deployment - template: + template: metadata: labels: app: simple-deployment spec: containers: - - name: simple-pod - image: mhausenblas/simpleservice:0.4.0 - ports: - - containerPort: 9876 + - name: simple-pod + image: mhausenblas/simpleservice:0.4.0 + ports: + - containerPort: 9876 diff --git a/08-service/02-bash.yml b/08-service/02-bash.yml index f953161..00e1ac4 100644 --- a/08-service/02-bash.yml +++ b/08-service/02-bash.yml @@ -1,8 +1,9 @@ +--- apiVersion: v1 kind: Pod metadata: name: bash spec: containers: - - name: bash - image: nginx + - name: bash + image: nginx diff --git a/08-service/03-simple-service.yml b/08-service/03-simple-service.yml index 822904a..579aaa6 100644 --- a/08-service/03-simple-service.yml +++ b/08-service/03-simple-service.yml @@ -1,10 +1,11 @@ +--- apiVersion: v1 kind: Service metadata: name: simple-service spec: ports: - - port: 80 - targetPort: 9876 + - port: 80 + targetPort: 9876 selector: app: simple-deployment diff --git a/08-service/04-ingress.yml b/08-service/04-ingress.yml index 840f849..99b76a7 100644 --- a/08-service/04-ingress.yml +++ b/08-service/04-ingress.yml @@ -1,3 +1,4 @@ +--- apiVersion: extensions/v1beta1 kind: Ingress metadata: @@ -8,4 +9,3 @@ spec: backend: serviceName: simple-service servicePort: 80 - diff --git a/09-cronjob/01-simple-cronjob.yml b/09-cronjob/01-simple-cronjob.yml index cdab73d..758494d 100644 --- a/09-cronjob/01-simple-cronjob.yml +++ b/09-cronjob/01-simple-cronjob.yml @@ -1,3 +1,4 @@ +--- apiVersion: batch/v1beta1 kind: CronJob metadata: @@ -10,6 +11,6 @@ spec: spec: restartPolicy: Never containers: - - name: pi - image: perl - command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(100)"] + - name: pi + image: perl + command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(100)"] diff --git a/09-cronjob/02-simple-job.yml b/09-cronjob/02-simple-job.yml index 65eda54..2d8710f 100644 --- a/09-cronjob/02-simple-job.yml +++ b/09-cronjob/02-simple-job.yml @@ -1,3 +1,4 @@ +--- apiVersion: batch/v1 kind: Job metadata: @@ -6,7 +7,7 @@ spec: template: spec: containers: - - name: c - image: busybox - command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"] - restartPolicy: Never \ No newline at end of file + - name: c + image: busybox + command: ["sh", "-c", "echo Processing item $ITEM && sleep 5"] + restartPolicy: Never diff --git a/10-secrets/01-secrets.yml b/10-secrets/01-secrets.yml index 721bffd..4c383d0 100644 --- a/10-secrets/01-secrets.yml +++ b/10-secrets/01-secrets.yml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: Secret metadata: @@ -5,4 +6,4 @@ metadata: type: Opaque data: username: YWRtaW4= - password: MWYyZDFlMmU2N2Rm \ No newline at end of file + password: MWYyZDFlMmU2N2Rm diff --git a/11-probes/01-liveness-probe.yml b/11-probes/01-liveness-probe.yml index 4128157..e61906b 100644 --- a/11-probes/01-liveness-probe.yml +++ b/11-probes/01-liveness-probe.yml @@ -1,15 +1,16 @@ +--- apiVersion: v1 kind: Pod metadata: name: liveness-probe-pod spec: containers: - - name: liveness-probe-pod - image: nginx - livenessProbe: - exec: - command: - - exit - - "1" - initialDelaySeconds: 5 - periodSeconds: 5 + - name: liveness-probe-pod + image: nginx + livenessProbe: + exec: + command: + - exit + - "1" + initialDelaySeconds: 5 + periodSeconds: 5 diff --git a/11-probes/02-readiness-probe.yml b/11-probes/02-readiness-probe.yml index 1a9cb06..2c23680 100644 --- a/11-probes/02-readiness-probe.yml +++ b/11-probes/02-readiness-probe.yml @@ -14,17 +14,17 @@ spec: app: readiness-deployment spec: containers: - - name: readiness-probe-pod - image: mhausenblas/simpleservice:0.4.0 - ports: - - containerPort: 9876 - readinessProbe: - exec: - command: - - exit - - "1" - initialDelaySeconds: 5 - periodSeconds: 5 + - name: readiness-probe-pod + image: mhausenblas/simpleservice:0.4.0 + ports: + - containerPort: 9876 + readinessProbe: + exec: + command: + - exit + - "1" + initialDelaySeconds: 5 + periodSeconds: 5 --- apiVersion: v1 kind: Service @@ -32,7 +32,7 @@ metadata: name: readiness-service spec: ports: - - port: 80 - targetPort: 9876 + - port: 80 + targetPort: 9876 selector: app: readiness-deployment diff --git a/13-affinity-anti-affinity/01-pod-anti-affinity.yml b/13-affinity-anti-affinity/01-pod-anti-affinity.yml index 9d4b7d4..997ddf8 100644 --- a/13-affinity-anti-affinity/01-pod-anti-affinity.yml +++ b/13-affinity-anti-affinity/01-pod-anti-affinity.yml @@ -17,8 +17,8 @@ spec: - nginx-pod-anti-affinity topologyKey: kubernetes.io/hostname containers: - - name: nginx - image: nginx + - name: nginx + image: nginx --- apiVersion: v1 kind: Pod @@ -38,5 +38,5 @@ spec: - nginx-pod-anti-affinity topologyKey: kubernetes.io/hostname containers: - - name: nginx - image: nginx + - name: nginx + image: nginx diff --git a/13-affinity-anti-affinity/02-node-affinity.yml b/13-affinity-anti-affinity/02-node-affinity.yml index cde3228..9e3bb7f 100644 --- a/13-affinity-anti-affinity/02-node-affinity.yml +++ b/13-affinity-anti-affinity/02-node-affinity.yml @@ -9,13 +9,13 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - - key: gpu - operator: In - values: - - "yes" + - key: gpu + operator: In + values: + - "yes" containers: - - name: nginx - image: nginx + - name: nginx + image: nginx --- apiVersion: v1 kind: Pod @@ -27,10 +27,10 @@ spec: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - - key: gpu - operator: In - values: - - "no" + - key: gpu + operator: In + values: + - "no" containers: - - name: nginx - image: nginx + - name: nginx + image: nginx diff --git a/14-pdb/kind.yml b/14-pdb/kind.yml index f7b8654..db1fdf9 100644 --- a/14-pdb/kind.yml +++ b/14-pdb/kind.yml @@ -1,7 +1,8 @@ +--- # three node (two workers) cluster config kind: Cluster apiVersion: kind.sigs.k8s.io/v1alpha3 nodes: -- role: control-plane -- role: worker -- role: worker + - role: control-plane + - role: worker + - role: worker diff --git a/15-hpa-vpa/02-hpa.yml b/15-hpa-vpa/02-hpa.yml index 9456328..50b81dd 100644 --- a/15-hpa-vpa/02-hpa.yml +++ b/15-hpa-vpa/02-hpa.yml @@ -1,3 +1,4 @@ +--- apiVersion: autoscaling/v1 kind: HorizontalPodAutoscaler metadata: @@ -9,4 +10,4 @@ spec: apiVersion: extensions/v1beta1 kind: Deployment name: simple-deployment -targetCPUUtilizationPercentage: 80 \ No newline at end of file +targetCPUUtilizationPercentage: 80 diff --git a/16-sidecar-containers/01-sidecar.yml b/16-sidecar-containers/01-sidecar.yml index 923b237..63b9ea2 100644 --- a/16-sidecar-containers/01-sidecar.yml +++ b/16-sidecar-containers/01-sidecar.yml @@ -1,21 +1,22 @@ +--- apiVersion: v1 kind: Pod metadata: name: two-containers spec: volumes: - - name: shared-data - emptyDir: {} + - name: shared-data + emptyDir: {} containers: - - name: nginx - image: nginx - volumeMounts: - - name: data - mountPath: /usr/share/nginx/html - - name: debian - image: debian - volumeMounts: - - name: data - mountPath: /pod-data - command: ["/bin/sh"] - args: ["-c", "echo Hello from the debian container > /pod-data/index.html"] + - name: nginx + image: nginx + volumeMounts: + - name: data + mountPath: /usr/share/nginx/html + - name: debian + image: debian + volumeMounts: + - name: data + mountPath: /pod-data + command: ["/bin/sh"] + args: ["-c", "echo Hello from the debian container > /pod-data/index.html"] diff --git a/17-volumes/01-simple-mysql-pv.yml b/17-volumes/01-simple-mysql-pv.yml index a509a8e..f2d0f6e 100644 --- a/17-volumes/01-simple-mysql-pv.yml +++ b/17-volumes/01-simple-mysql-pv.yml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: PersistentVolume metadata: diff --git a/17-volumes/02-simple-mysql-pvc.yml b/17-volumes/02-simple-mysql-pvc.yml index b5bacce..8079232 100644 --- a/17-volumes/02-simple-mysql-pvc.yml +++ b/17-volumes/02-simple-mysql-pvc.yml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: PersistentVolumeClaim metadata: diff --git a/17-volumes/03-simple-mysql-deployment.yml b/17-volumes/03-simple-mysql-deployment.yml index 81ab359..b139c7d 100644 --- a/17-volumes/03-simple-mysql-deployment.yml +++ b/17-volumes/03-simple-mysql-deployment.yml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -14,18 +15,18 @@ spec: app: mysql spec: containers: - - image: mysql:5.6 - name: mysql - env: - - name: MYSQL_ROOT_PASSWORD - value: password - ports: - - containerPort: 3306 + - image: mysql:5.6 name: mysql - volumeMounts: - - name: mysql-persistent-storage - mountPath: /var/lib/mysql + env: + - name: MYSQL_ROOT_PASSWORD + value: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql volumes: - - name: mysql-persistent-storage - persistentVolumeClaim: - claimName: mysql-pv-claim \ No newline at end of file + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: mysql-pv-claim diff --git a/17-volumes/04-simple-mysql-service.yml b/17-volumes/04-simple-mysql-service.yml index 4749582..1f65f7f 100644 --- a/17-volumes/04-simple-mysql-service.yml +++ b/17-volumes/04-simple-mysql-service.yml @@ -1,10 +1,11 @@ +--- apiVersion: v1 kind: Service metadata: name: mysql spec: ports: - - port: 3306 + - port: 3306 selector: app: mysql - clusterIP: None \ No newline at end of file + clusterIP: None diff --git a/18-stateful-set/03-statefulset.yml b/18-stateful-set/03-statefulset.yml index dd34733..9e8b64f 100644 --- a/18-stateful-set/03-statefulset.yml +++ b/18-stateful-set/03-statefulset.yml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: StatefulSet metadata: @@ -14,19 +15,19 @@ spec: app: nginx # has to match .spec.selector.matchLabels spec: containers: - - name: nginx - image: k8s.gcr.io/nginx-slim:0.8 - ports: - - containerPort: 80 - name: web - volumeMounts: - - name: www - mountPath: /usr/share/nginx/html + - name: nginx + image: k8s.gcr.io/nginx-slim:0.8 + ports: + - containerPort: 80 + name: web + volumeMounts: + - name: www + mountPath: /usr/share/nginx/html volumeClaimTemplates: - - metadata: - name: www - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 1Gi \ No newline at end of file + - metadata: + name: www + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/99-good-practices/yamllint b/99-good-practices/yamllint index acf220d..9779dcc 100644 --- a/99-good-practices/yamllint +++ b/99-good-practices/yamllint @@ -3,4 +3,4 @@ extends: default rules: line-length: disable comments: -min-spaces-from-content: 1 + min-spaces-from-content: 1