You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/main/asciidoc/kubernetes-dev-services.adoc
+18-59Lines changed: 18 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,76 +17,33 @@ The following https://github.com/dajudge/kindcontainer?tab=readme-ov-file#contai
17
17
18
18
== Enabling / Disabling Dev Services for Kubernetes
19
19
20
-
Dev Services for Kubernetes is automatically enabled unless:
20
+
To use the Kubernetes Dev Service, you simply need to add the `quarkus-kubernetes-client` extension to your project:
21
21
22
-
- `quarkus.kubernetes-client.devservices.enabled` is set to `false`
23
-
- the `api-server-url` is configured
24
-
- a valid Kube config file is found and `quarkus.kubernetes-client.devservices.override-kubeconfig` is not set to `true`
25
-
- you include the `quarkus-test-kubernetes-client` dependency
22
+
:add-extension-extensions: kubernetes-client
23
+
include::{includes}/devtools/extension-add.adoc[]
26
24
27
-
NOTE: Dev Services for Kubernetes relies on a container engine: Docker or Podman to start the server.
25
+
A Kubernetes API server is automatically started in dev or test modes whenever the `quarkus-kubernetes-client` extension is configured for a project. However, the dev service is disabled in some cases to prevent potential confusing situations:
26
+
27
+
- if the dev service is explicitly disabled by setting `quarkus.kubernetes-client.devservices.enabled` to `false`
28
+
- if the client is explicitly configured to access a given API server via `quarkus.kubernetes-client.api-server-url`
29
+
- if a valid Kube config file is found, in which case that configuration will be used by the client. It is, however, possible to force the dev service to start anyway by setting `quarkus.kubernetes-client.devservices.override-kubeconfig` to `true` to disregard the existing configuration
30
+
- if you include the `quarkus-test-kubernetes-client` dependency as, presumably, in that case, you have tests that rely on the Fabric8 mock server and don't need to start a cluster
31
+
32
+
NOTE: Dev Services for Kubernetes relies on a container engine (Docker or Podman) to start the server.
28
33
If your environment does not support such a container engine, you will have to start a Kubernetes cluster running in a VM, in the cloud, etc.
29
-
In this case, you can configure the Kubernetes cluster access using either a Kube config file or the various properties available in the https://github.com/quarkusio/quarkus/blob/main/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesClientBuildConfig.java[KubernetesClientBuildConfig] class.
34
+
In this case, you can configure the Kubernetes cluster access using either a Kube config file or the various properties available as specified in the xref:kubernetes-client.adoc[Kubernetes client configuration guide].
30
35
31
36
== Shared cluster
32
37
33
-
Most of the time you need to share the cluster between applications.
34
-
Dev Services for Kubernetes implements a _service discovery_ mechanism for your multiple Quarkus applications running in dev mode to share a single cluster.
38
+
Applications often need to share access to the same cluster. For that purpose, Dev Services for Kubernetes implements a _service discovery_ mechanism for multiple Quarkus applications running in dev mode to share a single cluster.
35
39
36
-
NOTE: Dev Services for Kubernetes starts the container with the `quarkus-dev-service-kubernetes` label which is used to identify the container.
40
+
NOTE: Dev Services for Kubernetes starts the api server container with the `quarkus-dev-service-kubernetes` label which is used to identify it.
37
41
38
-
If you need multiple (shared) clusters, you can configure the `quarkus.kubernetes-client.devservices.service-name` configuration property and indicate the cluster name.
39
-
It looks for a container with the name defined, or starts a new one if none can be found.
40
-
The default service name is `kubernetes`.
42
+
If you need multiple (shared) clusters, you can provide a value for the `quarkus.kubernetes-client.devservices.service-name` configuration property to specify the name of the cluster that will be shared among the selected applications. The dev service support will look for an already existing container with that specified name or starts a new one if none can be found.The default service name is `kubernetes`.
41
43
42
44
Sharing is enabled by default in dev mode, but disabled in test mode.
43
45
You can disable the sharing with `quarkus.kubernetes-client.devservices.shared=false`.
44
46
45
-
== What else for the developers
46
-
47
-
If you would like to develop test cases running top of the kubernetes cluster (launched as test container by the Dev Service), then add the following dependencies to your pom file
and set the Quarkus properties to select the flavor, or kube version.
59
-
60
-
Then you will be able to create a Fabric8 Kubernetes Client object able to perform many kube tasks as detailed part of this https://github.com/fabric8io/kubernetes-client/blob/main/doc/CHEATSHEET.md[cheat sheet].
`api-only` only starts a Kubernetes API Server (plus the required etcd). If you need a fully-featured Kubernetes cluster that can spin up Pods, you can use `k3s` or `kind`. `k3s` requires to start the container with `privileged mode`. The `kind` test container supports now to use podman rootless or rootfull.
58
+
`api-only` only starts a Kubernetes API Server (plus the required etcd). If you need a fully-featured Kubernetes cluster that can spin up Pods, you can use `k3s` or `kind`. `k3s` requires to start the container with `privileged mode`. The `kind` test container now also supports using podman's rootless mode.
102
59
103
60
If `api-version` is not set, the latest version for the given flavor will be used. Otherwise, the version must match a https://github.com/dajudge/kindcontainer/blob/master/k8s-versions.json[version supported by the given flavor].
104
61
62
+
Once the cluster is configured, you can access it easily as you normally would, for example, by injecting a client instance in your test.
Copy file name to clipboardExpand all lines: extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java
Copy file name to clipboardExpand all lines: extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/NoQuarkusTestKubernetesClient.java
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,20 @@
6
6
/**
7
7
* Boolean supplier that returns true if quarkus-test-kubernetes-client is not
8
8
* present in the application pom.xml.
9
-
*
9
+
* <p>
10
10
* quarkus-test-kubernetes-client provide a Kubernetes client configuration to connect
11
11
* to a Kubernetes mock server and will have precedence over the configuration provided by
12
12
* Dev Services for Kubernetes. DevServicesKubernetesProcessor uses this BooleanSupplier
13
13
* to avoid starting a Kubernetes test container in such a case.
Copy file name to clipboardExpand all lines: extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/internal/KubernetesDevServicesBuildTimeConfig.java
+9-8Lines changed: 9 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ public interface KubernetesDevServicesBuildTimeConfig {
10
10
11
11
/**
12
12
* If Dev Services for Kubernetes should be used. (default to true)
13
-
*
13
+
* <p>
14
14
* If this is true and kubernetes client is not configured then a kubernetes cluster
15
15
* will be started and will be used.
16
16
*/
@@ -19,15 +19,16 @@ public interface KubernetesDevServicesBuildTimeConfig {
19
19
20
20
/**
21
21
* The kubernetes api server version to use.
22
-
*
23
-
* If not set, Dev Services for Kubernetes will use the latest supported version of the given flavor.
24
-
* see https://github.com/dajudge/kindcontainer/blob/master/k8s-versions.json
22
+
* <p>
23
+
* If not set, Dev Services for Kubernetes will use the
24
+
* <a href="https://github.com/dajudge/kindcontainer/blob/master/k8s-versions.json">latest supported version</a> of the
25
+
* given flavor.
25
26
*/
26
27
Optional<String> apiVersion();
27
28
28
29
/**
29
30
* The flavor to use (kind, k3s or api-only).
30
-
*
31
+
* <p>
31
32
* If not set, Dev Services for Kubernetes will set it to: api-only.
32
33
*/
33
34
Optional<Flavor> flavor();
@@ -74,16 +75,16 @@ public interface KubernetesDevServicesBuildTimeConfig {
Copy file name to clipboardExpand all lines: extensions/kubernetes-client/spi/src/main/java/io/quarkus/kubernetes/client/spi/KubernetesDevServiceRequestBuildItem.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
* BuildItem managing the Kubernetes DevService Request information for the extension consuming it
0 commit comments