From 60dfafd51076fbcd1a3dfc164cb079f2bcb1893f Mon Sep 17 00:00:00 2001 From: James Callahan Date: Tue, 22 Aug 2023 11:39:30 +1000 Subject: [PATCH] feat: add a kustomize base to the repository --- README.md | 8 ++++++++ kustomize/README.md | 39 ++++++++++++++++++++++++++++++++++++ kustomize/kustomization.yaml | 8 ++++++++ kustomize/resources.yaml | 34 +++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 kustomize/README.md create mode 100644 kustomize/kustomization.yaml create mode 100644 kustomize/resources.yaml diff --git a/README.md b/README.md index 682835cc..e5d1d52b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,14 @@ $ docker run -P mccutchen/go-httpbin $ docker run -e HTTPS_CERT_FILE='/tmp/server.crt' -e HTTPS_KEY_FILE='/tmp/server.key' -p 8080:8080 -v /tmp:/tmp mccutchen/go-httpbin ``` +### Kubernetes + +``` +$ kubectl apply -k github.com/mccutchen/go-httpbin/kustomize +``` + +See `./kustomize` directory for further information + ### Standalone binary Follow the [Installation](#installation) instructions to install go-httpbin as diff --git a/kustomize/README.md b/kustomize/README.md new file mode 100644 index 00000000..9bf0a656 --- /dev/null +++ b/kustomize/README.md @@ -0,0 +1,39 @@ +This folder is a [kustomize application](https://kubectl.docs.kubernetes.io/references/kustomize/glossary/#application) that stands up a running instance of go-httpbin in a Kubernetes cluster. + +You may wish to utilise this as a [remote application](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/resource/), e.g. + +```yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +commonLabels: + app.kubernetes.io/name: httpbin +resources: + - github.com/mccutchen/go-httpbin/kustomize +images: + - name: mccutchen/go-httpbin +``` + +To expose your instance to the internet, you could add an `Ingress` in an overlay: +```yaml +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: httpbin +spec: + ingressClassName: myingressname + rules: + - host: my-go-httpbin.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: httpbin + port: + name: http + tls: + - hosts: + - my-go-httpbin.com + secretName: go-httpbin-tls +``` diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml new file mode 100644 index 00000000..319cabc3 --- /dev/null +++ b/kustomize/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +commonLabels: + app.kubernetes.io/name: httpbin +resources: + - resources.yaml +images: + - name: mccutchen/go-httpbin diff --git a/kustomize/resources.yaml b/kustomize/resources.yaml new file mode 100644 index 00000000..cc1c3e87 --- /dev/null +++ b/kustomize/resources.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: httpbin +spec: + template: + spec: + containers: + - name: httpbin + image: mccutchen/go-httpbin + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /status/200 + port: http + readinessProbe: + httpGet: + path: /status/200 + port: http + resources: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: httpbin +spec: + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http