forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserviceaccount.go
82 lines (67 loc) · 2.75 KB
/
serviceaccount.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package controller
import (
"github.com/golang/glog"
kapiv1 "k8s.io/api/core/v1"
sacontroller "k8s.io/kubernetes/pkg/controller/serviceaccount"
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
serviceaccountcontrollers "github.com/openshift/origin/pkg/serviceaccounts/controllers"
)
func RunServiceAccountController(ctx ControllerContext) (bool, error) {
if len(ctx.OpenshiftControllerConfig.ServiceAccount.ManagedNames) == 0 {
glog.Infof("Skipped starting Service Account Manager, no managed names specified")
return false, nil
}
options := sacontroller.DefaultServiceAccountsControllerOptions()
options.ServiceAccounts = []kapiv1.ServiceAccount{}
for _, saName := range ctx.OpenshiftControllerConfig.ServiceAccount.ManagedNames {
// the upstream controller does this one, so we don't have to
if saName == "default" {
continue
}
sa := kapiv1.ServiceAccount{}
sa.Name = saName
options.ServiceAccounts = append(options.ServiceAccounts, sa)
}
controller, err := sacontroller.NewServiceAccountsController(
ctx.ExternalKubeInformers.Core().V1().ServiceAccounts(),
ctx.ExternalKubeInformers.Core().V1().Namespaces(),
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceAccountControllerServiceAccountName),
options)
if err != nil {
return true, nil
}
go controller.Run(3, ctx.Stop)
return true, nil
}
func RunServiceAccountPullSecretsController(ctx ControllerContext) (bool, error) {
kc := ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceAccountPullSecretsControllerServiceAccountName)
go serviceaccountcontrollers.NewDockercfgDeletedController(
ctx.ExternalKubeInformers.Core().V1().Secrets(),
kc,
serviceaccountcontrollers.DockercfgDeletedControllerOptions{},
).Run(ctx.Stop)
go serviceaccountcontrollers.NewDockercfgTokenDeletedController(
ctx.ExternalKubeInformers.Core().V1().Secrets(),
kc,
serviceaccountcontrollers.DockercfgTokenDeletedControllerOptions{},
).Run(ctx.Stop)
dockerURLsInitialized := make(chan struct{})
dockercfgController := serviceaccountcontrollers.NewDockercfgController(
ctx.ExternalKubeInformers.Core().V1().ServiceAccounts(),
ctx.ExternalKubeInformers.Core().V1().Secrets(),
kc,
serviceaccountcontrollers.DockercfgControllerOptions{DockerURLsInitialized: dockerURLsInitialized},
)
go dockercfgController.Run(5, ctx.Stop)
dockerRegistryControllerOptions := serviceaccountcontrollers.DockerRegistryServiceControllerOptions{
DockercfgController: dockercfgController,
DockerURLsInitialized: dockerURLsInitialized,
}
go serviceaccountcontrollers.NewDockerRegistryServiceController(
ctx.ExternalKubeInformers.Core().V1().Secrets(),
ctx.ExternalKubeInformers.Core().V1().Services(),
kc,
dockerRegistryControllerOptions,
).Run(10, ctx.Stop)
return true, nil
}