Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sources/assemblies/assembly-deploying.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ include::../modules/deploying/proc-deploying-operator-crd.adoc[leveloffset=+2]
include::../modules/deploying/proc-connecting-console.adoc[leveloffset=+1]
//TLS configuration for the console server
include::../modules/deploying/ref-tls-configuration.adoc[leveloffset=+2]
//Deployment configuration (scheduling, container overrides)
include::../modules/deploying/ref-deployment-configuration.adoc[leveloffset=+2]
//virtual kafka clusters
include::../modules/deploying/ref-virtual-kafka-clusters.adoc[leveloffset=+2]
//cluster connection authentication options
Expand Down
152 changes: 152 additions & 0 deletions docs/sources/modules/deploying/ref-deployment-configuration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
:_mod-docs-content-type: REFERENCE

// Module included in the following assemblies:
//
// assembly-deploying.adoc

[id='ref-deployment-configuration-{context}']
= Configuring the console deployment

[role="_abstract"]
You can customize how the operator deploys the console by configuring the `spec.deployment` field of the `Console` custom resource.
This field provides a template that mirrors the structure of a Kubernetes `Deployment` manifest, giving you control over pod scheduling and container configuration.

`spec.deployment` is optional.
When omitted, the operator deploys the console using default settings.

== Deployment template properties

`spec.deployment.metadata`:: Optional labels and annotations to apply to the `Deployment` resource itself.
`spec.deployment.metadata.labels`:: Additional labels to add to the `Deployment`.
`spec.deployment.metadata.annotations`:: Additional annotations to add to the `Deployment`.
`spec.deployment.spec.template`:: Template applied to the console pod.
`spec.deployment.spec.template.metadata`:: Optional labels and annotations to apply to the console pod.
`spec.deployment.spec.template.metadata.labels`:: Additional labels to add to the pod.
`spec.deployment.spec.template.metadata.annotations`:: Additional annotations to add to the pod.
`spec.deployment.spec.template.spec`:: Spec for the console pod. Configures scheduling constraints and the server container.

=== Pod scheduling properties

`spec.deployment.spec.template.spec.affinity`:: The pod's affinity rules.
Constrains which node the console pod is eligible to be scheduled on, based on node labels or the labels of other pods already running on a node.
See the https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity[Kubernetes affinity documentation] for details.
`spec.deployment.spec.template.spec.tolerations`:: The pod's tolerations.
Allows the console pod to be scheduled onto a node that has matching taints.
See the https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/[Kubernetes taints and tolerations documentation] for details.
`spec.deployment.spec.template.spec.topologySpreadConstraints`:: The pod's topology spread constraints.
Controls how the console pod is spread across failure-domains such as regions, zones, or nodes.
See the https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/[Kubernetes topology spread constraints documentation] for details.
`spec.deployment.spec.template.spec.nodeSelector`:: A label selector that must match a node's labels for the console pod to be scheduled on that node.
Specified as a map of key-value pairs.

=== Server container properties

`spec.deployment.spec.template.spec.serverContainer`:: Template for the console server container.
`spec.deployment.spec.template.spec.serverContainer.image`:: Container image to use for the console server.
When omitted, the operator uses its built-in default image.
`spec.deployment.spec.template.spec.serverContainer.imagePullPolicy`:: Image pull policy for the console server image.
Accepted values are `Always`, `IfNotPresent`, and `Never`.
When omitted, the operator defaults to `IfNotPresent` for images specified by digest and `Always` for all other images.
`spec.deployment.spec.template.spec.serverContainer.resources`:: CPU and memory resource requests and limits for the console server container.
`spec.deployment.spec.template.spec.serverContainer.env`:: Additional environment variables to set on the console server container.

== Examples

=== Scheduling the console pod on specific nodes

The following example uses a `nodeSelector` to schedule the console pod only on a node labeled `disktype: ssd`, and adds a toleration so that the pod can be placed on a node tainted `dedicated=console:NoSchedule`.

[source,yaml]
----
apiVersion: console.streamshub.github.com/v1alpha1
kind: Console
metadata:
name: my-console
spec:
hostname: my-console.<cluster_domain>
deployment:
spec:
template:
spec:
nodeSelector:
disktype: ssd
tolerations:
- key: dedicated
operator: Equal
value: console
effect: NoSchedule
kafkaClusters:
- name: console-kafka
namespace: kafka
listener: secure
credentials:
kafkaUser:
name: console-kafka-user1
----

=== Pinning the console to a specific availability zone using node affinity

The following example uses a preferred node affinity rule to favor nodes in the `us-east-1a` availability zone.

[source,yaml]
----
apiVersion: console.streamshub.github.com/v1alpha1
kind: Console
metadata:
name: my-console
spec:
hostname: my-console.<cluster_domain>
deployment:
spec:
template:
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- us-east-1a
kafkaClusters:
- name: console-kafka
namespace: kafka
listener: secure
credentials:
kafkaUser:
name: console-kafka-user1
----

=== Overriding the server container image and resources

[source,yaml]
----
apiVersion: console.streamshub.github.com/v1alpha1
kind: Console
metadata:
name: my-console
spec:
hostname: my-console.<cluster_domain>
deployment:
spec:
template:
spec:
serverContainer:
image: quay.io/my-org/console-api:latest
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
kafkaClusters:
- name: console-kafka
namespace: kafka
listener: secure
credentials:
kafkaUser:
name: console-kafka-user1
----
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.jboss.logging.Logger;

import com.github.streamshub.console.api.v1alpha1.Console;
import com.github.streamshub.console.api.v1alpha1.status.Condition;
import com.github.streamshub.console.api.v1alpha1.status.ConditionBuilder;
Expand Down Expand Up @@ -227,6 +229,7 @@ public ErrorStatusUpdateControl<Console> updateErrorStatus(Console resource,
Context<Console> context,
Exception e) {

Logger.getLogger(getClass()).debug("Exception during reconcile", e);
var result = context.managedWorkflowAndDependentResourceContext().getWorkflowReconcileResult();
determineConditions(resource, result, e);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.github.streamshub.console.api.v1alpha1.spec.containers.Containers;
import com.github.streamshub.console.api.v1alpha1.spec.metrics.MetricsSource;
import com.github.streamshub.console.api.v1alpha1.spec.security.GlobalSecurity;
import com.github.streamshub.console.api.v1alpha1.spec.template.DeploymentTemplate;

import io.fabric8.kubernetes.api.model.EnvVar;
import io.sundr.builder.annotations.Buildable;
Expand All @@ -34,14 +35,23 @@ public class ConsoleSpec {
Tls tls;

@JsonPropertyDescription("""
Templates for Console instance containers. The templates allow \
users to specify how the Kubernetes resources are generated.
Template for the Console Deployment. Allows customisation of the Deployment \
and pod metadata, scheduling constraints (affinity, tolerations, topology \
spread constraints, and node selector), and the server container image, \
pull policy, resources, and environment variables.
""")
DeploymentTemplate deployment;

@JsonPropertyDescription("""
DEPRECATED: Templates for Console instance containers. The templates allow \
users to specify how the Kubernetes resources are generated. \
Use `deployment.spec.template.spec.serverContainer` property instead.
""")
Containers containers;

@JsonPropertyDescription("""
DEPRECATED: Image overrides to be used for the API and UI servers. \
Use `containers` property instead.
Use `deployment.spec.template.spec.serverContainer.image` property instead.
""")
Images images;

Expand All @@ -57,7 +67,7 @@ public class ConsoleSpec {

@JsonPropertyDescription("""
DEPRECATED: Environment variables which should be applied to the API container. \
Use `containers` property instead.
Use `deployment.spec.template.spec.serverContainer.env` property instead.
""")
List<EnvVar> env;

Expand All @@ -77,6 +87,14 @@ public void setTls(Tls tls) {
this.tls = tls;
}

public DeploymentTemplate getDeployment() {
return deployment;
}

public void setDeployment(DeploymentTemplate deployment) {
this.deployment = deployment;
}

public Containers getContainers() {
return containers;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.github.streamshub.console.api.v1alpha1.spec.template;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonValue;

import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.ResourceRequirements;
import io.sundr.builder.annotations.Buildable;

@Buildable(editableEnabled = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContainerTemplate {

@JsonPropertyDescription("Container image to be used for the container.")
private String image;

@JsonPropertyDescription("""
Image pull policy to be used for the container image. \
One of Always, IfNotPresent, or Never. \
Defaults to Always when the image tag is not a digest, \
and IfNotPresent when a digest is specified.
""")
private ImagePullPolicy imagePullPolicy;

@JsonPropertyDescription("CPU and memory resources to reserve.")
private ResourceRequirements resources;

@JsonPropertyDescription("Environment variables which should be applied to the container.")
private List<EnvVar> env;

public String getImage() {
return image;
}

public void setImage(String image) {
this.image = image;
}

public ImagePullPolicy getImagePullPolicy() {
return imagePullPolicy;
}

public void setImagePullPolicy(ImagePullPolicy imagePullPolicy) {
this.imagePullPolicy = imagePullPolicy;
}

public ResourceRequirements getResources() {
return resources;
}

public void setResources(ResourceRequirements resources) {
this.resources = resources;
}

public List<EnvVar> getEnv() {
return env;
}

public void setEnv(List<EnvVar> env) {
this.env = env;
}

public enum ImagePullPolicy {
ALWAYS("Always"),
IF_NOT_PRESENT("IfNotPresent"),
NEVER("Never");

private final String value;

ImagePullPolicy(String value) {
this.value = value;
}

@JsonValue
public String value() {
return value;
}

@JsonCreator
public static ImagePullPolicy fromValue(String value) {
for (var policy : values()) {
if (policy.value.equals(value)) {
return policy;
}
}
throw new IllegalArgumentException("Invalid imagePullPolicy: " + value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.streamshub.console.api.v1alpha1.spec.template;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;

import io.sundr.builder.annotations.Buildable;

@Buildable(editableEnabled = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DeploymentSpecTemplate {

@JsonPropertyDescription("""
Template for the console pod. Allows configuration of pod metadata, \
scheduling constraints (affinity, tolerations, topology spread constraints, \
and node selector), and the server container image, pull policy, resources, \
and environment variables.
""")
private PodTemplate template;

public PodTemplate getTemplate() {
return template;
}

public void setTemplate(PodTemplate template) {
this.template = template;
}

}
Loading
Loading