forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
security.go
41 lines (35 loc) · 1.43 KB
/
security.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package controller
import (
"fmt"
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
sccallocation "github.com/openshift/origin/pkg/security/controller"
"github.com/openshift/origin/pkg/security/mcs"
"github.com/openshift/origin/pkg/security/uid"
)
func RunNamespaceSecurityAllocationController(ctx *ControllerContext) (bool, error) {
uidRange, err := uid.ParseRange(ctx.OpenshiftControllerConfig.SecurityAllocator.UIDAllocatorRange)
if err != nil {
return true, fmt.Errorf("unable to describe UID range: %v", err)
}
mcsRange, err := mcs.ParseRange(ctx.OpenshiftControllerConfig.SecurityAllocator.MCSAllocatorRange)
if err != nil {
return true, fmt.Errorf("unable to describe MCS category range: %v", err)
}
kubeClient, err := ctx.ClientBuilder.Client(bootstrappolicy.InfraNamespaceSecurityAllocationControllerServiceAccountName)
if err != nil {
return true, err
}
securityClient, err := ctx.ClientBuilder.OpenshiftSecurityClient(bootstrappolicy.InfraNamespaceSecurityAllocationControllerServiceAccountName)
if err != nil {
return true, err
}
controller := sccallocation.NewNamespaceSCCAllocationController(
ctx.KubernetesInformers.Core().V1().Namespaces(),
kubeClient.CoreV1().Namespaces(),
securityClient.SecurityV1(),
uidRange,
sccallocation.DefaultMCSAllocation(uidRange, mcsRange, ctx.OpenshiftControllerConfig.SecurityAllocator.MCSLabelsPerProject),
)
go controller.Run(ctx.Stop)
return true, nil
}