Skip to content

Commit

Permalink
Added examples for K8s single-pod Deployment (#1406)
Browse files Browse the repository at this point in the history
Co-authored-by: William Miceli <[email protected]>
  • Loading branch information
WilliamMiceli and William Miceli authored Dec 13, 2022
1 parent 0139dda commit f953fcf
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 7 deletions.
51 changes: 47 additions & 4 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
workflow_dispatch:

jobs:
test-kind:
test-kind-multipod:
runs-on: ubuntu-latest

steps:
Expand All @@ -33,8 +33,8 @@ jobs:
- name: Create cluster
run: ./kind create cluster

- name: Install Kroki
run: ./kubectl apply -f docs/modules/setup/examples/k8s
- name: Install Kroki using Multiple Pods
run: ./kubectl apply -f docs/modules/setup/examples/k8s-multi-pod

- name: Kubectl version
run: ./kubectl version
Expand All @@ -52,7 +52,50 @@ jobs:
run: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:8000/seqdiag/svg/eNorTi1MyUxMV6jmUlBIKsovL04tUtC1UyhPTQKyyoCc6JzEpNQcBVsFJXfXEAX9zLyU1Aq9jJLcHKVYayQ9Nrq6CE3WhA0L8A8GmpaUk5-un5yfm5uaVwIxD6EWqDElsSQxKbE4FUmfp1-wa1CIAg49IFfANOFxXS0A68hQUg== | grep 200

- name: Uninstall Kroki
run: ./kubectl delete -f docs/modules/setup/examples/k8s
run: ./kubectl delete -f docs/modules/setup/examples/k8s-multi-pod

- name: Delete cluster
run: ./kind delete cluster

test-kind-singlepod:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install Kubernetes Kind
run: |
curl -Lo ./kind "https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64"
chmod +x ./kind
./kind version
- name: Install kubectl
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.21.3/bin/linux/amd64/kubectl
chmod +x ./kubectl
- name: Create cluster
run: ./kind create cluster

- name: Install Kroki using a Single Pod
run: ./kubectl apply -f docs/modules/setup/examples/k8s-single-pod

- name: Kubectl version
run: ./kubectl version

- name: Wait until available
run: ./kubectl wait --for=condition=available --timeout=120s --all deployments.apps

- name: Check pod
run: ./kubectl get pod

- name: Forward port 8000 (background)
run: ./kubectl port-forward service/kroki 8000:8000 &

- name: Test SeqDiag
run: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:8000/seqdiag/svg/eNorTi1MyUxMV6jmUlBIKsovL04tUtC1UyhPTQKyyoCc6JzEpNQcBVsFJXfXEAX9zLyU1Aq9jJLcHKVYayQ9Nrq6CE3WhA0L8A8GmpaUk5-un5yfm5uaVwIxD6EWqDElsSQxKbE4FUmfp1-wa1CIAg49IFfANOFxXS0A68hQUg== | grep 200

- name: Uninstall Kroki
run: ./kubectl delete -f docs/modules/setup/examples/k8s-single-pod

- name: Delete cluster
run: ./kind delete cluster
Expand Down
Binary file not shown.
52 changes: 52 additions & 0 deletions docs/modules/setup/examples/k8s-single-pod/kroki-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kroki
labels:
app: kroki

spec:
replicas: 1
selector:
matchLabels:
app: kroki
template:
metadata:
labels:
app: kroki
spec:
containers:
- name: kroki
image: docker.io/yuzutech/kroki:latest
env:
- name: KROKI_BLOCKDIAG_HOST
value: localhost
- name: KROKI_MERMAID_HOST
value: localhost
- name: KROKI_BPMN_HOST
value: localhost
- name: KROKI_EXCALIDRAW_HOST
value: localhost
ports:
- protocol: TCP
containerPort: 8000
- name: kroki-blockdiag
image: docker.io/yuzutech/kroki-blockdiag:latest
ports:
- protocol: TCP
containerPort: 8001
- name: kroki-mermaid
image: docker.io/yuzutech/kroki-mermaid:latest
ports:
- protocol: TCP
containerPort: 8002
- name: kroki-bpmn
image: docker.io/yuzutech/kroki-bpmn:latest
ports:
- protocol: TCP
containerPort: 8003
- name: kroki-excalidraw
image: docker.io/yuzutech/kroki-excalidraw:latest
ports:
- protocol: TCP
containerPort: 8004
16 changes: 16 additions & 0 deletions docs/modules/setup/examples/k8s-single-pod/kroki-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kroki

spec:
rules:
- http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: kroki
port:
number: 8000
14 changes: 14 additions & 0 deletions docs/modules/setup/examples/k8s-single-pod/kroki-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: kroki
labels:
app: kroki

spec:
ports:
- name: "8000"
port: 8000
targetPort: 8000
selector:
app: kroki
29 changes: 26 additions & 3 deletions docs/modules/setup/pages/use-kubernetes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ Read more about how to publish a service on the {uri-k8s-docs-publish-service}[K
== Extract the Kubernetes object definition files
Prepare the Kubernetes definition files by doing the following:

. Download the example bundle link:{attachmentsdir}/kroki-k8s.zip[`kroki-k8s.zip`] that contains all the required `Deployment`, `Service` and `Ingress` definition files to deploy Kroki on Kubernetes.
. Download the example bundle link:{attachmentsdir}/kroki-k8s-multipod.zip[`kroki-k8s-multipod.zip`] that contains all the required `Deployment`, `Service` and `Ingress` definition files to deploy Kroki on Kubernetes.
+
.Example command with `wget` installed
[source,cli]
----
wget http://docs.kroki.io/kroki/setup/_attachments/kroki-k8s.zip -O kroki-k8s.zip
wget http://docs.kroki.io/kroki/setup/_attachments/kroki-k8s-multipod.zip -O kroki-k8s-multipod.zip
----

. Extract the contents of the above zip file into a folder named `kroki-k8s`.
+
.Example command with `unzip` installed
[source,cli]
----
unzip kroki-k8s.zip -d kroki-k8s
unzip kroki-k8s-multipod.zip -d kroki-k8s
----


Expand Down Expand Up @@ -149,3 +149,26 @@ To uninstall Kroki use the command `kubectl delete` as follows:

[source,cli,subs=+quotes]
kubectl delete -f _/path/to/kroki-k8s_

== Using a Single Pod Consisting of Multiple Containers
As a much simpler (but less-flexible) configuration, it is possible to run all containers inside of a single Kubernetes pod.

. Download the example bundle link:{attachmentsdir}/kroki-k8s-singlepod.zip[`kroki-k8s-singlepod.zip`] that contains all the required `Deployment`, `Service` and `Ingress` definition files to deploy Kroki on Kubernetes.
+
.Example command with `wget` installed
[source,cli]
----
wget http://docs.kroki.io/kroki/setup/_attachments/kroki-k8s-singlepod.zip -O kroki-k8s-singlepod.zip
----

. Extract the contents of the above zip file into a folder named `kroki-k8s`.
+
.Example command with `unzip` installed
[source,cli]
----
unzip kroki-k8s-singlepod.zip -d kroki-k8s
----

You can then create the Kubernetes objects as a batch or individually, similar to what was shown previously.

Validation and uninstall/removal of Kubernetes objects can be followed using the exact same commands as shown previously too.

0 comments on commit f953fcf

Please sign in to comment.