Commit 5812c876 authored by Pengfei Ni's avatar Pengfei Ni

kuberuntime: set namespsace options regardless of security context

parent 3b8e3279
...@@ -41,24 +41,24 @@ func (m *kubeGenericRuntimeManager) determineEffectiveSecurityContext(pod *v1.Po ...@@ -41,24 +41,24 @@ func (m *kubeGenericRuntimeManager) determineEffectiveSecurityContext(pod *v1.Po
} }
// set namespace options and supplemental groups. // set namespace options and supplemental groups.
podSc := pod.Spec.SecurityContext
if podSc == nil {
return synthesized
}
synthesized.NamespaceOptions = &runtimeapi.NamespaceOption{ synthesized.NamespaceOptions = &runtimeapi.NamespaceOption{
HostNetwork: pod.Spec.HostNetwork, HostNetwork: pod.Spec.HostNetwork,
HostIpc: pod.Spec.HostIPC, HostIpc: pod.Spec.HostIPC,
HostPid: pod.Spec.HostPID, HostPid: pod.Spec.HostPID,
} }
if podSc.FSGroup != nil { podSc := pod.Spec.SecurityContext
synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, *podSc.FSGroup) if podSc != nil {
if podSc.FSGroup != nil {
synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, *podSc.FSGroup)
}
if podSc.SupplementalGroups != nil {
synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, podSc.SupplementalGroups...)
}
} }
if groups := m.runtimeHelper.GetExtraSupplementalGroupsForPod(pod); len(groups) > 0 { if groups := m.runtimeHelper.GetExtraSupplementalGroupsForPod(pod); len(groups) > 0 {
synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, groups...) synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, groups...)
} }
if podSc.SupplementalGroups != nil {
synthesized.SupplementalGroups = append(synthesized.SupplementalGroups, podSc.SupplementalGroups...)
}
return synthesized return synthesized
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment