Skip to content

Commit 98a8bc3

Browse files
committed
configure executors with pod templates
1 parent ca4ba59 commit 98a8bc3

File tree

13 files changed

+516
-123
lines changed

13 files changed

+516
-123
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 18 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ indoc = "2"
3535

3636
# TODO: revert before merging
3737
[patch."https://github.com/stackabletech/operator-rs.git"]
38-
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
39-
stackable-operator = { path = "../operator-rs/crates/stackable-operator" }
38+
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
39+
# stackable-operator = { path = "../operator-rs/crates/stackable-operator" }

crate-hashes.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/spark-k8s-operator/crds/crds.yaml

Lines changed: 186 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,191 @@ spec:
19101910
description: Flag to stop the cluster. This means all deployed resources (e.g. Services, StatefulSets, ConfigMaps) are kept but all deployed Pods (e.g. replicas from a StatefulSet) are scaled to 0 and therefore stopped and removed. If applied at the same time with `reconciliationPaused`, the latter will pause reconciliation and `stopped` will take no effect until `reconciliationPaused` is set to false or removed.
19111911
type: boolean
19121912
type: object
1913+
executor:
1914+
description: Spark connect executor properties.
1915+
nullable: true
1916+
properties:
1917+
cliOverrides:
1918+
additionalProperties:
1919+
type: string
1920+
default: {}
1921+
type: object
1922+
config:
1923+
default: {}
1924+
properties:
1925+
logging:
1926+
default:
1927+
containers: {}
1928+
enableVectorAgent: null
1929+
description: Logging configuration, learn more in the [logging concept documentation](https://docs.stackable.tech/home/nightly/concepts/logging).
1930+
properties:
1931+
containers:
1932+
additionalProperties:
1933+
anyOf:
1934+
- required:
1935+
- custom
1936+
- {}
1937+
description: Log configuration of the container
1938+
properties:
1939+
console:
1940+
description: Configuration for the console appender
1941+
nullable: true
1942+
properties:
1943+
level:
1944+
description: The log level threshold. Log events with a lower log level are discarded.
1945+
enum:
1946+
- TRACE
1947+
- DEBUG
1948+
- INFO
1949+
- WARN
1950+
- ERROR
1951+
- FATAL
1952+
- NONE
1953+
nullable: true
1954+
type: string
1955+
type: object
1956+
custom:
1957+
description: Custom log configuration provided in a ConfigMap
1958+
properties:
1959+
configMap:
1960+
description: ConfigMap containing the log configuration files
1961+
nullable: true
1962+
type: string
1963+
type: object
1964+
file:
1965+
description: Configuration for the file appender
1966+
nullable: true
1967+
properties:
1968+
level:
1969+
description: The log level threshold. Log events with a lower log level are discarded.
1970+
enum:
1971+
- TRACE
1972+
- DEBUG
1973+
- INFO
1974+
- WARN
1975+
- ERROR
1976+
- FATAL
1977+
- NONE
1978+
nullable: true
1979+
type: string
1980+
type: object
1981+
loggers:
1982+
additionalProperties:
1983+
description: Configuration of a logger
1984+
properties:
1985+
level:
1986+
description: The log level threshold. Log events with a lower log level are discarded.
1987+
enum:
1988+
- TRACE
1989+
- DEBUG
1990+
- INFO
1991+
- WARN
1992+
- ERROR
1993+
- FATAL
1994+
- NONE
1995+
nullable: true
1996+
type: string
1997+
type: object
1998+
default: {}
1999+
description: Configuration per logger
2000+
type: object
2001+
type: object
2002+
description: Log configuration per container.
2003+
type: object
2004+
enableVectorAgent:
2005+
description: Wether or not to deploy a container with the Vector log agent.
2006+
nullable: true
2007+
type: boolean
2008+
type: object
2009+
requestedSecretLifetime:
2010+
description: Request secret (currently only autoTls certificates) lifetime from the secret operator, e.g. `7d`, or `30d`. This can be shortened by the `maxCertificateLifetime` setting on the SecretClass issuing the TLS certificate.
2011+
nullable: true
2012+
type: string
2013+
resources:
2014+
default:
2015+
cpu:
2016+
max: null
2017+
min: null
2018+
memory:
2019+
limit: null
2020+
runtimeLimits: {}
2021+
storage: {}
2022+
description: Resource usage is configured here, this includes CPU usage, memory usage and disk storage usage, if this role needs any.
2023+
properties:
2024+
cpu:
2025+
default:
2026+
max: null
2027+
min: null
2028+
properties:
2029+
max:
2030+
description: The maximum amount of CPU cores that can be requested by Pods. Equivalent to the `limit` for Pod resource configuration. Cores are specified either as a decimal point number or as milli units. For example:`1.5` will be 1.5 cores, also written as `1500m`.
2031+
nullable: true
2032+
type: string
2033+
min:
2034+
description: The minimal amount of CPU cores that Pods need to run. Equivalent to the `request` for Pod resource configuration. Cores are specified either as a decimal point number or as milli units. For example:`1.5` will be 1.5 cores, also written as `1500m`.
2035+
nullable: true
2036+
type: string
2037+
type: object
2038+
memory:
2039+
properties:
2040+
limit:
2041+
description: 'The maximum amount of memory that should be available to the Pod. Specified as a byte [Quantity](https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/quantity/), which means these suffixes are supported: E, P, T, G, M, k. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki. For example, the following represent roughly the same value: `128974848, 129e6, 129M, 128974848000m, 123Mi`'
2042+
nullable: true
2043+
type: string
2044+
runtimeLimits:
2045+
description: Additional options that can be specified.
2046+
type: object
2047+
type: object
2048+
storage:
2049+
type: object
2050+
type: object
2051+
type: object
2052+
configOverrides:
2053+
additionalProperties:
2054+
additionalProperties:
2055+
type: string
2056+
type: object
2057+
default: {}
2058+
description: The `configOverrides` can be used to configure properties in product config files that are not exposed in the CRD. Read the [config overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#config-overrides) and consult the operator specific usage guide documentation for details on the available config files and settings for the specific product.
2059+
type: object
2060+
envOverrides:
2061+
additionalProperties:
2062+
type: string
2063+
default: {}
2064+
description: '`envOverrides` configure environment variables to be set in the Pods. It is a map from strings to strings - environment variables and the value to set. Read the [environment variable overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#env-overrides) for more information and consult the operator specific usage guide to find out about the product specific environment variables that are available.'
2065+
type: object
2066+
jvmArgumentOverrides:
2067+
default:
2068+
add: []
2069+
remove: []
2070+
removeRegex: []
2071+
description: Allows overriding JVM arguments. Please read on the [JVM argument overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#jvm-argument-overrides) for details on the usage.
2072+
properties:
2073+
add:
2074+
default: []
2075+
description: JVM arguments to be added
2076+
items:
2077+
type: string
2078+
type: array
2079+
remove:
2080+
default: []
2081+
description: JVM arguments to be removed by exact match
2082+
items:
2083+
type: string
2084+
type: array
2085+
removeRegex:
2086+
default: []
2087+
description: JVM arguments matching any of this regexes will be removed
2088+
items:
2089+
type: string
2090+
type: array
2091+
type: object
2092+
podOverrides:
2093+
default: {}
2094+
description: In the `podOverrides` property you can define a [PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) to override any property that can be set on a Kubernetes Pod. Read the [Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides) for more information.
2095+
type: object
2096+
x-kubernetes-preserve-unknown-fields: true
2097+
type: object
19132098
image:
19142099
anyOf:
19152100
- required:
@@ -1959,7 +2144,7 @@ spec:
19592144
type: string
19602145
type: object
19612146
server:
1962-
description: A connect server definition.
2147+
description: A spark connect server definition.
19632148
nullable: true
19642149
properties:
19652150
cliOverrides:

rust/operator-binary/src/connect/common.rs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1-
use stackable_operator::kvp::ObjectLabels;
1+
use snafu::{ResultExt, Snafu};
2+
use stackable_operator::{
3+
kvp::ObjectLabels,
4+
role_utils::{JavaCommonConfig, JvmArgumentOverrides},
5+
};
26
use strum::Display;
37

48
use crate::{
59
connect::crd::{CONNECT_CONTROLLER_NAME, CONNECT_SERVER_ROLE_NAME},
6-
crd::constants::{APP_NAME, OPERATOR_NAME},
10+
crd::constants::{
11+
APP_NAME, JVM_SECURITY_PROPERTIES_FILE, LOG4J2_CONFIG_FILE, OPERATOR_NAME,
12+
VOLUME_MOUNT_PATH_CONFIG, VOLUME_MOUNT_PATH_LOG_CONFIG,
13+
},
714
};
815

916
const DUMMY_SPARK_CONNECT_GROUP_NAME: &str = "default";
1017

18+
#[derive(Snafu, Debug)]
19+
#[allow(clippy::enum_variant_names)]
20+
pub enum Error {
21+
#[snafu(display("failed to merge jvm argument overrides"))]
22+
MergeJvmArgumentOverrides {
23+
source: stackable_operator::role_utils::Error,
24+
},
25+
}
26+
1127
pub fn labels<'a, T>(scs: &'a T, app_version_label: &'a str, role: &'a str) -> ObjectLabels<'a, T> {
1228
ObjectLabels {
1329
owner: scs,
@@ -36,3 +52,26 @@ pub fn object_name(stacklet_name: &str, role: SparkConnectRole) -> String {
3652
SparkConnectRole::Executor => todo!(),
3753
}
3854
}
55+
56+
// Returns the jvm arguments a user has provided merged with the operator props.
57+
pub fn jvm_args(user_java_config: Option<&JavaCommonConfig>) -> Result<String, Error> {
58+
let jvm_args = vec![
59+
format!("-Dlog4j.configurationFile={VOLUME_MOUNT_PATH_LOG_CONFIG}/{LOG4J2_CONFIG_FILE}"),
60+
format!(
61+
"-Djava.security.properties={VOLUME_MOUNT_PATH_CONFIG}/{JVM_SECURITY_PROPERTIES_FILE}"
62+
),
63+
];
64+
65+
if let Some(user_jvm_props) = user_java_config {
66+
let operator_generated = JvmArgumentOverrides::new_with_only_additions(jvm_args.clone());
67+
let mut user_jvm_props_copy = user_jvm_props.jvm_argument_overrides.clone();
68+
user_jvm_props_copy
69+
.try_merge(&operator_generated)
70+
.context(MergeJvmArgumentOverridesSnafu)?;
71+
Ok(user_jvm_props_copy
72+
.effective_jvm_config_after_merging()
73+
.join(" "))
74+
} else {
75+
Ok(jvm_args.join(" "))
76+
}
77+
}

0 commit comments

Comments
 (0)