Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add security context config to SOLR containers #702

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions controllers/util/solr_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCl
initContainers = append(initContainers, customPodOptions.InitContainers...)
}

AllowPrivilegeEscalationValue := false;
RunAsNonRootValue := false

containers := []corev1.Container{
{
Name: SolrNodeContainer,
Expand Down Expand Up @@ -496,6 +499,16 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCl
PostStart: postStart,
PreStop: preStop,
},
SecurityContext: &corev1.SecurityContext{
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
AllowPrivilegeEscalation: &AllowPrivilegeEscalationValue,
RunAsNonRoot: &RunAsNonRootValue,
},
},
}

Expand Down Expand Up @@ -753,6 +766,9 @@ func generateSolrSetupInitContainers(solrCloud *solr.SolrCloud, solrCloudStatus
}
}

AllowPrivilegeEscalationValue := false
RunAsNonRootValue := false

volumePrepResources := corev1.ResourceList{
corev1.ResourceCPU: *DefaultSolrVolumePrepInitContainerCPU,
corev1.ResourceMemory: *DefaultSolrVolumePrepInitContainerMemory,
Expand All @@ -766,6 +782,16 @@ func generateSolrSetupInitContainers(solrCloud *solr.SolrCloud, solrCloudStatus
Resources: corev1.ResourceRequirements{
Requests: volumePrepResources,
Limits: volumePrepResources,
}
SecurityContext: &corev1.SecurityContext{
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
SeccompProfile: &corev1.SeccompProfile{
Type: "RuntimeDefault",
},
AllowPrivilegeEscalation: &AllowPrivilegeEscalationValue,
RunAsNonRoot: &RunAsNonRootValue,
},
}

Expand Down