From 10b28a0692b3f2bc8f6acb67247aa8e0d2a8b984 Mon Sep 17 00:00:00 2001 From: Isaac Johnson Date: Mon, 30 Sep 2024 07:49:05 -0500 Subject: [PATCH] Add Kubernetes Deployment manifest files --- deployment/README.md | 42 ++++++++++++++++++++++++++++++++++++++ deployment/ingress.yaml | 34 ++++++++++++++++++++++++++++++ deployment/kubernetes.yaml | 32 +++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 deployment/README.md create mode 100644 deployment/ingress.yaml create mode 100644 deployment/kubernetes.yaml diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 0000000..3bd6ab5 --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,42 @@ +# Installation + +A basic installation can be invoked with `kubectl apply -f ./kubernetes.yaml` + +```yaml +$ kubectl apply -f ./kubernetes.yaml +deployment.apps/rustpad-deployment created +service/rustpad-service created +``` + +We can the verify it is running +``` +$ kubectl get svc rustpad-service +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +rustpad-service ClusterIP 10.43.83.244 80/TCP 17s +$ kubectl get pods -l app=rustpad +NAME READY STATUS RESTARTS AGE +rustpad-deployment-8799874d6-g2jxb 1/1 Running 0 26s +``` + +Then use port-forward to access +``` +$ kubectl port-forward svc/rustpad-service 8888:80 +Forwarding from 127.0.0.1:8888 -> 3030 +Forwarding from [::1]:8888 -> 3030 +Handling connection for 8888 +``` + +## Ingress + +Ingress depends much on your cluster-issuer and DNS names + +In the example `ingress.yaml` my ClusterIssuer is 'myclusterissuer', my ingress provider is 'nginx' and my DNS name is 'rustpad.example.com' + +Replace with your own to create a proper TLS ingress for Rustpad, then apply + +``` +$ kubectl apply -f ./ingress.yaml +ingress.networking.k8s.io/rustpadgcpingress created +``` + +Note: if you use a different Ingress provider than Nginx, ensure it can support websocket forwarding if you want it to "connect" to the backend server. \ No newline at end of file diff --git a/deployment/ingress.yaml b/deployment/ingress.yaml new file mode 100644 index 0000000..f8e2a1b --- /dev/null +++ b/deployment/ingress.yaml @@ -0,0 +1,34 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + cert-manager.io/cluster-issuer: myclusterissuer + ingress.kubernetes.io/proxy-body-size: "0" + ingress.kubernetes.io/ssl-redirect: "true" + kubernetes.io/ingress.class: nginx + kubernetes.io/tls-acme: "true" + nginx.ingress.kubernetes.io/proxy-body-size: "0" + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + nginx.ingress.kubernetes.io/ssl-redirect: "true" + nginx.org/client-max-body-size: "0" + nginx.org/proxy-connect-timeout: "3600" + nginx.org/proxy-read-timeout: "3600" + nginx.org/websocket-services: rustpad-service + name: rustpadgcpingress +spec: + rules: + - host: rustpad.example.com + http: + paths: + - backend: + service: + name: rustpad-service + port: + number: 80 + path: / + pathType: ImplementationSpecific + tls: + - hosts: + - rustpad.example.com + secretName: rustpadgcp-tls diff --git a/deployment/kubernetes.yaml b/deployment/kubernetes.yaml new file mode 100644 index 0000000..e6f159c --- /dev/null +++ b/deployment/kubernetes.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rustpad-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: rustpad + template: + metadata: + labels: + app: rustpad + spec: + containers: + - name: rustpad-container + image: ekzhang/rustpad + ports: + - containerPort: 3030 +--- +apiVersion: v1 +kind: Service +metadata: + name: rustpad-service +spec: + selector: + app: rustpad + ports: + - protocol: TCP + port: 80 + targetPort: 3030 +