FSGroup implementation

This commit is contained in:
Paul Morie
2015-10-20 14:49:39 -04:00
parent f960b05fe1
commit 3cd12f5e05
48 changed files with 21626 additions and 20935 deletions

View File

@@ -69,6 +69,10 @@ func (p *plugin) Admit(a admission.Attributes) (err error) {
}
}
if pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.FSGroup != nil {
return apierrors.NewForbidden(a.GetResource(), pod.Name, fmt.Errorf("SecurityContext.FSGroup is forbidden"))
}
for _, v := range pod.Spec.Containers {
if v.SecurityContext != nil {
if v.SecurityContext.SELinuxOptions != nil {

View File

@@ -101,6 +101,8 @@ func TestPodSecurityContextAdmission(t *testing.T) {
},
}
fsGroup := int64(1001)
tests := []struct {
securityContext api.PodSecurityContext
errorExpected bool
@@ -115,6 +117,12 @@ func TestPodSecurityContextAdmission(t *testing.T) {
},
errorExpected: true,
},
{
securityContext: api.PodSecurityContext{
FSGroup: &fsGroup,
},
errorExpected: true,
},
}
for _, test := range tests {
pod.Spec.SecurityContext = &test.securityContext