Skip to content

Commit

Permalink
Add simple Kubernetes example
Browse files Browse the repository at this point in the history
  • Loading branch information
martialblog authored and arnaudroques committed Jul 21, 2022
1 parent 2d011e2 commit 820fcca
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- [Nginx simple reverse proxy example](./nginx-simple)
- [Nginx reverse proxy example with defined location directive (different context path)](./nginx-contextpath)
- [Kubernetes simple deployment](./kubernetes-simple)
51 changes: 51 additions & 0 deletions examples/kubernetes-simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# PlantUML Kubernetes Deployment

In this example, PlantUML is deployed on an Kubernetes cluster using a `Deployment`, a `Service` and an `Ingress`.

## Quick start

Install:

```bash
# Hint: Adjust the Ingress host to your URL

kubectl create ns plantuml
kubectl -n plantuml apply -f deployment.yaml
```

Uninstall:

```bash
kubectl -n plantuml delete -f deployment.yaml
kubectl delete ns plantuml
```

## TLS configuration

Create a TLS `Secret` and extend the `Ingress` spec with a TLS configuration:

```bash
[...]
tls:
- hosts:
- plantuml-example.localhost
secretName: plantuml-tls
```

Since the `Ingress Controller` terminates the TLS and routes `http` to the application, we might need to tell the application explicitly that it got a forwarded request.

This configuration changes depending on the `Ingress Controller`. Here an nginx example:

```
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "X-Forwarded-Proto: https";
```

## Useful commands

```bash
# see whats going on inside your Deployment
kubectl -n plantuml logs -l "app.kubernetes.io/name=plantuml"
```
84 changes: 84 additions & 0 deletions examples/kubernetes-simple/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: plantuml
labels:
app.kubernetes.io/name: plantuml
app.kubernetes.io/instance: plantuml
spec:
replicas: 3 # Can be adjusted
selector:
matchLabels:
app.kubernetes.io/name: plantuml
app.kubernetes.io/instance: plantuml
template:
metadata:
labels:
app.kubernetes.io/name: plantuml
app.kubernetes.io/instance: plantuml
spec:
containers:
- name: plantuml
securityContext:
allowPrivilegeEscalation: false
image: plantuml/plantuml-server:jetty-v1.2022.6
imagePullPolicy: Always
# env: # In case of different base URL
# - name: BASE_URL
# value: plantuml
ports:
- name: http
containerPort: 8080
protocol: TCP
livenessProbe:
tcpSocket:
port: http
readinessProbe:
tcpSocket:
port: http
resources:
limits:
cpu: 500m
memory: 2048Mi
requests:
cpu: 250m
memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
name: plantuml
labels:
app.kubernetes.io/name: plantuml
app.kubernetes.io/instance: plantuml
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: plantuml
app.kubernetes.io/instance: plantuml
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: plantuml
labels:
app.kubernetes.io/name: plantuml
app.kubernetes.io/instance: plantuml
spec:
rules:
- host: plantuml-example.localhost
http:
paths:
- backend:
service:
name: plantuml
port:
number: 80
path: /
pathType: Prefix

0 comments on commit 820fcca

Please sign in to comment.