security: run the crash collector as ceph user

The crash collector does not have the command line arguments
to run as ceph user id 167, so we set the security context
to run as the ceph user in the main crash collector
container.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit df6d7af355)
This commit is contained in:
Travis Nielsen authored and Mergify committed 2022-10-31 17:14:39 +00:00
1 parent 21c0612559
commit ec226e6c68
3 files changed
+16 -1

No files matched your search

+10
View File
@@ -38,6 +38,7 @@ import (
kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
)
const (
@@ -53,6 +54,7 @@ const (
daemonTypeLabel = "ceph_daemon_type"
ExternalMgrAppName = "rook-ceph-mgr-external"
ServiceExternalMetricName = "http-external-metrics"
CephUserID = 167
livenessProbeTimeoutSeconds int32 = 5
livenessProbeInitialDelaySeconds int32 = 10
startupProbeFailuresDaemonDefault int32 = 6 // multiply by 10 = effective startup timeout
@@ -656,6 +658,14 @@ func PodSecurityContext() *v1.SecurityContext {
}
}
// PodSecurityContext detects if the pod needs privileges to run
func CephSecurityContext() *v1.SecurityContext {
context := PodSecurityContext()
context.RunAsUser = pointer.Int64(CephUserID)
context.RunAsGroup = pointer.Int64(CephUserID)
return context
}
// PrivilegedContext returns a privileged Pod security context
func PrivilegedContext(runAsRoot bool) *v1.SecurityContext {
privileged := true