Skip to content

Commit

Permalink
chore(docs): introduce helm deploy method in use kubernetes section (#…
Browse files Browse the repository at this point in the history
…1793)

Co-authored-by: Guillaume Grossetie <[email protected]>
  • Loading branch information
TeCHiScy and ggrossetie authored Oct 22, 2024
1 parent ee89dc8 commit c55d72a
Showing 1 changed file with 86 additions and 17 deletions.
103 changes: 86 additions & 17 deletions docs/modules/setup/pages/use-kubernetes.adoc
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
= Use Kubernetes
//:uri-k8s-kroki-examples: https://raw.githubusercontent.com/yuzutech/kroki/master/docs/modules/setup/examples/k8s
:uri-k8s-kroki-examples: {examplesdir}/k8s
:uri-k8s-kroki-examples: https://raw.githubusercontent.com/yuzutech/kroki/refs/heads/main/docs/modules/setup/examples/k8s-multi-pod
:uri-k8s-docs-publish-service: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
:uri-helm-charts: https://github.com/cowboysysop/charts/tree/master/charts/kroki

This section describes how to install Kroki on Kubernetes using the `default` namespace.

On this page you will find how to:

* [x] Use `Ingress` to expose the service on port 8000.
* [x] Download and extract the example Kroki kubernetes definition files
* [x] Download and extract the example Kroki Kubernetes definition files
* [x] Install the Kubernetes objects as a batch or one by one.
* [x] Validate the installation
* [x] Delete the Kroki installation
* [x] Use Helm Chart to install/uninstall Kroki
.Providing external access to Kroki
[IMPORTANT]
Expand All @@ -24,8 +25,10 @@ This example uses `Ingress` to expose the service on port 8000.
Read more about how to publish a service on the {uri-k8s-docs-publish-service}[Kubernetes documentation] website.
====

== Extract the Kubernetes object definition files
Prepare the Kubernetes definition files by doing the following:
== Deploy using Kubernetes object definition files

=== Extract the definition files
Prepare the definition files by doing the following:

. 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.
+
Expand All @@ -43,26 +46,26 @@ wget http://docs.kroki.io/kroki/setup/_attachments/kroki-k8s-multipod.zip -O kro
unzip kroki-k8s-multipod.zip -d kroki-k8s
----

In the next steps you use the `*.yml` files beneath the directory `kroki-k8s` and apply them in batch or individually, to create the Kubernetes objects.
In the next steps you use the `*.yaml` files beneath the directory `kroki-k8s` and apply them in batch or individually, to create the Kubernetes objects.

== Create objects as a batch
=== Create objects as a batch

To install (create) all the Kubernetes objects in a batch do the following:
To install (create) all the Kubernetes objects in a batch, do the following:

Use the command `kubectl apply` to create all the required Kubernetes objects,
replacing _/path/to/kroki-k8s_ with the path to the folder containing the `*.yaml` definition files.

.Example command
.Example command with `kubectl` installed
[source,cli,subs=+quotes]
----
kubectl apply -f _/path/to/kroki-k8s_
----

Your next step is to <<Validate that Kroki is running>>.

Read more about working with kubernetes objects on the https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/[Kubernetes] website.
Read more about working with Kubernetes objects on the https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/[Kubernetes] website.

== Create objects individually
=== Create objects individually
Alternatively they can be applied individually.

To install them individually from GitHub, open a terminal and type commands indicated for each service:
Expand Down Expand Up @@ -101,16 +104,16 @@ kubectl apply -f {uri-k8s-kroki-examples}/kroki-ingress.yaml

Your next step is to <<Validate that Kroki is running>>.

== Validate that Kroki is running
=== Validate that Kroki is running
After installing the Kroki Kubernetes objects you verify that Kroki is running.

To verify that the Kroki service is running do the following:
To verify that the Kroki service is running, do the following:

. Run the `kubectl get pod` command:
[source,cli]
kubectl get pod
+
If the installation is successful a list of running pods is shown that includes the following:
If the installation is successful, a list of running pods is shown that includes the following:
+
....
NAME READY STATUS RESTARTS AGE
Expand All @@ -133,15 +136,15 @@ curl http://localhost:8000/seqdiag/svg/eNorTi1MyUxMV6jmUlBIKsovL04tUtC1UyhPTQKyy
+
If successful, a diagram is shown.

== Uninstall Kroki
=== Uninstall Kroki
If you installed Kroki using the downloaded and unpacked `*.yaml` files, Kroki can be deleted using those same files.

To uninstall Kroki use the command `kubectl delete` as follows:
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
=== Use 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.
Expand All @@ -163,3 +166,69 @@ 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.

== Deploy using Helm Charts
You can alternatively deploy Kroki using {uri-helm-charts}[Helm Charts]. It's much easier to deploy Kroki with charts, since all object definition files are managed by Helm.

NOTE: This is an unofficial chart maintained by `cowboysysop`.

To install Kroki using the name `my-kroki`, use the following command:

.Example command with `helm` installed
[source,cli]
----
helm repo add cowboysysop https://cowboysysop.github.io/charts/
helm install my-kroki cowboysysop/kroki
----

Use the following helm command to verify the installation:

.Example command with `helm` installed
[source,cli]
----
helm status my-kroki --show-resources --show-desc
----

If the installation is successful, the following status is shown:

....
NAME: my-kroki
LAST DEPLOYED: Mon Oct 7 17:06:09 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
RESOURCES:
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
kroki-6db8878b8f-zn8kz 5/5 Running 0 13d
==> v1/ServiceAccount
NAME SECRETS AGE
kroki 0 14d
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kroki ClusterIP 10.43.100.80 <none> 8000/TCP 14d
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
kroki 1/1 1 1 14d
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=kroki,app.kubernetes.io/instance=kroki" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8000/ to use your application"
kubectl --namespace default port-forward $POD_NAME 8000:8000
....

You can use the exact same commands as shown in <<Validate that Kroki is running>> to make sure that Kroki is running fine.

To uninstall Kroki, use the command `helm uninstall` as follows:

.Example command with `helm` installed
[source,cli]
----
helm uninstall my-kroki
----

0 comments on commit c55d72a

Please sign in to comment.