From 2093f72602b788b6c12a909855c9dcb34fd07928 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 7 Mar 2022 21:58:17 +0000 Subject: [PATCH] Add a skeleton k8s deployment setup DNS will come later --- ansible/yamllint.yml | 18 +----------------- k8s/kustomization.yml | 4 ++++ k8s/whoami/deployment.yml | 24 ++++++++++++++++++++++++ k8s/whoami/ingress.yml | 17 +++++++++++++++++ k8s/whoami/kustomization.yml | 8 ++++++++ k8s/whoami/namespace.yml | 4 ++++ k8s/whoami/service.yml | 13 +++++++++++++ scripts/k8s/apply.sh | 5 +++++ scripts/k8s/lint.sh | 7 +++++++ yamllint.yml | 17 +++++++++++++++++ 10 files changed, 100 insertions(+), 17 deletions(-) mode change 100644 => 120000 ansible/yamllint.yml create mode 100644 k8s/kustomization.yml create mode 100644 k8s/whoami/deployment.yml create mode 100644 k8s/whoami/ingress.yml create mode 100644 k8s/whoami/kustomization.yml create mode 100644 k8s/whoami/namespace.yml create mode 100644 k8s/whoami/service.yml create mode 100755 scripts/k8s/apply.sh create mode 100755 scripts/k8s/lint.sh create mode 100644 yamllint.yml diff --git a/ansible/yamllint.yml b/ansible/yamllint.yml deleted file mode 100644 index 2dd2400..0000000 --- a/ansible/yamllint.yml +++ /dev/null @@ -1,17 +0,0 @@ -extends: default - -ignore: | - ansible/galaxy_roles - ansible/galaxy_collections - ansible/group_vars/all/hosts.yml - ansible/roles/traefik/files/traefik.yml - ansible/roles/nebula/files/nebula.yml - -rules: - document-start: disable - truthy: disable - quoted-strings: - quote-type: double - required: only-when-needed - line-length: - max: 160 diff --git a/ansible/yamllint.yml b/ansible/yamllint.yml new file mode 120000 index 0000000..ad62d0d --- /dev/null +++ b/ansible/yamllint.yml @@ -0,0 +1 @@ +./yamllint.yml \ No newline at end of file diff --git a/k8s/kustomization.yml b/k8s/kustomization.yml new file mode 100644 index 0000000..338d5e1 --- /dev/null +++ b/k8s/kustomization.yml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - whoami diff --git a/k8s/whoami/deployment.yml b/k8s/whoami/deployment.yml new file mode 100644 index 0000000..2299d1f --- /dev/null +++ b/k8s/whoami/deployment.yml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: whoami +spec: + selector: + matchLabels: + app: whoami + replicas: 2 + template: + metadata: + labels: + app: whoami + spec: + containers: + - name: whoami + image: traefik/whoami + readinessProbe: + httpGet: + path: / + port: 80 + ports: + - containerPort: 80 + imagePullPolicy: Always diff --git a/k8s/whoami/ingress.yml b/k8s/whoami/ingress.yml new file mode 100644 index 0000000..71e6a6e --- /dev/null +++ b/k8s/whoami/ingress.yml @@ -0,0 +1,17 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: whoami +spec: + ingressClassName: nginx + rules: + - host: whoami.localhost + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: whoami + port: + number: 80 diff --git a/k8s/whoami/kustomization.yml b/k8s/whoami/kustomization.yml new file mode 100644 index 0000000..30a02f5 --- /dev/null +++ b/k8s/whoami/kustomization.yml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: whoami +resources: + - deployment.yml + - ingress.yml + - namespace.yml + - service.yml diff --git a/k8s/whoami/namespace.yml b/k8s/whoami/namespace.yml new file mode 100644 index 0000000..f7d1afe --- /dev/null +++ b/k8s/whoami/namespace.yml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: whoami diff --git a/k8s/whoami/service.yml b/k8s/whoami/service.yml new file mode 100644 index 0000000..39f0019 --- /dev/null +++ b/k8s/whoami/service.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: whoami + labels: + app: whoami +spec: + ports: + - port: 80 + targetPort: 80 + protocol: TCP + selector: + app: whoami diff --git a/scripts/k8s/apply.sh b/scripts/k8s/apply.sh new file mode 100755 index 0000000..5ab9cbe --- /dev/null +++ b/scripts/k8s/apply.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +kubectl apply -k ./k8s diff --git a/scripts/k8s/lint.sh b/scripts/k8s/lint.sh new file mode 100755 index 0000000..7fc9627 --- /dev/null +++ b/scripts/k8s/lint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +PATH=${PWD}/env/bin:${PATH} + +yamllint -c ./yamllint.yml ./k8s diff --git a/yamllint.yml b/yamllint.yml new file mode 100644 index 0000000..2dd2400 --- /dev/null +++ b/yamllint.yml @@ -0,0 +1,17 @@ +extends: default + +ignore: | + ansible/galaxy_roles + ansible/galaxy_collections + ansible/group_vars/all/hosts.yml + ansible/roles/traefik/files/traefik.yml + ansible/roles/nebula/files/nebula.yml + +rules: + document-start: disable + truthy: disable + quoted-strings: + quote-type: double + required: only-when-needed + line-length: + max: 160