Skip to content

Commit

Permalink
Add Kubernetes Deployment manifest files
Browse files Browse the repository at this point in the history
  • Loading branch information
idjohnson committed Sep 30, 2024
1 parent cbc5df8 commit 10b28a0
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
42 changes: 42 additions & 0 deletions deployment/README.md
Original file line number Diff line number Diff line change
@@ -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 <none> 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.
34 changes: 34 additions & 0 deletions deployment/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions deployment/kubernetes.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 10b28a0

Please sign in to comment.