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