From 979ecd44dce73a3105fc4da14336f2f37eb6b613 Mon Sep 17 00:00:00 2001 From: Sergio Talens-Oliag Date: Thu, 1 May 2025 14:58:02 +0200 Subject: [PATCH] feat(dummyhttp): first version of the application --- dummyhttp/README.md | 15 +++++++++++++++ dummyhttp/deployment.yaml | 36 ++++++++++++++++++++++++++++++++++++ dummyhttp/ingress.yaml | 18 ++++++++++++++++++ dummyhttp/kustomization.yaml | 7 +++++++ dummyhttp/msr.yaml | 1 + dummyhttp/service.yaml | 11 +++++++++++ 6 files changed, 88 insertions(+) create mode 100644 dummyhttp/README.md create mode 100644 dummyhttp/deployment.yaml create mode 100644 dummyhttp/ingress.yaml create mode 100644 dummyhttp/kustomization.yaml create mode 100644 dummyhttp/msr.yaml create mode 100644 dummyhttp/service.yaml diff --git a/dummyhttp/README.md b/dummyhttp/README.md new file mode 100644 index 0000000..8fb4854 --- /dev/null +++ b/dummyhttp/README.md @@ -0,0 +1,15 @@ +# Dummyhttp kustomize application + +This application deploys a container that runs an instance of the [dummyhttp](https://github.com/svenstaro/dummyhttp) +application that returns a string that uses environment variables added to the container from a `ConfigMap` and a +`Secret`. + +The container image is built from a generic +[Dockerfile](https://forgejo.mixinet.net/oci/images/src/tag/dummyhttp-v1.0.0/dummyhttp/Dockerfile) that runs the +application directly, but we have modified the arguments on the `Deployment` to be able to use environment variables on +the arguments to the server (we use `/bin/sh -c` as entrypoint and the command uses `eval` to expand the environment +variables when calling the application). + +The base application includes a `Deployment`, a `Service` and an `Ingress` definition; the `Deployment` uses environment +variables from a `ConfigMap` and a `Secret` if they are available, but we've marked them as optional to be able to +deploy the application without having them available. diff --git a/dummyhttp/deployment.yaml b/dummyhttp/deployment.yaml new file mode 100644 index 0000000..ad67cb4 --- /dev/null +++ b/dummyhttp/deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dummyhttp + labels: + app: dummyhttp +spec: + selector: + matchLabels: + app: dummyhttp + template: + metadata: + labels: + app: dummyhttp + spec: + containers: + - name: dummyhttp + image: forgejo.mixinet.net/oci/dummyhttp:1.0.0 + command: [ "/bin/sh", "-c" ] + args: + - 'eval dummyhttp -b \"{\\\"c\\\": \\\"$CM_VAR\\\", \\\"s\\\": \\\"$SECRET_VAR\\\"}\"' + ports: + - containerPort: 8080 + env: + - name: CM_VAR + valueFrom: + configMapKeyRef: + name: dummyhttp-configmap + key: CM_VAR + optional: true + - name: SECRET_VAR + valueFrom: + secretKeyRef: + name: dummyhttp-secret + key: SECRET_VAR + optional: true diff --git a/dummyhttp/ingress.yaml b/dummyhttp/ingress.yaml new file mode 100644 index 0000000..a5c478a --- /dev/null +++ b/dummyhttp/ingress.yaml @@ -0,0 +1,18 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: dummyhttp + annotations: + traefik.ingress.kubernetes.io/router.tls: "true" +spec: + rules: + - host: dummyhttp.localhost.mixinet.net + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: dummyhttp + port: + number: 80 diff --git a/dummyhttp/kustomization.yaml b/dummyhttp/kustomization.yaml new file mode 100644 index 0000000..835afa8 --- /dev/null +++ b/dummyhttp/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- deployment.yaml +- service.yaml +- ingress.yaml diff --git a/dummyhttp/msr.yaml b/dummyhttp/msr.yaml new file mode 100644 index 0000000..2ef3d52 --- /dev/null +++ b/dummyhttp/msr.yaml @@ -0,0 +1 @@ +version: 1.0.0 diff --git a/dummyhttp/service.yaml b/dummyhttp/service.yaml new file mode 100644 index 0000000..7ba81e1 --- /dev/null +++ b/dummyhttp/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: dummyhttp +spec: + selector: + app: dummyhttp + ports: + - name: http + port: 80 + targetPort: 8080