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: _versions/main/guides/kubernetes-dev-services.adoc
+52-6Lines changed: 52 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,11 @@ include::_attributes.adoc[]
10
10
:topics: dev-services,kubernetes,testing,dev-mode
11
11
:extensions: io.quarkus:quarkus-kubernetes-client
12
12
13
-
Dev Services for Kubernetes automatically starts a Kubernetes API server in dev mode and when running tests.
14
-
So you don't have to start a Kubernetes cluster manually.
13
+
Dev Services for Kubernetes automatically starts a Kubernetes API server (plus the required etcd) in dev mode and when running tests. So you don't have to start it manually.
15
14
The application is configured automatically.
16
15
16
+
The following https://github.com/dajudge/kindcontainer?tab=readme-ov-file#container-flavors[testcontainers] are supported: https://kind.sigs.k8s.io/[kind], https://k3s.io/[k3s] or api only(default)
17
+
17
18
== Enabling / Disabling Dev Services for Kubernetes
18
19
19
20
Dev Services for Kubernetes is automatically enabled unless:
@@ -23,9 +24,9 @@ Dev Services for Kubernetes is automatically enabled unless:
23
24
- a valid Kube config file is found and `quarkus.kubernetes-client.devservices.override-kubeconfig` is not set to `true`
24
25
- you include the `quarkus-test-kubernetes-client` dependency
25
26
26
-
Dev Services for Kubernetes relies on Docker to start the API server.
27
-
If your environment does not support Docker, you will need to start the Kubernetes cluster manually, or connect to an already running Kubernetes cluster.
28
-
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.
27
+
NOTE: Dev Services for Kubernetes relies on a container engine: Docker or Podman to start the server.
28
+
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.
29
30
30
31
== Shared cluster
31
32
@@ -41,6 +42,51 @@ The default service name is `kubernetes`.
41
42
Sharing is enabled by default in dev mode, but disabled in test mode.
42
43
You can disable the sharing with `quarkus.kubernetes-client.devservices.shared=false`.
43
44
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. If you need a fully-featured Kubernetes cluster that can spin up Pods, you can use `k3s` or `kind`. Note that they both requires to run in Docker privileged mode.
101
+
`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.
56
102
57
103
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].
<1> The `QuarkusComponentTest` annotation registers the JUnit extension.
284
+
<2> Sets a configuration property for the test.
285
+
<3> The test injects the component under the test. `Foo` injects `Charlie`.
286
+
<4> The test also injects a mock for `Charlie`. The injected reference is an "unconfigured" Mockito mock.
287
+
235
288
== Configuration
236
289
237
290
You can set the configuration properties for a test with the `@io.quarkus.test.component.TestConfigProperty` annotation or with the `QuarkusComponentTestExtensionBuilder#configProperty(String, String)` method.
@@ -240,6 +293,8 @@ If you only need to use the default values for missing config properties, then t
240
293
It is also possible to set configuration properties for a test method with the `@io.quarkus.test.component.TestConfigProperty` annotation.
241
294
However, if the test instance lifecycle is `Lifecycle#_PER_CLASS` this annotation can only be used on the test class and is ignored on test methods.
242
295
296
+
NOTE: `@io.quarkus.test.component.TestConfigProperty` declared on a `@Nested` test class is always ignored.
297
+
243
298
CDI beans are also automatically registered for all injected https://smallrye.io/smallrye-config/Main/config/mappings/[Config Mappings]. The mappings are populated with the test configuration properties.
0 commit comments