The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Dev Services for Kubernetes

Dev Services for Kubernetes automatically starts a Kubernetes API server in dev mode and when running tests. So you don’t have to start a Kubernetes cluster manually. The application is configured automatically.

Enabling / Disabling Dev Services for Kubernetes

Dev Services for Kubernetes is automatically enabled unless:

  • quarkus.kubernetes-client.devservices.enabled is set to false

  • the api-server-url is configured

  • a valid Kube config file is found and quarkus.kubernetes-client.devservices.override-kubeconfig is not set to true

  • you include the quarkus-test-kubernetes-client dependency

Dev Services for Kubernetes relies on Docker to start the API server. If your environment does not support Docker, you will need to start the Kubernetes cluster manually, or connect to an already running Kubernetes cluster. You can configure the Kubernetes cluster access using either a Kube config file or the various properties available in the KubernetesClientBuildConfig class.

Shared cluster

Most of the time you need to share the cluster between applications. Dev Services for Kubernetes implements a service discovery mechanism for your multiple Quarkus applications running in dev mode to share a single cluster.

Dev Services for Kubernetes starts the container with the quarkus-dev-service-kubernetes label which is used to identify the container.

If you need multiple (shared) clusters, you can configure the quarkus.kubernetes-client.devservices.service-name configuration property and indicate the cluster name. It looks for a container with the name defined, or starts a new one if none can be found. The default service name is kubernetes.

Sharing is enabled by default in dev mode, but disabled in test mode. You can disable the sharing with quarkus.kubernetes-client.devservices.shared=false.

Configuring the cluster

Dev Services for Kubernetes provides three different flavors of Kubernetes cluster. Each flavor supports different Kubernetes API versions. You can configure the flavor and version using the quarkus.kubernetes-client.devservices.flavor and quarkus.kubernetes-client.devservices.api-version properties:

quarkus.kubernetes-client.devservices.flavor=api-only # k3s or kind
quarkus.kubernetes-client.devservices.api-version=1.22

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.

If api-version is not set, the latest version for the given flavor will be used. Otherwise, the version must match a version supported by the given flavor.

Configuration reference

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

If Dev Services for Kubernetes should be used. (default to true) If this is true and kubernetes client is not configured then a kubernetes cluster will be started and will be used.

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_ENABLED

Show more

boolean

true

The kubernetes api server version to use. If not set, Dev Services for Kubernetes will use the latest supported version of the given flavor. see https://github.com/dajudge/kindcontainer/blob/master/k8s-versions.json

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_API_VERSION

Show more

string

The flavor to use (kind, k3s or api-only). Default to api-only.

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_FLAVOR

Show more

kindkind (needs priviledge docker), k3sk3s (needs priviledge docker), api-onlyapi only

api-onlyapi only

By default, if a kubeconfig is found, Dev Services for Kubernetes will not start. Set this to true to override the kubeconfig config.

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_OVERRIDE_KUBECONFIG

Show more

boolean

false

Indicates if the Kubernetes cluster managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Kubernetes starts a new container.

The discovery uses the quarkus-dev-service-kubernetes label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-kubernetes label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Kubernetes looks for a container with the quarkus-dev-service-kubernetes label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the quarkus-dev-service-kubernetes label set to the specified value.

This property is used when you need multiple shared Kubernetes clusters.

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_SERVICE_NAME

Show more

string

kubernetes

Environment variables that are passed to the container.

Environment variable: QUARKUS_KUBERNETES_CLIENT_DEVSERVICES_CONTAINER_ENV__ENVIRONMENT_VARIABLE_NAME_

Show more

Map<String,String>

Related content