Kubernetes extension
Quarkus offers the ability to automatically generate Kubernetes resources based on sane defaults and user-supplied configuration using dekorate. It currently supports generating resources for vanilla Kubernetes, OpenShift and Knative. Furthermore, Quarkus can deploy the application to a target Kubernetes cluster by applying the generated manifests to the target cluster’s API Server. Finally, when either one of container image extensions is present (see the container image guide for more details), Quarkus has the ability to create a container image and push it to a registry before deploying the application to the target platform.
Prerequisites
完成这个指南,你需要:
-
大概15分钟
-
编辑器
-
安装JDK 11以上版本并正确配置了
JAVA_HOME
-
Apache Maven 3.9.1
-
如果你愿意的话,还可以选择使用Quarkus CLI
-
Access to a Kubernetes cluster (Minikube is a viable option)
Kubernetes
Let’s create a new project that contains both the Kubernetes and Jib extensions:
This added the following dependencies to the build file:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib</artifactId>
</dependency>
implementation("io.quarkus:quarkus-resteasy-reactive")
implementation("io.quarkus:quarkus-kubernetes")
implementation("io.quarkus:quarkus-container-image-jib")
By adding these dependencies, we enable the generation of Kubernetes manifests each time we perform a build while also enabling the build of a container image using Jib. For example, following the execution of:
quarkus build
./mvnw install
./gradlew build
you will notice amongst the other files that are created, two files named kubernetes.json
and kubernetes.yml
in the target/kubernetes/
directory.
If you look at either file you will see that it contains both a Kubernetes Deployment
and a Service
.
The full source of the kubernetes.json
file looks something like this:
{
{
"apiVersion" : "apps/v1",
"kind" : "Deployment",
"metadata" : {
"annotations": {
"app.quarkus.io/vcs-uri" : "<some url>",
"app.quarkus.io/commit-id" : "<some git SHA>",
},
"labels" : {
"app.kubernetes.io/name" : "test-quarkus-app",
"app.kubernetes.io/version" : "1.0.0-SNAPSHOT",
},
"name" : "test-quarkus-app"
},
"spec" : {
"replicas" : 1,
"selector" : {
"matchLabels" : {
"app.kubernetes.io/name" : "test-quarkus-app",
"app.kubernetes.io/version" : "1.0.0-SNAPSHOT",
}
},
"template" : {
"metadata" : {
"labels" : {
"app.kubernetes.io/name" : "test-quarkus-app",
"app.kubernetes.io/version" : "1.0.0-SNAPSHOT"
}
},
"spec" : {
"containers" : [ {
"env" : [ {
"name" : "KUBERNETES_NAMESPACE",
"valueFrom" : {
"fieldRef" : {
"fieldPath" : "metadata.namespace"
}
}
} ],
"image" : "yourDockerUsername/test-quarkus-app:1.0.0-SNAPSHOT",
"imagePullPolicy" : "Always",
"name" : "test-quarkus-app"
} ]
}
}
}
},
{
"apiVersion" : "v1",
"kind" : "Service",
"metadata" : {
"annotations": {
"app.quarkus.io/vcs-uri" : "<some url>",
"app.quarkus.io/commit-id" : "<some git SHA>",
},
"labels" : {
"app.kubernetes.io/name" : "test-quarkus-app",
"app.kubernetes.io/version" : "1.0.0-SNAPSHOT",
},
"name" : "test-quarkus-app"
},
"spec" : {
"ports" : [ {
"name" : "http",
"port" : 8080,
"targetPort" : 8080
} ],
"selector" : {
"app.kubernetes.io/name" : "test-quarkus-app",
"app.kubernetes.io/version" : "1.0.0-SNAPSHOT"
},
"type" : "ClusterIP"
}
}
}
The generated manifest can be applied to the cluster from the project root using kubectl
:
kubectl apply -f target/kubernetes/kubernetes.json
An important thing to note about the Deployment
(or StatefulSet
) is that is uses yourDockerUsername/test-quarkus-app:1.0.0-SNAPSHOT
as the container image of the Pod
. The name of the image is controlled by the Jib extension and can be customized using the usual application.properties
.
For example with a configuration like:
quarkus.container-image.group=quarkus #optional, default to the system username
quarkus.container-image.name=demo-app #optional, defaults to the application name
quarkus.container-image.tag=1.0 #optional, defaults to the application version
The image that will be used in the generated manifests will be quarkus/demo-app:1.0
Generating idempotent resources
When generating the Kubernetes manifests, Quarkus automatically adds some labels and annotations to give extra information about the generation date or versions. For example:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
app.quarkus.io/commit-id: 0f8b87788bc446a9347a7961bea8a60889fe1494
app.quarkus.io/build-timestamp: 2023-02-10 - 13:07:51 +0000
labels:
app.kubernetes.io/managed-by: quarkus
app.kubernetes.io/version: 0.0.1-SNAPSHOT
app.kubernetes.io/name: example
name: example
spec:
...
The app.quarkus.io/commit-id
, app.quarkus.io/build-timestamp
labels and the app.kubernetes.io/version
annotation might change every time we re-build the Kubernetes manifests which can be problematic when we want to deploy these resources using a Git-Ops tool (because these tools will detect differences and hence will perform a re-deployment).
To make the generated resources Git-Ops friendly and only produce idempotent resources (resources that won’t change every time we build the sources), we need to add the following property:
quarkus.kubernetes.idempotent=true
Moreover, by default the directory where the generated resources are created is target/kubernetes
, to change it, we need to use:
quarkus.kubernetes.output-directory=target/kubernetes-with-idempotent
Note that the property |
Changing the generated deployment resource
Besides generating a Deployment
resource, you can also choose to generate either a StatefulSet
, or a Job
, or a CronJob
resource instead via application.properties
:
quarkus.kubernetes.deployment-kind=StatefulSet
Generating Job resources
If you want to generate a Job resource, you need to add the following property to the application.properties
:
quarkus.kubernetes.deployment-kind=Job
If you are using the Picocli extension, by default a Job resource will be generated. |
You can provide the arguments that will be used by the Kubernetes Job via the property quarkus.kubernetes.arguments
. For example, by adding the property quarkus.kubernetes.arguments=A,B
.
Finally, the Kubernetes job will be launched every time it is installed in Kubernetes. You can know more about how to run Kubernetes jobs in this link.
You can configure the rest of the Kubernetes Job configuration using the properties under quarkus.kubernetes.job.xxx
(see link).
Generating CronJob resources
If you want to generate a CronJob resource, you need to add the following property via the application.properties
:
quarkus.kubernetes.deployment-kind=CronJob
# Cron expression to run the job every hour
quarkus.kubernetes.cron-job.schedule=0 * * * *
CronJob resources require the Cron expression to specify when to launch the job via the property quarkus.kubernetes.cron-job.schedule . If not provide, the build will fail.
|
You can configure the rest of the Kubernetes CronJob configuration using the properties under quarkus.kubernetes.cron-job.xxx
(see link).
Namespace
By default, Quarkus omits the namespace in the generated manifests, rather than enforce the default
namespace. That means that you can apply the manifest to your chosen namespace when using kubectl
, which in the example below is test
:
kubectl apply -f target/kubernetes/kubernetes.json -n=test
To specify the namespace in your manifest customize with the following property in your application.properties
:
quarkus.kubernetes.namespace=mynamespace
Defining a Docker registry
The Docker registry can be specified with the following property:
quarkus.container-image.registry=my.docker-registry.net
By adding this property along with the rest of the container image properties of the previous section, the generated manifests will use the image my.docker-registry.net/quarkus/demo-app:1.0
. The image is not the only thing that can be customized in the generated manifests, as will become evident in the following sections.
Labels and Annotations
Labels
The generated manifests use the Kubernetes recommended labels. These labels can be customized using quarkus.kubernetes.name
, quarkus.kubernetes.version
and quarkus.kubernetes.part-of
. For example by adding the following configuration to your application.properties
:
quarkus.kubernetes.part-of=todo-app
quarkus.kubernetes.name=todo-rest
quarkus.kubernetes.version=1.0-rc.1
As is described in detail in the OpenShift section, customizing OpenShift (or Knative) properties is done in the same way, but replacing
|
The labels in generated resources will look like:
"labels" : {
"app.kubernetes.io/part-of" : "todo-app",
"app.kubernetes.io/name" : "todo-rest",
"app.kubernetes.io/version" : "1.0-rc.1"
}
You can also remove the
|
Custom Labels
To add additional custom labels, for example foo=bar
just apply the following configuration:
quarkus.kubernetes.labels.foo=bar
When using the quarkus-container-image-jib extension to build a container image, then any label added via the aforementioned property will also be added to the generated container image.
|
Annotations
Out of the box, the generated resources will be annotated with version control related information that can be used either by tooling, or by the user for troubleshooting purposes.
"annotations": {
"app.quarkus.io/vcs-uri" : "<some url>",
"app.quarkus.io/commit-id" : "<some git SHA>",
}
Custom Annotations
Custom annotations can be added in a way similar to labels.For example to add the annotation foo=bar
and app.quarkus/id=42
just apply the following configuration:
quarkus.kubernetes.annotations.foo=bar
quarkus.kubernetes.annotations."app.quarkus/id"=42
Environment variables
Kubernetes provides multiple ways of defining environment variables:
-
key/value pairs
-
import all values from a Secret or ConfigMap
-
interpolate a single value identified by a given field in a Secret or ConfigMap
-
interpolate a value from a field within the same resource
Environment variables from key/value pairs
To add a key/value pair as an environment variable in the generated resources:
quarkus.kubernetes.env.vars.my-env-var=foobar
The command above will add MY_ENV_VAR=foobar
as an environment variable. Please note that the key my-env-var
will be converted to uppercase and dashes will be replaced by underscores resulting in MY_ENV_VAR
.
Environment variables from Secret
To add all key/value pairs of Secret
as environment variables just apply the following configuration, separating each Secret
to be used as source by a comma (,
):
quarkus.kubernetes.env.secrets=my-secret,my-other-secret
which would generate the following in the container definition:
envFrom:
- secretRef:
name: my-secret
optional: false
- secretRef:
name: my-other-secret
optional: false
The following extracts a value identified by the keyName
field from the my-secret
Secret into a foo
environment variable:
quarkus.kubernetes.env.mapping.foo.from-secret=my-secret
quarkus.kubernetes.env.mapping.foo.with-key=keyName
This would generate the following in the env
section of your container:
- env:
- name: FOO
valueFrom:
secretKeyRef:
key: keyName
name: my-secret
optional: false
Environment variables from ConfigMap
To add all key/value pairs from ConfigMap
as environment variables just apply the following configuration, separating each ConfigMap
to be used as source by a comma (,
):
quarkus.kubernetes.env.configmaps=my-config-map,another-config-map
which would generate the following in the container definition:
envFrom:
- configMapRef:
name: my-config-map
optional: false
- configMapRef:
name: another-config-map
optional: false
The following extracts a value identified by the keyName
field from the my-config-map
ConfigMap into a foo
environment variable:
quarkus.kubernetes.env.mapping.foo.from-configmap=my-configmap
quarkus.kubernetes.env.mapping.foo.with-key=keyName
This would generate the following in the env
section of your container:
- env:
- name: FOO
valueFrom:
configMapRefKey:
key: keyName
name: my-configmap
optional: false
Environment variables from fields
It’s also possible to use the value from another field to add a new environment variable by specifying the path of the field to be used as a source, as follows:
quarkus.kubernetes.env.fields.foo=metadata.name
As is described in detail in the OpenShift section, customizing OpenShift properties is done in the same way, but replacing
|
Validation
A conflict between two definitions, e.g. mistakenly assigning both a value and specifying that a variable is derived from a field, will result in an error being thrown at build time so that you get the opportunity to fix the issue before you deploy your application to your cluster where it might be more difficult to diagnose the source of the issue.
Similarly, two redundant definitions, e.g. defining an injection from the same secret twice, will not cause an issue but will indeed report a warning to let you know that you might not have intended to duplicate that definition.
Backwards compatibility
Previous versions of the Kubernetes extension supported a different syntax to add environment variables. The older syntax is still supported but is deprecated, and it’s advised that you migrate to the new syntax.
Old |
New |
||
Plain variable |
|
|
|
From field |
|
|
|
All from |
|
|
|
All from |
|
|
|
From one |
|
|
|
|
|
||
From one |
|
|
|
|
|
If you redefine the same variable using the new syntax while keeping the old syntax, ONLY the new version will be kept and a warning will be issued to alert you of the problem.For example, if you define both quarkus.kubernetes.env-vars.my-env-var.value=foobar and quarkus.kubernetes.env.vars.my-env-var=newValue , the extension will only generate an environment variable MY_ENV_VAR=newValue and issue a warning.
|
Mounting volumes
The Kubernetes extension allows the user to configure both volumes and mounts for the application. Any volume can be mounted with a simple configuration:
quarkus.kubernetes.mounts.my-volume.path=/where/to/mount
This will add a mount to the pod for volume my-volume
to path /where/to/mount
. The volumes themselves can be configured as shown in the sections below.
Passing application configuration
Quarkus supports passing configuration from external locations (via Smallrye Config). This usually requires setting an additional environment variable or system property. When you need to use a secret or a config map for the purpose of application configuration, you need to:
-
define a volume
-
mount the volume
-
create an environment variable for
SMALLRYE_CONFIG_LOCATIONS
To simplify things, quarkus provides single step alternative:
quarkus.kubernetes.app-secret=<name of the secret containing the configuration>
or
quarkus.kubernetes.app-config-map=<name of the config map containing the configuration>
When these properties are used, the generated manifests will contain everything required. The application config volumes will be created using path: /mnt/app-secret
and /mnt/app-config-map
for secrets and configmaps respectively.
Note: Users may use both properties at the same time.
Changing the number of replicas:
To change the number of replicas from 1 to 3:
quarkus.kubernetes.replicas=3
Add readiness and liveness probes
By default, the Kubernetes resources do not contain readiness and liveness probes in the generated Deployment
. Adding them however is just a matter of adding the SmallRye Health extension like so:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
implementation("io.quarkus:quarkus-smallrye-health")
The values of the generated probes will be determined by the configured health properties: quarkus.smallrye-health.root-path
, quarkus.smallrye-health.liveness-path
and quarkus.smallrye-health.readiness-path
. More information about the health extension can be found in the relevant guide.
Customizing the readiness probe
To set the initial delay of the probe to 20 seconds and the period to 45:
quarkus.kubernetes.readiness-probe.initial-delay=20s
quarkus.kubernetes.readiness-probe.period=45s
Add hostAliases
To add entries to a Pod’s /etc/hosts
file (more information can be found in Kubernetes documentation), just apply the following configuration:
quarkus.kubernetes.hostaliases."10.0.0.0".hostnames=foo.com,bar.org
This would generate the following hostAliases
section in the deployment
definition:
kind: Deployment
spec:
template:
spec:
hostAliases:
- hostnames:
- foo.com
- bar.org
ip: 10.0.0.0
Container Resources Management
CPU & Memory limits and requests can be applied to a Container
(more info in Kubernetes documentation) using the following configuration:
quarkus.kubernetes.resources.requests.memory=64Mi
quarkus.kubernetes.resources.requests.cpu=250m
quarkus.kubernetes.resources.limits.memory=512Mi
quarkus.kubernetes.resources.limits.cpu=1000m
This would generate the following entry in the container
section:
containers:
- resources:
limits:
cpu: 1000m
memory: 512Mi
requests:
cpu: 250m
memory: 64Mi
Exposing your application in Kubernetes
Kubernetes exposes applications using Ingress resources. To generate the Ingress resource, just apply the following configuration:
quarkus.kubernetes.ingress.expose=true
This would generate the following Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
app.quarkus.io/commit-id: a58d2211c86f07a47d4b073ea9ce000d2c6828d5
app.quarkus.io/build-timestamp: 2022-06-29 - 13:22:41 +0000
labels:
app.kubernetes.io/name: kubernetes-with-ingress
app.kubernetes.io/version: 0.1-SNAPSHOT
name: kubernetes-with-ingress
spec:
rules:
- http:
paths:
- backend:
service:
name: kubernetes-with-ingress
port:
name: http
path: /
pathType: Prefix
After deploying these resources to Kubernetes, the Ingress resource will allow unsecured connections to reach out your application.
Adding Ingress rules
To customize the default host
and path
properties of the generated Ingress resources, you need to apply the following configuration:
quarkus.kubernetes.ingress.expose=true
# To change the Ingress host. By default, it's empty.
quarkus.kubernetes.ingress.host=prod.svc.url
# To change the Ingress path of the generated Ingress rule. By default, it's "/".
quarkus.kubernetes.ports.http.path=/prod
This would generate the following Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app.kubernetes.io/name: kubernetes-with-ingress
app.kubernetes.io/version: 0.1-SNAPSHOT
name: kubernetes-with-ingress
spec:
rules:
- host: prod.svc.url
http:
paths:
- backend:
service:
name: kubernetes-with-ingress
port:
name: http
path: /prod
pathType: Prefix
Additionally, you can also add new Ingress rules by adding the following configuration:
# Example to add a new rule
quarkus.kubernetes.ingress.rules.1.host=dev.svc.url
quarkus.kubernetes.ingress.rules.1.path=/dev
quarkus.kubernetes.ingress.rules.1.path-type=ImplementationSpecific
# by default, path type is Prefix
# Exmple to add a new rule that use another service binding
quarkus.kubernetes.ingress.rules.2.host=alt.svc.url
quarkus.kubernetes.ingress.rules.2.path=/ea
quarkus.kubernetes.ingress.rules.2.service-name=updated-service
quarkus.kubernetes.ingress.rules.2.service-port-name=tcpurl
This would generate the following Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
app.kubernetes.io/name: kubernetes-with-ingress
app.kubernetes.io/version: 0.1-SNAPSHOT
name: kubernetes-with-ingress
spec:
rules:
- host: prod.svc.url
http:
paths:
- backend:
service:
name: kubernetes-with-ingress
port:
name: http
path: /prod
pathType: Prefix
- host: dev.svc.url
http:
paths:
- backend:
service:
name: kubernetes-with-ingress
port:
name: http
path: /dev
pathType: ImplementationSpecific
- host: alt.svc.url
http:
paths:
- backend:
service:
name: updated-service
port:
name: tcpurl
path: /ea
pathType: Prefix
Securing the Ingress resource
To secure the incoming connections, Kubernetes allows enabling TLS within the Ingress resource by specifying a Secret that contains a TLS private key and certificate. You can generate a secured Ingress resource by simply adding the "tls.secret-name" properties:
quarkus.kubernetes.ingress.expose=true
quarkus.kubernetes.ingress.target-port=https
## Ingress TLS configuration:
quarkus.kubernetes.ingress.tls.my-secret.enabled=true
This configuration will generate the following secured Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
...
name: kubernetes-with-secure-ingress
spec:
rules:
...
tls:
- secretName: my-secret
Now, Kubernetes will validate all the incoming connections using SSL with the certificates provided within the secret with name "my-secret".
More information about how to create the secret in here. |
Using the Kubernetes client
Applications that are deployed to Kubernetes and need to access the API server will usually make use of the kubernetes-client
extension:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes-client</artifactId>
</dependency>
implementation("io.quarkus:quarkus-kubernetes-client")
To access the API server from within a Kubernetes cluster, some RBAC related resources are required (e.g. a ServiceAccount, a RoleBinding). To ease the usage of the kubernetes-client
extension, the kubernetes
extension is going to generate a RoleBinding resource that binds a cluster role named "view" to the application ServiceAccount resource. It’s important to note that the cluster role "view" won’t be generated automatically, so it’s expected that you have this cluster role with name "view" already installed in your cluster.
On the other hand, you can fully customize the roles, subjects and role bindings to generate using the properties under quarkus.kubernetes.rbac.role-bindings
, and if present, the kubernetes-client
extension will use it and hence won’t generate any RoleBinding resource.
You can disable the RBAC resources generation using the property |
Generating RBAC resources
In some scenarios, it’s necessary to generate additional RBAC resources that are used by Kubernetes to grant or limit access to other resources. For example, in our use case, we are building a Kubernetes operator that needs to read the list of the installed deployments. To do this, we would need to assign a service account to our operator and link this service account with a role that grants access to the Deployment resources. Let’s see how to do this using the quarkus.kubernetes.rbac
properties:
# Generate the Role resource with name "my-role" (1)
quarkus.kubernetes.rbac.roles.my-role.policy-rules.0.api-groups=extensions,apps
quarkus.kubernetes.rbac.roles.my-role.policy-rules.0.resources=deployments
quarkus.kubernetes.rbac.roles.my-role.policy-rules.0.verbs=list
1 | In this example, the role "my-role" will be generated with a policy rule to get the list of deployments. |
By default, if one role is configured, a RoleBinding resource will be generated as well to link this role with the ServiceAccount resource.
Moreover, you can have more control over the RBAC resources to be generated:
# Generate Role resource with name "my-role" (1)
quarkus.kubernetes.rbac.roles.my-role.policy-rules.0.api-groups=extensions,apps
quarkus.kubernetes.rbac.roles.my-role.policy-rules.0.resources=deployments
quarkus.kubernetes.rbac.roles.my-role.policy-rules.0.verbs=get,watch,list
# Generate ServiceAccount resource with name "my-service-account" in namespace "my_namespace" (2)
quarkus.kubernetes.rbac.service-accounts.my-service-account.namespace=my_namespace
# Bind Role "my-role" with ServiceAccount "my-service-account" (3)
quarkus.kubernetes.rbac.role-bindings.my-role-binding.subjects.my-service-account.kind=ServiceAccount
quarkus.kubernetes.rbac.role-bindings.my-role-binding.subjects.my-service-account.namespace=my_namespace
quarkus.kubernetes.rbac.role-bindings.my-role-binding.role-name=my-role
1 | In this example, the role "my-role" will be generated with the specified policy rules. |
2 | Also, the service account "my-service-account" will be generated. |
3 | And we can configure the generated RoleBinding resource by selecting the role to be used and the subject. |
Finally, we can also generate the cluster wide role resource of "ClusterRole" kind and a "ClusterRoleBinding" resource as follows:
# Generate ClusterRole resource with name "my-cluster-role" (1)
quarkus.kubernetes.rbac.cluster-roles.my-cluster-role.policy-rules.0.api-groups=extensions,apps
quarkus.kubernetes.rbac.cluster-roles.my-cluster-role.policy-rules.0.resources=deployments
quarkus.kubernetes.rbac.cluster-roles.my-cluster-role.policy-rules.0.verbs=get,watch,list
# Bind the ClusterRole "my-cluster-role" with the application service account
quarkus.kubernetes.rbac.cluster-role-bindings.my-cluster-role-binding.subjects.manager.kind=Group
quarkus.kubernetes.rbac.cluster-role-bindings.my-cluster-role-binding.subjects.manager.api-group=rbac.authorization.k8s.io
quarkus.kubernetes.rbac.cluster-role-bindings.my-cluster-role-binding.role-name=my-cluster-role (2)
1 | In this example, the cluster role "my-cluster-role" will be generated with the specified policy rules. |
2 | The name of the ClusterRole resource to use. Role resources are namespace-based and hence not allowed in ClusterRoleBinding resources. |
Deploying to Minikube
Minikube is quite popular when a Kubernetes cluster is needed for development purposes. To make the deployment to Minikube experience as frictionless as possible, Quarkus provides the quarkus-minikube
extension. This extension can be added to a project like so:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-minikube</artifactId>
</dependency>
implementation("io.quarkus:quarkus-minikube")
The purpose of this extension is to generate Kubernetes manifests (minikube.yaml
and minikube.json
) that are tailored to Minikube. This extension assumes a couple of things:
-
Users won’t be using an image registry and will instead make their container image accessible to the Kubernetes cluster by building it directly into Minikube’s Docker daemon. To use Minikube’s Docker daemon you must first execute:
eval $(minikube -p minikube docker-env)
-
Applications deployed to Kubernetes won’t be accessed via a Kubernetes
Ingress
, but rather as aNodePort
Service
. The advantage of doing this is that the URL of an application can be retrieved trivially by executing:minikube service list
To control the nodePort that is used in this case, users can set quarkus.kubernetes.node-port
. Note however that this configuration is entirely optional because Quarkus will automatically use a proper (and non-changing) value if none is set.
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 only. When deploying to production, consider using the vanilla Kubernetes manifests (or the OpenShift ones when targeting OpenShift). |
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 and apply those to your Minikube cluster. |
Deploying to Kind
Kind is another popular tool used as a Kubernetes cluster for development purposes. To make the deployment to Kind experience as frictionless as possible, Quarkus provides the quarkus-kind
extension. This extension can be added to a project like so:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kind</artifactId>
</dependency>
The purpose of this extension is to generate Kubernetes manifests (kind.yaml
and kind.json
) that are tailored to Kind and also to automate the process of loading images to the cluster when performing container image builds. The tailor made manifests will be pretty similar (they share the same rules) with Minikube (see above).
Tuning the generated resources using application.properties
The Kubernetes extension allows tuning the generated manifest, using the application.properties
file. Here are some examples:
Configuration options
The table below describe all the available configuration options.
Configuration property fixed at build time - All other configuration properties are overridable at runtime
类型 |
默认 |
|
---|---|---|
The name of the group this component belongs too Environment variable: |
string |
|
The name of the application. This value will be used for naming Kubernetes resources like: - Deployment - Service and so on … Environment variable: |
string |
|
The version of the application. Environment variable: |
string |
|
The kind of the deployment resource to use. Supported values are 'StatefulSet', 'Job', 'CronJob' and 'Deployment' defaulting to the latter. Environment variable: |
|
|
The namespace the generated resources should belong to. If not value is set, then the 'namespace' field will not be added to the 'metadata' section of the generated manifests. This in turn means that when the manifests are applied to a cluster, the namespace will be resolved from the current Kubernetes context (see https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context for more details). Environment variable: |
string |
|
Whether to add the build timestamp to the Kubernetes annotations This is a very useful way to have manifests of successive builds of the same application differ - thus ensuring that Kubernetes will apply the updated resources Environment variable: |
boolean |
|
Working directory Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account Environment variable: |
string |
|
The number of desired pods Environment variable: |
int |
|
The type of service that will be generated for the application Environment variable: |
|
|
The nodePort to set when serviceType is set to node-port. Environment variable: |
int |
|
Image pull policy Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
When true (the default), emit a set of annotations to identify services that should be scraped by prometheus for metrics. In configurations that use the Prometheus operator with ServiceMonitor, annotations may not be necessary. Environment variable: |
boolean |
|
Define the annotation prefix used for scrape values, this value will be used as the base for other annotation name defaults. Altering the base for generated annotations can make it easier to define re-labeling rules and avoid unexpected knock-on effects. The default value is Environment variable: |
string |
|
Define the annotation used to indicate services that should be scraped. By default, Environment variable: |
string |
|
Define the annotation used to indicate the path to scrape. By default, Environment variable: |
string |
|
Define the annotation used to indicate the port to scrape. By default, Environment variable: |
string |
|
Define the annotation used to indicate the scheme to use for scraping By default, Environment variable: |
string |
|
EmptyDir volumes Environment variable: |
list of string |
|
The target deployment platform. Defaults to kubernetes. Can be kubernetes, openshift, knative, minikube etc., or any combination of the above as comma separated list. Environment variable: |
list of string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
If true, the service will be exposed Environment variable: |
boolean |
|
The host under which the application is going to be exposed Environment variable: |
string |
|
The default target named port. If not provided, it will be deducted from the Service resource ports. Options are: "http" and "https". Environment variable: |
string |
|
The class of the Ingress. If the ingressClassName is omitted, a default Ingress class is used. Environment variable: |
string |
|
Specifies the maximum desired number of pods the job should run at any given time. Environment variable: |
int |
|
Specifies the desired number of successfully finished pods the job should be run with. Environment variable: |
int |
|
CompletionMode specifies how Pod completions are tracked. Environment variable: |
|
|
Specifies the number of retries before marking this job failed. Environment variable: |
int |
|
Specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. Environment variable: |
long |
|
Limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. Environment variable: |
int |
|
Suspend specifies whether the Job controller should create Pods or not. Environment variable: |
boolean |
|
Restart policy when the job container fails. Environment variable: |
|
|
The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. Environment variable: |
string |
|
ConcurrencyPolicy describes how the job will be handled. Environment variable: |
|
|
Deadline in seconds for starting the job if it misses scheduled time for any reason. Missed jobs executions will be counted as failed ones. Environment variable: |
long |
|
Environment variable: |
int |
|
Environment variable: |
int |
|
Specifies the maximum desired number of pods the job should run at any given time. Environment variable: |
int |
|
Specifies the desired number of successfully finished pods the job should be run with. Environment variable: |
int |
|
CompletionMode specifies how Pod completions are tracked. Environment variable: |
|
|
Specifies the number of retries before marking this job failed. Environment variable: |
int |
|
Specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. Environment variable: |
long |
|
Limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. Environment variable: |
int |
|
Suspend specifies whether the Job controller should create Pods or not. Environment variable: |
boolean |
|
Restart policy when the job container fails. Environment variable: |
|
|
If true, the 'app.kubernetes.io/version' label will be part of the selectors of Service and Deployment Environment variable: |
boolean |
|
If true, the 'app.kubernetes.io/name' label will be part of the selectors of Service and Deployment Environment variable: |
boolean |
|
If set to true, Quarkus will attempt to deploy the application to the target Kubernetes cluster Environment variable: |
boolean |
|
If deploy is enabled, it will follow this strategy to update the resources to the target Kubernetes cluster. Environment variable: |
|
|
If set, the secret will mounted to the application container and its contents will be used for application configuration. Environment variable: |
string |
|
If set, the config map will be mounted to the application container and its contents will be used for application configuration. Environment variable: |
string |
|
The SELinux level label that applies to the container. Environment variable: |
string |
|
The SELinux role label that applies to the container. Environment variable: |
string |
|
The SELinux type label that applies to the container. Environment variable: |
string |
|
The SELinux user label that applies to the container. Environment variable: |
string |
|
The name of the GMSA credential spec to use. Environment variable: |
string |
|
GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field. Environment variable: |
string |
|
The UserName in Windows to run the entrypoint of the container process. Environment variable: |
string |
|
HostProcess determines if a container should be run as a 'Host Process' container. Environment variable: |
boolean |
|
The UID to run the entrypoint of the container process. Environment variable: |
long |
|
The GID to run the entrypoint of the container process. Environment variable: |
long |
|
Indicates that the container must run as a non-root user. Environment variable: |
boolean |
|
A list of groups applied to the first process run in each container, in addition to the container’s primary GID. If unspecified, no groups will be added to any container. Environment variable: |
list of long |
|
A special supplemental group that applies to all containers in a pod. Environment variable: |
long |
|
Sysctls hold a list of namespaced sysctls used for the pod. Environment variable: |
string |
|
It holds policies that will be used for applying fsGroup to a volume when volume is mounted. Values: OnRootMismatch, Always Environment variable: |
|
|
If set, it will change the name of the container according to the configuration Environment variable: |
string |
|
If true, the debug mode in pods will be enabled. Environment variable: |
boolean |
|
The transport to use. Environment variable: |
string |
|
If enabled, it means the JVM will wait for the debugger to attach before executing the main class. If false, the JVM will immediately execute the main class, while listening for the debugger connection. Environment variable: |
string |
|
It specifies the address at which the debug socket will listen. Environment variable: |
int |
|
Flag to enable init task externalization. When enabled (default), all initialization tasks created by extensions, will be externalized as Jobs. In addition the deployment will wait for these jobs. Environment variable: |
boolean |
|
Switch used to control whether non-idempotent fields are included in generated kubernetes resources to improve git-ops compatibility Environment variable: |
boolean |
|
Optionally set directory generated kubernetes resources will be written to. Default is Environment variable: |
string |
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
Custom labels to add to all resources Environment variable: |
|
|
Custom annotations to add to all resources Environment variable: |
|
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
The name of the secret to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
The path where the file will be mounted. Environment variable: |
string |
required |
It must be a value between 0000 and 0777. If not specified, the volume defaultMode will be used. Environment variable: |
int |
|
Optional Environment variable: |
boolean |
|
The name of the ConfigMap to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
The path where the file will be mounted. Environment variable: |
string |
required |
It must be a value between 0000 and 0777. If not specified, the volume defaultMode will be used. Environment variable: |
int |
|
Optional Environment variable: |
boolean |
|
Git repository URL. Environment variable: |
string |
required |
The directory of the repository to mount. Environment variable: |
string |
|
The commit hash to use. Environment variable: |
string |
|
The name of the claim to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
Optional Environment variable: |
boolean |
|
The name of the disk to mount. Environment variable: |
string |
required |
The partition. Environment variable: |
int |
|
Filesystem type. Environment variable: |
string |
|
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The share name. Environment variable: |
string |
required |
The secret name. Environment variable: |
string |
required |
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The name of the disk to mount. Environment variable: |
string |
required |
The URI of the vhd blob object OR the resourceID of an Azure managed data disk if Kind is Managed Environment variable: |
string |
required |
Kind of disk. Environment variable: |
|
|
Disk caching mode. Environment variable: |
|
|
File system type. Environment variable: |
string |
|
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The container image. Environment variable: |
string |
|
Working directory. Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account. Environment variable: |
string |
|
The host under which the application is going to be exposed. Environment variable: |
string |
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
Image pull policy. Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
The map associating environment variable names to their associated field references they take their value from. Environment variable: |
|
|
The map associating environment name to its associated value. Environment variable: |
|
|
The optional name of the Secret from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The optional name of the ConfigMap from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The key identifying the field from which the value is extracted. Environment variable: |
string |
required |
The container image. Environment variable: |
string |
|
Working directory. Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account. Environment variable: |
string |
|
The host under which the application is going to be exposed. Environment variable: |
string |
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
Image pull policy. Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
The map associating environment variable names to their associated field references they take their value from. Environment variable: |
|
|
The map associating environment name to its associated value. Environment variable: |
|
|
The optional name of the Secret from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The optional name of the ConfigMap from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The key identifying the field from which the value is extracted. Environment variable: |
string |
required |
The ip address Environment variable: |
string |
|
The hostnames to resolve to the ip Environment variable: |
list of string |
|
The name of the role. Environment variable: |
string |
|
The namespace of the role. Environment variable: |
string |
|
Labels to add into the Role resource. Environment variable: |
|
|
API groups of the policy rule. Environment variable: |
list of string |
|
Non resource URLs of the policy rule. Environment variable: |
list of string |
|
Resource names of the policy rule. Environment variable: |
list of string |
|
Resources of the policy rule. Environment variable: |
list of string |
|
Verbs of the policy rule. Environment variable: |
list of string |
|
The name of the cluster role. Environment variable: |
string |
|
Labels to add into the ClusterRole resource. Environment variable: |
|
|
API groups of the policy rule. Environment variable: |
list of string |
|
Non resource URLs of the policy rule. Environment variable: |
list of string |
|
Resource names of the policy rule. Environment variable: |
list of string |
|
Resources of the policy rule. Environment variable: |
list of string |
|
Verbs of the policy rule. Environment variable: |
list of string |
|
The name of the service account. Environment variable: |
string |
|
The namespace of the service account. Environment variable: |
string |
|
Labels of the service account. Environment variable: |
|
|
If true, this service account will be used in the generated Deployment resource. Environment variable: |
boolean |
|
Name of the RoleBinding resource to be generated. If not provided, it will use the application name plus the role ref name. Environment variable: |
string |
|
Labels to add into the RoleBinding resource. Environment variable: |
|
|
The name of the Role resource to use by the RoleRef element in the generated Role Binding resource. By default, it’s "view" role name. Environment variable: |
string |
|
If the Role sets in the Environment variable: |
boolean |
|
The "name" resource to use by the Subject element in the generated Role Binding resource. Environment variable: |
string |
|
The "kind" resource to use by the Subject element in the generated Role Binding resource. By default, it uses the "ServiceAccount" kind. Environment variable: |
string |
|
The "apiGroup" resource that matches with the "kind" property. By default, it’s empty. Environment variable: |
string |
|
The "namespace" resource to use by the Subject element in the generated Role Binding resource. By default, it will use the same as provided in the generated resources. Environment variable: |
string |
|
Name of the ClusterRoleBinding resource to be generated. If not provided, it will use the application name plus the role ref name. Environment variable: |
string |
|
Labels to add into the RoleBinding resource. Environment variable: |
|
|
The name of the ClusterRole resource to use by the RoleRef element in the generated ClusterRoleBinding resource. Environment variable: |
string |
required |
The "name" resource to use by the Subject element in the generated Role Binding resource. Environment variable: |
string |
|
The "kind" resource to use by the Subject element in the generated Role Binding resource. By default, it uses the "ServiceAccount" kind. Environment variable: |
string |
|
The "apiGroup" resource that matches with the "kind" property. By default, it’s empty. Environment variable: |
string |
|
The "namespace" resource to use by the Subject element in the generated Role Binding resource. By default, it will use the same as provided in the generated resources. Environment variable: |
string |
|
Custom annotations to add to exposition (route or ingress) resources Environment variable: |
|
|
If true, it will use the TLS configuration in the generated Ingress resource. Environment variable: |
boolean |
|
The list of hosts to be included in the TLS certificate. By default, it will use the application host. Environment variable: |
list of string |
|
The host under which the rule is going to be used. Environment variable: |
string |
required |
The path under which the rule is going to be used. Default is "/". Environment variable: |
string |
|
The path type strategy to use by the Ingress rule. Default is "Prefix". Environment variable: |
string |
|
The service name to be used by this Ingress rule. Default is the generated service name of the application. Environment variable: |
string |
|
The service port name to be used by this Ingress rule. Default is the port name of the generated service of the application. Environment variable: |
string |
|
The service port number to be used by this Ingress rule. This is only used when the servicePortName is not set. Environment variable: |
int |
|
The map associating environment variable names to their associated field references they take their value from. Environment variable: |
|
|
The map associating environment name to its associated value. Environment variable: |
|
|
The optional name of the Secret from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The optional name of the ConfigMap from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The key identifying the field from which the value is extracted. Environment variable: |
string |
required |
Properties that use non-standard types, can be referenced by expanding the property. For example to define a kubernetes-readiness-probe
which is of type Probe
:
quarkus.kubernetes.readiness-probe.initial-delay=20s
quarkus.kubernetes.readiness-probe.period=45s
In this example initial-delay
and period
are fields of the type Probe
. Below you will find tables describing all available types.
Client Connection Configuration
You may need to configure the connection to your Kubernetes cluster. By default, it automatically uses the active context used by kubectl
.
For instance, if your cluster API endpoint uses a self-signed SSL Certificate you need to explicitly configure the client to trust it. You can achieve this by defining the following property:
quarkus.kubernetes-client.trust-certs=true
The full list of the Kubernetes client configuration properties is provided below.
Configuration property fixed at build time - All other configuration properties are overridable at runtime
类型 |
默认 |
|
---|---|---|
Whether the client should trust a self-signed certificate if so presented by the API server Environment variable: |
boolean |
|
URL of the Kubernetes API server Environment variable: |
string |
|
Default namespace to use Environment variable: |
string |
|
CA certificate file Environment variable: |
string |
|
CA certificate data Environment variable: |
string |
|
Client certificate file Environment variable: |
string |
|
Client certificate data Environment variable: |
string |
|
Client key file Environment variable: |
string |
|
Client key data Environment variable: |
string |
|
Client key algorithm Environment variable: |
string |
|
Client key passphrase Environment variable: |
string |
|
Kubernetes auth username Environment variable: |
string |
|
Kubernetes auth password Environment variable: |
string |
|
Kubernetes oauth token Environment variable: |
string |
|
Watch reconnect interval Environment variable: |
|
|
Maximum reconnect attempts in case of watch failure By default there is no limit to the number of reconnect attempts Environment variable: |
int |
|
Maximum amount of time to wait for a connection with the API server to be established Environment variable: |
|
|
Maximum amount of time to wait for a request to the API server to be completed Environment variable: |
|
|
Maximum number of retry attempts for API requests that fail with an HTTP code of >= 500 Environment variable: |
int |
|
Time interval between retry attempts for API requests that fail with an HTTP code of >= 500 Environment variable: |
|
|
HTTP proxy used to access the Kubernetes API server Environment variable: |
string |
|
HTTPS proxy used to access the Kubernetes API server Environment variable: |
string |
|
Proxy username Environment variable: |
string |
|
Proxy password Environment variable: |
string |
|
IP addresses or hosts to exclude from proxying Environment variable: |
list of string |
|
Enable the generation of the RBAC manifests. If enabled and no other role binding are provided using the properties Environment variable: |
boolean |
|
类型 |
默认 |
|
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: |
boolean |
|
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: |
string |
|
The flavor to use (kind, k3s or api-only). Default to api-only. Environment variable: |
|
|
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: |
boolean |
|
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 Environment variable: |
boolean |
|
The value of the Environment variable: |
string |
|
OpenShift
One way to deploy an application to OpenShift is to use s2i (source to image) to create an image stream from the source and then deploy the image stream:
quarkus extension remove kubernetes,jib
quarkus extension add openshift
oc new-project quarkus-project
quarkus build -Dquarkus.container-image.build=true
oc new-app --name=greeting quarkus-project/kubernetes-quickstart:1.0.0-SNAPSHOT
oc expose svc/greeting
oc get route
curl <route>/greeting
./mvnw quarkus:remove-extension -Dextensions="kubernetes, jib"
./mvnw quarkus:add-extension -Dextensions="openshift"
oc new-project quarkus-project
./mvnw clean package -Dquarkus.container-image.build=true
oc new-app --name=greeting quarkus-project/kubernetes-quickstart:1.0.0-SNAPSHOT
oc expose svc/greeting
oc get route
curl <route>/greeting
./gradlew removeExtension --extensions="kubernetes, jib"
./gradlew addExtension --extensions="openshift"
oc new-project quarkus-project
./gradlew build -Dquarkus.container-image.build=true
oc new-app --name=greeting quarkus-project/kubernetes-quickstart:1.0.0-SNAPSHOT
oc expose svc/greeting
oc get route
curl <route>/greeting
See further information in Deploying to OpenShift.
A description of OpenShift resources and customisable properties is given below alongside Kubernetes resources to show similarities where applicable. This includes an alternative to oc new-app …
above, i.e. oc apply -f target/kubernetes/openshift.json
.
To enable the generation of OpenShift resources, you need to include OpenShift in the target platforms:
quarkus.kubernetes.deployment-target=openshift
If you need to generate resources for both platforms (vanilla Kubernetes and OpenShift), then you need to include both (comma separated).
quarkus.kubernetes.deployment-target=kubernetes,openshift
Following the execution of ./mvnw package -Dquarkus.container-image.build=true
you will notice amongst the other files that are created, two files named openshift.json
and openshift.yml
in the target/kubernetes/
directory.
These manifests can be deployed as is to a running cluster, using kubectl
:
kubectl apply -f target/kubernetes/openshift.json
OpenShift’s users might want to use oc
rather than kubectl
:
oc apply -f target/kubernetes/openshift.json
For users that prefer to keep the application.properties
independent of the deployment platform, the deployment target can be specified directly in the deploy command by adding -Dquarkus.kubernetes.deployment-target=openshift
in addition to -Dquarkus.kubernetes.deploy=true
. Furthermore, Quarkus allows collapsing the two properties into one: -Dquarkus.openshift.deploy=true
.
./mvnw clean package -Dquarkus.openshift.deploy=true
The equivalent with gradle:
./gradlew build -Dquarkus.openshift.deploy=true
In case that both properties are used with conflicting values quarkus.kubernetes.deployment-target
is used.
Quarkus also provides the OpenShift extension. This extension is basically a wrapper around the Kubernetes extension and relieves OpenShift users of the necessity of setting the deployment-target property to openshift
|
The OpenShift resources can be customized in a similar approach with Kubernetes.
Configuration property fixed at build time - All other configuration properties are overridable at runtime
类型 |
默认 |
|
---|---|---|
The OpenShift flavor / version to use. Older versions of OpenShift have minor differences in the labels and fields they support. This option allows users to have their manifests automatically aligned to the OpenShift 'flavor' they use. Environment variable: |
|
|
The kind of the deployment resource to use. Supported values are 'Deployment', 'StatefulSet', 'Job', 'CronJob' and 'DeploymentConfig' defaulting to the latter. Environment variable: |
|
|
The name of the group this component belongs too Environment variable: |
string |
|
The name of the application. This value will be used for naming Kubernetes resources like: 'Deployment', 'Service' and so on… Environment variable: |
string |
|
The version of the application. Environment variable: |
string |
|
The namespace the generated resources should belong to. If not value is set, then the 'namespace' field will not be added to the 'metadata' section of the generated manifests. This in turn means that when the manifests are applied to a cluster, the namespace will be resolved from the current Kubernetes context (see https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context for more details). Environment variable: |
string |
|
Add the build timestamp to the Kubernetes annotations This is a very useful way to have manifests of successive builds of the same application differ - thus ensuring that Kubernetes will apply the updated resources Environment variable: |
boolean |
|
Working directory Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account Environment variable: |
string |
|
The number of desired pods Environment variable: |
int |
|
The type of service that will be generated for the application Environment variable: |
|
|
The nodePort to set when serviceType is set to nodePort Environment variable: |
int |
|
Image pull policy Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
When true (the default), emit a set of annotations to identify services that should be scraped by prometheus for metrics. In configurations that use the Prometheus operator with ServiceMonitor, annotations may not be necessary. Environment variable: |
boolean |
|
Define the annotation prefix used for scrape values, this value will be used as the base for other annotation name defaults. Altering the base for generated annotations can make it easier to define re-labeling rules and avoid unexpected knock-on effects. The default value is Environment variable: |
string |
|
Define the annotation used to indicate services that should be scraped. By default, Environment variable: |
string |
|
Define the annotation used to indicate the path to scrape. By default, Environment variable: |
string |
|
Define the annotation used to indicate the port to scrape. By default, Environment variable: |
string |
|
Define the annotation used to indicate the scheme to use for scraping By default, Environment variable: |
string |
|
EmptyDir volumes Environment variable: |
list of string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
If set, it will change the name of the container according to the configuration Environment variable: |
string |
|
If true, the service will be exposed Environment variable: |
boolean |
|
The host under which the application is going to be exposed Environment variable: |
string |
|
The target named port. If not provided, it will be deducted from the Service resource ports. Options are: "http" and "https". Environment variable: |
string |
|
The cert authority certificate contents. Environment variable: |
string |
|
The certificate contents. Environment variable: |
string |
|
The contents of the ca certificate of the final destination. Environment variable: |
string |
|
The desired behavior for insecure connections to a route. Environment variable: |
string |
|
The key file contents. Environment variable: |
string |
|
The termination type. Environment variable: |
string |
|
If true, the 'app.kubernetes.io/version' label will be part of the selectors of Service and DeploymentConfig Environment variable: |
boolean |
|
If true, the 'app.kubernetes.io/name' label will be part of the selectors of Service and Deployment Environment variable: |
boolean |
|
Specifies the maximum desired number of pods the job should run at any given time. Environment variable: |
int |
|
Specifies the desired number of successfully finished pods the job should be run with. Environment variable: |
int |
|
CompletionMode specifies how Pod completions are tracked. Environment variable: |
|
|
Specifies the number of retries before marking this job failed. Environment variable: |
int |
|
Specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. Environment variable: |
long |
|
Limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. Environment variable: |
int |
|
Suspend specifies whether the Job controller should create Pods or not. Environment variable: |
boolean |
|
Restart policy when the job container fails. Environment variable: |
|
|
The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. Environment variable: |
string |
|
ConcurrencyPolicy describes how the job will be handled. Environment variable: |
|
|
Deadline in seconds for starting the job if it misses scheduled time for any reason. Missed jobs executions will be counted as failed ones. Environment variable: |
long |
|
Environment variable: |
int |
|
Environment variable: |
int |
|
Specifies the maximum desired number of pods the job should run at any given time. Environment variable: |
int |
|
Specifies the desired number of successfully finished pods the job should be run with. Environment variable: |
int |
|
CompletionMode specifies how Pod completions are tracked. Environment variable: |
|
|
Specifies the number of retries before marking this job failed. Environment variable: |
int |
|
Specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. Environment variable: |
long |
|
Limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. Environment variable: |
int |
|
Suspend specifies whether the Job controller should create Pods or not. Environment variable: |
boolean |
|
Restart policy when the job container fails. Environment variable: |
|
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
If set, the secret will mounted to the application container and its contents will be used for application configuration. Environment variable: |
string |
|
If set, the config amp will be mounted to the application container and its contents will be used for application configuration. Environment variable: |
string |
|
The SELinux level label that applies to the container. Environment variable: |
string |
|
The SELinux role label that applies to the container. Environment variable: |
string |
|
The SELinux type label that applies to the container. Environment variable: |
string |
|
The SELinux user label that applies to the container. Environment variable: |
string |
|
The name of the GMSA credential spec to use. Environment variable: |
string |
|
GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field. Environment variable: |
string |
|
The UserName in Windows to run the entrypoint of the container process. Environment variable: |
string |
|
HostProcess determines if a container should be run as a 'Host Process' container. Environment variable: |
boolean |
|
The UID to run the entrypoint of the container process. Environment variable: |
long |
|
The GID to run the entrypoint of the container process. Environment variable: |
long |
|
Indicates that the container must run as a non-root user. Environment variable: |
boolean |
|
A list of groups applied to the first process run in each container, in addition to the container’s primary GID. If unspecified, no groups will be added to any container. Environment variable: |
list of long |
|
A special supplemental group that applies to all containers in a pod. Environment variable: |
long |
|
Sysctls hold a list of namespaced sysctls used for the pod. Environment variable: |
string |
|
It holds policies that will be used for applying fsGroup to a volume when volume is mounted. Values: OnRootMismatch, Always Environment variable: |
|
|
If true, the debug mode in pods will be enabled. Environment variable: |
boolean |
|
The transport to use. Environment variable: |
string |
|
If enabled, it means the JVM will wait for the debugger to attach before executing the main class. If false, the JVM will immediately execute the main class, while listening for the debugger connection. Environment variable: |
string |
|
It specifies the address at which the debug socket will listen. Environment variable: |
int |
|
If set to true, Quarkus will attempt to deploy the application to the target Openshift cluster Environment variable: |
boolean |
|
If deploy is enabled, it will follow this strategy to update the resources to the target OpenShift cluster. Environment variable: |
|
|
Flag to enable init task externalization. When enabled (default), all initialization tasks created by extensions, will be externalized as Jobs. In addition the deployment will wait for these jobs. Environment variable: |
boolean |
|
Switch used to control whether non-idempotent fields are included in generated kubernetes resources to improve git-ops compatibility Environment variable: |
boolean |
|
Custom labels to add to all resources Environment variable: |
|
|
Custom annotations to add to all resources Environment variable: |
|
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
The name of the secret to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
The path where the file will be mounted. Environment variable: |
string |
required |
It must be a value between 0000 and 0777. If not specified, the volume defaultMode will be used. Environment variable: |
int |
|
Optional Environment variable: |
boolean |
|
The name of the ConfigMap to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
The path where the file will be mounted. Environment variable: |
string |
required |
It must be a value between 0000 and 0777. If not specified, the volume defaultMode will be used. Environment variable: |
int |
|
Optional Environment variable: |
boolean |
|
Git repository URL. Environment variable: |
string |
required |
The directory of the repository to mount. Environment variable: |
string |
|
The commit hash to use. Environment variable: |
string |
|
The name of the claim to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
Optional Environment variable: |
boolean |
|
The name of the disk to mount. Environment variable: |
string |
required |
The partition. Environment variable: |
int |
|
Filesystem type. Environment variable: |
string |
|
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The share name. Environment variable: |
string |
required |
The secret name. Environment variable: |
string |
required |
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The name of the disk to mount. Environment variable: |
string |
required |
The URI of the vhd blob object OR the resourceID of an Azure managed data disk if Kind is Managed Environment variable: |
string |
required |
Kind of disk. Environment variable: |
|
|
Disk caching mode. Environment variable: |
|
|
File system type. Environment variable: |
string |
|
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The container image. Environment variable: |
string |
|
Working directory. Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account. Environment variable: |
string |
|
The host under which the application is going to be exposed. Environment variable: |
string |
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
Image pull policy. Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
The map associating environment variable names to their associated field references they take their value from. Environment variable: |
|
|
The map associating environment name to its associated value. Environment variable: |
|
|
The optional name of the Secret from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The optional name of the ConfigMap from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The key identifying the field from which the value is extracted. Environment variable: |
string |
required |
The container image. Environment variable: |
string |
|
Working directory. Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account. Environment variable: |
string |
|
The host under which the application is going to be exposed. Environment variable: |
string |
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
Image pull policy. Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
The map associating environment variable names to their associated field references they take their value from. Environment variable: |
|
|
The map associating environment name to its associated value. Environment variable: |
|
|
The optional name of the Secret from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The optional name of the ConfigMap from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The key identifying the field from which the value is extracted. Environment variable: |
string |
required |
The ip address Environment variable: |
string |
|
The hostnames to resolve to the ip Environment variable: |
list of string |
|
Custom annotations to add to exposition (route or ingress) resources Environment variable: |
|
|
The name of the role. Environment variable: |
string |
|
The namespace of the role. Environment variable: |
string |
|
Labels to add into the Role resource. Environment variable: |
|
|
API groups of the policy rule. Environment variable: |
list of string |
|
Non resource URLs of the policy rule. Environment variable: |
list of string |
|
Resource names of the policy rule. Environment variable: |
list of string |
|
Resources of the policy rule. Environment variable: |
list of string |
|
Verbs of the policy rule. Environment variable: |
list of string |
|
The name of the cluster role. Environment variable: |
string |
|
Labels to add into the ClusterRole resource. Environment variable: |
|
|
API groups of the policy rule. Environment variable: |
list of string |
|
Non resource URLs of the policy rule. Environment variable: |
list of string |
|
Resource names of the policy rule. Environment variable: |
list of string |
|
Resources of the policy rule. Environment variable: |
list of string |
|
Verbs of the policy rule. Environment variable: |
list of string |
|
The name of the service account. Environment variable: |
string |
|
The namespace of the service account. Environment variable: |
string |
|
Labels of the service account. Environment variable: |
|
|
If true, this service account will be used in the generated Deployment resource. Environment variable: |
boolean |
|
Name of the RoleBinding resource to be generated. If not provided, it will use the application name plus the role ref name. Environment variable: |
string |
|
Labels to add into the RoleBinding resource. Environment variable: |
|
|
The name of the Role resource to use by the RoleRef element in the generated Role Binding resource. By default, it’s "view" role name. Environment variable: |
string |
|
If the Role sets in the Environment variable: |
boolean |
|
The "name" resource to use by the Subject element in the generated Role Binding resource. Environment variable: |
string |
|
The "kind" resource to use by the Subject element in the generated Role Binding resource. By default, it uses the "ServiceAccount" kind. Environment variable: |
string |
|
The "apiGroup" resource that matches with the "kind" property. By default, it’s empty. Environment variable: |
string |
|
The "namespace" resource to use by the Subject element in the generated Role Binding resource. By default, it will use the same as provided in the generated resources. Environment variable: |
string |
|
Name of the ClusterRoleBinding resource to be generated. If not provided, it will use the application name plus the role ref name. Environment variable: |
string |
|
Labels to add into the RoleBinding resource. Environment variable: |
|
|
The name of the ClusterRole resource to use by the RoleRef element in the generated ClusterRoleBinding resource. Environment variable: |
string |
required |
The "name" resource to use by the Subject element in the generated Role Binding resource. Environment variable: |
string |
|
The "kind" resource to use by the Subject element in the generated Role Binding resource. By default, it uses the "ServiceAccount" kind. Environment variable: |
string |
|
The "apiGroup" resource that matches with the "kind" property. By default, it’s empty. Environment variable: |
string |
|
The "namespace" resource to use by the Subject element in the generated Role Binding resource. By default, it will use the same as provided in the generated resources. Environment variable: |
string |
|
The map associating environment variable names to their associated field references they take their value from. Environment variable: |
|
|
The map associating environment name to its associated value. Environment variable: |
|
|
The optional name of the Secret from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The optional name of the ConfigMap from which a value is to be extracted. Mutually exclusive with Environment variable: |
string |
|
The key identifying the field from which the value is extracted. Environment variable: |
string |
required |
Knative
To enable the generation of Knative resources, you need to include Knative in the target platforms:
quarkus.kubernetes.deployment-target=knative
Following the execution of ./mvnw package
you will notice amongst the other files that are created, two files named knative.json
and knative.yml
in the target/kubernetes/
directory.
If you look at either file you will see that it contains a Knative Service
.
The full source of the knative.json
file looks something like this:
{
{
"apiVersion" : "serving.quarkus.knative.dev/v1alpha1",
"kind" : "Service",
"metadata" : {
"annotations": {
"app.quarkus.io/vcs-uri" : "<some url>",
"app.quarkus.io/commit-id" : "<some git SHA>"
},
"labels" : {
"app.kubernetes.io/name" : "test-quarkus-app",
"app.kubernetes.io/version" : "1.0.0-SNAPSHOT"
},
"name" : "knative"
},
"spec" : {
"runLatest" : {
"configuration" : {
"revisionTemplate" : {
"spec" : {
"container" : {
"image" : "dev.local/yourDockerUsername/test-quarkus-app:1.0.0-SNAPSHOT",
"imagePullPolicy" : "Always"
}
}
}
}
}
}
}
}
The generated manifest can be deployed as is to a running cluster, using kubectl
:
kubectl apply -f target/kubernetes/knative.json
The generated service can be customized using the following properties:
Configuration property fixed at build time - All other configuration properties are overridable at runtime
类型 |
默认 |
|
---|---|---|
The name of the group this component belongs too Environment variable: |
string |
|
The name of the application. This value will be used for naming Kubernetes resources like: - Deployment - Service and so on … Environment variable: |
string |
|
The version of the application. Environment variable: |
string |
|
The namespace the generated resources should belong to. If not value is set, then the 'namespace' field will not be added to the 'metadata' section of the generated manifests. This in turn means that when the manifests are applied to a cluster, the namespace will be resolved from the current Kubernetes context (see https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context for more details). Environment variable: |
string |
|
Whether to add the build timestamp to the Kubernetes annotations This is a very useful way to have manifests of successive builds of the same application differ - thus ensuring that Kubernetes will apply the updated resources Environment variable: |
boolean |
|
Working directory Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account Environment variable: |
string |
|
The type of service that will be generated for the application Environment variable: |
|
|
Image pull policy Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
When true (the default), emit a set of annotations to identify services that should be scraped by prometheus for metrics. In configurations that use the Prometheus operator with ServiceMonitor, annotations may not be necessary. Environment variable: |
boolean |
|
Define the annotation prefix used for scrape values, this value will be used as the base for other annotation name defaults. Altering the base for generated annotations can make it easier to define re-labeling rules and avoid unexpected knock-on effects. The default value is Environment variable: |
string |
|
Define the annotation used to indicate services that should be scraped. By default, Environment variable: |
string |
|
Define the annotation used to indicate the path to scrape. By default, Environment variable: |
string |
|
Define the annotation used to indicate the port to scrape. By default, Environment variable: |
string |
|
Define the annotation used to indicate the scheme to use for scraping By default, Environment variable: |
string |
|
EmptyDir volumes Environment variable: |
list of string |
|
If set, it will change the name of the container according to the configuration Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
CPU Requirements Environment variable: |
string |
|
Memory Requirements Environment variable: |
string |
|
If true, the 'app.kubernetes.io/version' label will be part of the selectors of Service and Deployment Environment variable: |
boolean |
|
If true, the 'app.kubernetes.io/name' label will be part of the selectors of Service and Deployment Environment variable: |
boolean |
|
Switch used to control whether non-idempotent fields are included in generated kubernetes resources to improve git-ops compatibility Environment variable: |
boolean |
|
The optional list of Secret names to load environment variables from. Environment variable: |
list of string |
|
The optional list of ConfigMap names to load environment variables from. Environment variable: |
list of string |
|
Whether this service is cluster-local. Cluster local services are not exposed to the outside world. More information in this link. Environment variable: |
boolean |
|
This value controls the minimum number of replicas each revision should have. Knative will attempt to never have less than this number of replicas at any point in time. Environment variable: |
int |
|
This value controls the maximum number of replicas each revision should have. Knative will attempt to never have more than this number of replicas running, or in the process of being created, at any point in time. Environment variable: |
int |
|
The scale-to-zero values control whether Knative allows revisions to scale down to zero, or stops at “1”. Environment variable: |
boolean |
|
Environment variable: |
|
|
Environment variable: |
|
|
Environment variable: |
int |
|
Environment variable: |
int |
|
Environment variable: |
int |
|
Environment variable: |
|
|
Environment variable: |
int |
|
Environment variable: |
int |
|
Environment variable: |
int |
|
Environment variable: |
string |
|
If set, the secret will mounted to the application container and its contents will be used for application configuration. Environment variable: |
string |
|
If set, the config map will be mounted to the application container and its contents will be used for application configuration. Environment variable: |
string |
|
The SELinux level label that applies to the container. Environment variable: |
string |
|
The SELinux role label that applies to the container. Environment variable: |
string |
|
The SELinux type label that applies to the container. Environment variable: |
string |
|
The SELinux user label that applies to the container. Environment variable: |
string |
|
The name of the GMSA credential spec to use. Environment variable: |
string |
|
GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field. Environment variable: |
string |
|
The UserName in Windows to run the entrypoint of the container process. Environment variable: |
string |
|
HostProcess determines if a container should be run as a 'Host Process' container. Environment variable: |
boolean |
|
The UID to run the entrypoint of the container process. Environment variable: |
long |
|
The GID to run the entrypoint of the container process. Environment variable: |
long |
|
Indicates that the container must run as a non-root user. Environment variable: |
boolean |
|
A list of groups applied to the first process run in each container, in addition to the container’s primary GID. If unspecified, no groups will be added to any container. Environment variable: |
list of long |
|
A special supplemental group that applies to all containers in a pod. Environment variable: |
long |
|
Sysctls hold a list of namespaced sysctls used for the pod. Environment variable: |
string |
|
It holds policies that will be used for applying fsGroup to a volume when volume is mounted. Values: OnRootMismatch, Always Environment variable: |
|
|
If set to true, Quarkus will attempt to deploy the application to the target knative cluster Environment variable: |
boolean |
|
If deploy is enabled, it will follow this strategy to update the resources to the target Knative cluster. Environment variable: |
|
|
Custom labels to add to all resources Environment variable: |
|
|
Custom annotations to add to all resources Environment variable: |
|
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
The name of the volumeName to mount. Environment variable: |
string |
|
The path to mount. Environment variable: |
string |
|
Path within the volumeName from which the container’s volumeName should be mounted. Environment variable: |
string |
|
ReadOnly Environment variable: |
boolean |
|
The name of the secret to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
The path where the file will be mounted. Environment variable: |
string |
required |
It must be a value between 0000 and 0777. If not specified, the volume defaultMode will be used. Environment variable: |
int |
|
Optional Environment variable: |
boolean |
|
The name of the ConfigMap to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
The path where the file will be mounted. Environment variable: |
string |
required |
It must be a value between 0000 and 0777. If not specified, the volume defaultMode will be used. Environment variable: |
int |
|
Optional Environment variable: |
boolean |
|
Git repository URL. Environment variable: |
string |
required |
The directory of the repository to mount. Environment variable: |
string |
|
The commit hash to use. Environment variable: |
string |
|
The name of the claim to mount. Environment variable: |
string |
required |
Default mode. When specifying an octal number, leading zero must be present. Environment variable: |
string |
|
Optional Environment variable: |
boolean |
|
The name of the disk to mount. Environment variable: |
string |
required |
The partition. Environment variable: |
int |
|
Filesystem type. Environment variable: |
string |
|
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The share name. Environment variable: |
string |
required |
The secret name. Environment variable: |
string |
required |
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The name of the disk to mount. Environment variable: |
string |
required |
The URI of the vhd blob object OR the resourceID of an Azure managed data disk if Kind is Managed Environment variable: |
string |
required |
Kind of disk. Environment variable: |
|
|
Disk caching mode. Environment variable: |
|
|
File system type. Environment variable: |
string |
|
Whether the volumeName is read only or not. Environment variable: |
boolean |
|
The container image. Environment variable: |
string |
|
Working directory. Environment variable: |
string |
|
The commands Environment variable: |
list of string |
|
The arguments Environment variable: |
list of string |
|
The service account. Environment variable: |
string |
|
The host under which the application is going to be exposed. Environment variable: |
string |
|
The port number. Refers to the container port. Environment variable: |
int |
|
The host port. Environment variable: |
int |
|
The application path (refers to web application path). Environment variable: |
string |
|
The protocol. Environment variable: |
|
|
Environment variable: |
int |
|
Image pull policy. Environment variable: |
|
|
The image pull secret Environment variable: |
list of string |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|
The amount of time to wait before starting to probe. Environment variable: |
|
|
The period in which the action should be called. Environment variable: |
|
|
The amount of time to wait for each action. Environment variable: |
|
|
The success threshold to use. Environment variable: |
int |
|
The failure threshold to use. Environment variable: |
int |
|
The port number to use when configuring the Environment variable: |
int |
|
The port name for selecting the port of the Environment variable: |
string |
|
The http path to use for the probe. For this to work, the container port also needs to be set. Assuming the container port has been set (as per above comment), if execAction or tcpSocketAction are not set, an HTTP probe will be used automatically even if no path is set (which will result in the root path being used). If Smallrye Health is used, the path will automatically be set according to the health check path. Environment variable: |
string |
|
The command to use for the probe. Environment variable: |
string |
|
The tcp socket to use for the probe (the format is host:port). Environment variable: |
string |
|
The gRPC port to use for the probe (the format is either port or port:service). Environment variable: |
string |
|