Skip to content

Commit 2784cb3

Browse files
authored
Merge pull request #9563 from geoand/k8s-doc-minikube
Add documentation about the Minikube extension
2 parents 5716b83 + e250810 commit 2784cb3

File tree

1 file changed

+63
-9
lines changed

1 file changed

+63
-9
lines changed

docs/src/main/asciidoc/deploying-to-kubernetes.adoc

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,53 @@ To access the API server from within a Kubernetes cluster, some RBAC related res
388388
So, when the `kubernetes-client` extension is present, the `kubernetes` extension is going to create those resources automatically, so that application will be granted the `view` role.
389389
If more roles are required, they will have to be added manually.
390390

391+
=== Deploying to Minikube
392+
393+
https://github.com/kubernetes/minikube[Minikube] is quite popular when a Kubernetes cluster is needed for development purposes. To make the deployment to Minikube
394+
experience as frictionless as possible, Quarkus provides the `quarkus-minikube` extension. This extension can be added to a project like so:
395+
396+
[source,xml]
397+
----
398+
<dependency>
399+
<groupId>io.quarkus</groupId>
400+
<artifactId>quarkus-minikube</artifactId>
401+
</dependency>
402+
----
403+
404+
The purpose of this extension is to generate Kubernetes manifests (`minikube.yaml` and `minikube.json`) that are tailored to Minikube.
405+
This extension assumes a couple things:
406+
407+
* Users won't be using an image registry and will instead make their container image accessible to the Kubernetes cluster by building it directly
408+
into Minikube's Docker daemon. To use Minikube's Docker daemon you must first execute:
409+
+
410+
[source]
411+
----
412+
eval $(minikube -p minikube docker-env)
413+
----
414+
415+
* Applications deployed to Kubernetes won't be accessed via a Kubernetes `Ingress`, but rather as a `NodePort` `Service`.
416+
The advantage of doing this is that the URL of an application can be retrieved trivially by executing:
417+
+
418+
[source]
419+
----
420+
minikube service list
421+
----
422+
423+
To control the https://kubernetes.io/docs/concepts/services-networking/service/#nodeport[nodePort] that is used in this case, users can set `quarkus.kubernetes.node-port`.
424+
Note however that this configuration is entirely optional because Quarkus will automatically use a proper (and non-changing) value if none is set.
425+
426+
WARNING: It is highly discouraged to use the manifests generated by the Minikube extension when deploying to production as these manifests are intended for development purposes
427+
only. When deploying to production, consider using the vanilla Kubernetes manifests (or the OpenShift ones when targeting OpenShift).
428+
429+
NOTE: If the assumptions the Minikube extension makes don't fit your workflow, nothing prevents you from using the regular Kubernetes extension to generate Kubernetes manifests
430+
and apply those to your Minikube cluster.
431+
391432
== Tuning the generated resources using application.properties
392433

393434
The Kubernetes extension allows tuning the generated manifest, using the `application.properties` file.
394435
Here are some examples:
395436

396-
== Configuration options
437+
=== Configuration options
397438

398439
The table below describe all the available configuration options.
399440

@@ -445,7 +486,7 @@ In this example `initial-delay` and `period` are fields of the type `Probe`.
445486
Below you will find tables describing all available types.
446487

447488

448-
=== Basic Types
489+
==== Basic Types
449490

450491
.ServiceType
451492
Allowed values: `cluster-ip`, `node-port`, `load-balancer`, `external-name`
@@ -495,7 +536,7 @@ Allowed values: `cluster-ip`, `node-port`, `load-balancer`, `external-name`
495536
|====
496537

497538

498-
=== Mounts and Volumes
539+
==== Mounts and Volumes
499540

500541
.Mount
501542
|====
@@ -566,7 +607,7 @@ Allowed values: `cluster-ip`, `node-port`, `load-balancer`, `external-name`
566607
|====
567608

568609
[#openshift]
569-
== OpenShift
610+
=== OpenShift
570611

571612
To enable the generation of OpenShift resources, you need to include OpenShift in the target platforms:
572613

@@ -641,7 +682,7 @@ The OpenShift resources can be customized in a similar approach with Kubernetes.
641682
|====
642683

643684
[#knative]
644-
== Knative
685+
=== Knative
645686

646687
To enable the generation of Knative resources, you need to include Knative in the target platforms:
647688

@@ -734,6 +775,19 @@ The generated service can be customized using the following properties:
734775
| quarkus.knative.sidecars | Map<String, Container> | |
735776
|====
736777

778+
=== Deployment targets
779+
780+
Mentioned in the previous sections was the concept of `deployment-target`. This concept allows users to control which Kubernetes manifests will be generated
781+
and deployed to a cluster (if `quarkus.kubernetes.deploy` has been set to `true`).
782+
783+
By default, when no `deployment-target` is set, then only vanilla Kubernetes resources are generated and deployed. When multiple values are set (for example
784+
`quarkus.kubernetes.deployment-target=kubernetes,openshift`) then the resources for all targets are generated, but only the resources
785+
that correspond to the *first* target are applied to the cluster (if deployment is enabled).
786+
787+
In the case of wrapper extensions like OpenShift and Minikube, when these extensions have been explicitly added to the project, the default `deployment-target`
788+
is set by those extensions. For example if `quarkus-minikube` has been added to a project, then `minikube` becomes the default deployment target and its
789+
resources will be applied to the Kubernetes cluster when deployment via `quarkus.kubernetes.deploy` has been set.
790+
Users can still override the deployment-targets manually using `quarkus.kubernetes.deployment-target`.
737791

738792
=== Deprecated configuration
739793

@@ -818,7 +872,7 @@ The name of the resource is determined by the application name and may be overri
818872
For example, in the `kubernetes-quickstart` application, we can add a `kubernetes.yml` file in the `src/main/kubernetes` that looks like:
819873

820874
[source,yaml]
821-
---
875+
----
822876
apiVersion: apps/v1
823877
kind: Deployment
824878
metadata:
@@ -843,12 +897,12 @@ spec:
843897
env:
844898
- name: FOO
845899
value: BAR
846-
---
900+
----
847901

848902
The generated `kubernetes.yml` will look like:
849903

850904
[source,yaml]
851-
---
905+
----
852906
apiVersion: "apps/v1"
853907
kind: "Deployment"
854908
metadata:
@@ -882,7 +936,7 @@ spec:
882936
name: "http"
883937
protocol: "TCP"
884938
serviceAccount: "kubernetes-quickstart"
885-
---
939+
----
886940

887941
The provided replicas <1>, labels <2> and environment variables <3> were retained. However, the image <4> and container port <5> were modified. Moreover, the default annotations have been added.
888942

0 commit comments

Comments
 (0)