Skip to content

Commit f565c4d

Browse files
committed
Don't run init container as root and avoid chmod and chowning (#183)
1 parent b087117 commit f565c4d

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ All notable changes to this project will be documented in this file.
88

99
- Updated stackable image versions ([#176])
1010
- `operator-rs` `0.22.0``0.27.1` ([#178])
11+
- Don't run init container as root and avoid chmod and chowning ([#183])
1112

1213
[#176]: https://github.com/stackabletech/spark-k8s-operator/pull/176
1314
[#178]: https://github.com/stackabletech/spark-k8s-operator/pull/178
15+
[#183]: https://github.com/stackabletech/spark-k8s-operator/pull/183
1416

1517
## [0.6.0] - 2022-11-07
1618

rust/crd/src/constants.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub const ACCESS_KEY_ID: &str = "accessKeyId";
2121
pub const SECRET_ACCESS_KEY: &str = "secretAccessKey";
2222
pub const S3_SECRET_DIR_NAME: &str = "/stackable/secrets";
2323

24-
pub const SPARK_UID: i64 = 1000;
2524
pub const MIN_MEMORY_OVERHEAD: u32 = 384;
2625
pub const JVM_OVERHEAD_FACTOR: f32 = 0.1;
2726
pub const NON_JVM_OVERHEAD_FACTOR: f32 = 0.4;

rust/operator-binary/src/spark_k8s_controller.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use snafu::{OptionExt, ResultExt, Snafu};
2-
use stackable_operator::builder::{
3-
ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder, PodSecurityContextBuilder,
4-
};
2+
use stackable_operator::builder::{ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder};
53

64
use stackable_operator::commons::s3::InlinedS3BucketSpec;
75
use stackable_operator::commons::tls::{CaCert, TlsVerification};
@@ -481,17 +479,12 @@ fn build_spark_role_serviceaccount(
481479
}
482480

483481
fn security_context() -> PodSecurityContext {
484-
PodSecurityContextBuilder::new()
485-
.fs_group(1000)
486-
// OpenShift generates UIDs for processes inside Pods. Setting the UID is optional,
487-
// *but* if specified, OpenShift will check that the value is within the
488-
// valid range generated by the SCC (security context constraints) for this Pod.
489-
// On the other hand, it is *required* to set the process UID in KinD, K3S as soon
490-
// as the runAsGroup property is set.
491-
.run_as_user(SPARK_UID)
492-
// Required to access files in mounted volumes on OpenShift.
493-
.run_as_group(0)
494-
.build()
482+
PodSecurityContext {
483+
run_as_user: Some(1000),
484+
run_as_group: Some(1000),
485+
fs_group: Some(1000),
486+
..PodSecurityContext::default()
487+
}
495488
}
496489

497490
pub fn error_policy(_obj: Arc<SparkApplication>, _error: &Error, _ctx: Arc<Ctx>) -> Action {

0 commit comments

Comments
 (0)