From 39982e516d5cac820cd45de70690b383455d9c78 Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 27 Feb 2024 21:14:12 -0800 Subject: [PATCH] Sample secondary configuration for another website --- .../k8s/alternate.temprah-lab.xyz/main.yaml | 37 +++++++++++ infra/vultr-kubernetes/k8s/readme.md | 62 +++++++++++++++++++ .../letsencrypt-certificate.yaml | 0 .../letsencrypt-issuer.yaml | 0 .../k8s/{ => temprah-lab.xyz}/nginx-dep.yaml | 0 .../{ => temprah-lab.xyz}/nginx-service.yaml | 0 .../vultr-kubernetes/k8s/traefik-ingress.yaml | 12 ++++ 7 files changed, 111 insertions(+) create mode 100644 infra/vultr-kubernetes/k8s/alternate.temprah-lab.xyz/main.yaml create mode 100644 infra/vultr-kubernetes/k8s/readme.md rename infra/vultr-kubernetes/k8s/{ => temprah-lab.xyz}/letsencrypt-certificate.yaml (100%) rename infra/vultr-kubernetes/k8s/{ => temprah-lab.xyz}/letsencrypt-issuer.yaml (100%) rename infra/vultr-kubernetes/k8s/{ => temprah-lab.xyz}/nginx-dep.yaml (100%) rename infra/vultr-kubernetes/k8s/{ => temprah-lab.xyz}/nginx-service.yaml (100%) diff --git a/infra/vultr-kubernetes/k8s/alternate.temprah-lab.xyz/main.yaml b/infra/vultr-kubernetes/k8s/alternate.temprah-lab.xyz/main.yaml new file mode 100644 index 0000000..697e46e --- /dev/null +++ b/infra/vultr-kubernetes/k8s/alternate.temprah-lab.xyz/main.yaml @@ -0,0 +1,37 @@ +# Here we are going to define the deployment and service +# Basically all things directly related to the actual service we want to provide +--- +kind: Deployment +apiVersion: apps/v1 +metadata: + name: alternate-nginx-web + namespace: default + labels: + app: alternate-nginx-web +spec: + replicas: 1 + selector: + matchLabels: + app: alternate-nginx-web + template: + metadata: + labels: + app: alternate-nginx-web + spec: + # Container comes from an example thing i randomly found on docker hub + containers: + - name: alternate-nginx-web + image: dockerbogo/docker-nginx-hello-world +--- +apiVersion: v1 +kind: Service +metadata: + name: alternate-nginx-web + namespace: default +spec: + selector: + app: alternate-nginx-web + ports: + - name: http + targetPort: 80 + port: 80 diff --git a/infra/vultr-kubernetes/k8s/readme.md b/infra/vultr-kubernetes/k8s/readme.md new file mode 100644 index 0000000..57da63c --- /dev/null +++ b/infra/vultr-kubernetes/k8s/readme.md @@ -0,0 +1,62 @@ +# First we setup the ingress controller with helm + + +```sh +helm repo add traefik https://helm.traefik.io/traefik +helm repo update +# Now we can install this to our cluster +helm install --kubeconfig config.yaml traefik traefik/traefik +``` + +# Prove the service is present with + +```sh +kubectl --kubeconfig config.yaml get svc +``` + +# Create the pods + +```sh +kubectl --kubeconfig config.yaml -f k8s/nginx-dep.yaml +``` + +# Expose on port 80 + +```sh +kubectl --kubeconfig config.yaml -f k8s/nginx-service.yaml +``` + +# Create ingress on k8s + +```sh +kubectl --kubeconfig config.yaml -f k8s/traefik-ingress.yaml +``` + +# Take the external IP from the ingress + +Put that into terraform's A record for the domain since this is a load balancer +in Vultr ( actual resource apparantly ) + +# Configure cert-manager for traefik ingress + +Using the latest version from here: +https://github.com/cert-manager/cert-manager/releases/download/v1.14.2/cert-manager.crds.yaml + +```sh +kubectl --kubeconfig config.yaml \ + apply --validate=false \ + -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.2/cert-manager.yaml +``` + +# Create the cert issuer and certificate + + +```sh +kubectl --kubeconfig config.yaml apply -f k8s/letsencrypt-issuer.yaml +kubectl --kubeconfig config.yaml apply -f k8s/letsencrypt-issuer.yaml +``` + +Because we just have 1 cert for now we are looking for it's status to be `READY` + + + diff --git a/infra/vultr-kubernetes/k8s/letsencrypt-certificate.yaml b/infra/vultr-kubernetes/k8s/temprah-lab.xyz/letsencrypt-certificate.yaml similarity index 100% rename from infra/vultr-kubernetes/k8s/letsencrypt-certificate.yaml rename to infra/vultr-kubernetes/k8s/temprah-lab.xyz/letsencrypt-certificate.yaml diff --git a/infra/vultr-kubernetes/k8s/letsencrypt-issuer.yaml b/infra/vultr-kubernetes/k8s/temprah-lab.xyz/letsencrypt-issuer.yaml similarity index 100% rename from infra/vultr-kubernetes/k8s/letsencrypt-issuer.yaml rename to infra/vultr-kubernetes/k8s/temprah-lab.xyz/letsencrypt-issuer.yaml diff --git a/infra/vultr-kubernetes/k8s/nginx-dep.yaml b/infra/vultr-kubernetes/k8s/temprah-lab.xyz/nginx-dep.yaml similarity index 100% rename from infra/vultr-kubernetes/k8s/nginx-dep.yaml rename to infra/vultr-kubernetes/k8s/temprah-lab.xyz/nginx-dep.yaml diff --git a/infra/vultr-kubernetes/k8s/nginx-service.yaml b/infra/vultr-kubernetes/k8s/temprah-lab.xyz/nginx-service.yaml similarity index 100% rename from infra/vultr-kubernetes/k8s/nginx-service.yaml rename to infra/vultr-kubernetes/k8s/temprah-lab.xyz/nginx-service.yaml diff --git a/infra/vultr-kubernetes/k8s/traefik-ingress.yaml b/infra/vultr-kubernetes/k8s/traefik-ingress.yaml index 74596b8..dae6072 100644 --- a/infra/vultr-kubernetes/k8s/traefik-ingress.yaml +++ b/infra/vultr-kubernetes/k8s/traefik-ingress.yaml @@ -3,6 +3,8 @@ kind: Ingress metadata: name: traefik-ingress namespace: default + labels: + name: project-athens-lb annotations: kubernetes.io/ingress.class: traefik spec: @@ -17,3 +19,13 @@ spec: number: 80 path: / pathType: Prefix + - host: hello.temprah-lab.xyz + http: + paths: + - backend: + service: + name: alternate-nginx-web + port: + number: 80 + path: / + pathType: Prefix