Skip to content

Commit 96081c9

Browse files
committed
Don't run init container as root and avoid chmod and chowning (#382)
1 parent c42c66c commit 96081c9

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
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 ([#374]).
1010
- `operator-rs` `0.22.0` -> `0.27.1` ([#377]).
11+
- Don't run init container as root and avoid chmod and chowning ([#382]).
1112

1213
[#374]: https://github.com/stackabletech/opa-operator/pull/374
1314
[#377]: https://github.com/stackabletech/opa-operator/pull/377
15+
[#382]: https://github.com/stackabletech/opa-operator/pull/382
1416

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

rust/operator-binary/src/controller.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ use crate::discovery::{self, build_discovery_configmaps};
55

66
use snafu::{OptionExt, ResultExt, Snafu};
77
use stackable_opa_crd::{OpaCluster, OpaRole, OpaStorageConfig, APP_NAME, OPERATOR_NAME};
8+
use stackable_operator::k8s_openapi::api::core::v1::PodSecurityContext;
89
use stackable_operator::{
9-
builder::{
10-
ConfigMapBuilder, ContainerBuilder, FieldPathEnvVar, ObjectMetaBuilder, PodBuilder,
11-
SecurityContextBuilder,
12-
},
10+
builder::{ConfigMapBuilder, ContainerBuilder, FieldPathEnvVar, ObjectMetaBuilder, PodBuilder},
1311
commons::resources::{NoRuntimeLimits, Resources},
1412
k8s_openapi::{
1513
api::{
@@ -481,19 +479,12 @@ fn build_server_rolegroup_daemonset(
481479
"-x".to_string(),
482480
"-c".to_string(),
483481
[
484-
format!("mkdir -p {}", BUNDLES_ACTIVE_DIR),
485-
format!("mkdir -p {}", BUNDLES_INCOMING_DIR),
486-
format!("mkdir -p {}", BUNDLES_TMP_DIR),
487-
format!("chown -R stackable:stackable {}", BUNDLES_ACTIVE_DIR),
488-
format!("chown -R stackable:stackable {}", BUNDLES_INCOMING_DIR),
489-
format!("chown -R stackable:stackable {}", BUNDLES_TMP_DIR),
490-
format!("chmod -R a=,u=rwX {}", BUNDLES_ACTIVE_DIR),
491-
format!("chmod -R a=,u=rwX {}", BUNDLES_INCOMING_DIR),
492-
format!("chmod -R a=,u=rwX {}", BUNDLES_TMP_DIR),
482+
format!("mkdir -p {BUNDLES_ACTIVE_DIR}"),
483+
format!("mkdir -p {BUNDLES_INCOMING_DIR}"),
484+
format!("mkdir -p {BUNDLES_TMP_DIR}"),
493485
]
494486
.join(" && "),
495487
])
496-
.security_context(SecurityContextBuilder::run_as_root())
497488
.add_volume_mount("bundles", "/bundles")
498489
.build();
499490

@@ -546,6 +537,12 @@ fn build_server_rolegroup_daemonset(
546537
..Volume::default()
547538
})
548539
.service_account_name(sa_name)
540+
.security_context(PodSecurityContext {
541+
run_as_user: Some(1000),
542+
run_as_group: Some(1000),
543+
fs_group: Some(1000),
544+
..PodSecurityContext::default()
545+
})
549546
.build_template(),
550547
..DaemonSetSpec::default()
551548
}),

0 commit comments

Comments
 (0)