-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate serviceaccount and rest of build controllers to new controlle…
…r initialization
- Loading branch information
Showing
12 changed files
with
623 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package controller | ||
|
||
import ( | ||
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" | ||
projectcontroller "github.com/openshift/origin/pkg/project/controller" | ||
) | ||
|
||
func RunOriginNamespaceController(ctx ControllerContext) (bool, error) { | ||
factory := projectcontroller.NamespaceControllerFactory{} | ||
factory.KubeClient = ctx.ClientBuilder.KubeInternalClientOrDie(bootstrappolicy.InfraOriginNamespaceServiceAccountName) | ||
go factory.Create().Run() | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package controller | ||
|
||
import ( | ||
"github.com/golang/glog" | ||
|
||
kapiv1 "k8s.io/kubernetes/pkg/api/v1" | ||
"k8s.io/kubernetes/pkg/controller" | ||
sacontroller "k8s.io/kubernetes/pkg/controller/serviceaccount" | ||
"k8s.io/kubernetes/pkg/serviceaccount" | ||
|
||
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" | ||
serviceaccountcontrollers "github.com/openshift/origin/pkg/serviceaccounts/controllers" | ||
) | ||
|
||
type ServiceAccountControllerOptions struct { | ||
ManagedNames []string | ||
} | ||
|
||
func (c *ServiceAccountControllerOptions) RunController(ctx ControllerContext) (bool, error) { | ||
if len(c.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 c.ManagedNames { | ||
sa := kapiv1.ServiceAccount{} | ||
sa.Name = saName | ||
|
||
options.ServiceAccounts = append(options.ServiceAccounts, sa) | ||
} | ||
|
||
go sacontroller.NewServiceAccountsController( | ||
ctx.DeprecatedOpenshiftInformers.KubernetesInformers().Core().V1().ServiceAccounts(), | ||
ctx.DeprecatedOpenshiftInformers.KubernetesInformers().Core().V1().Namespaces(), | ||
ctx.ClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceAccountControllerServiceAccountName), | ||
options).Run(3, ctx.Stop) | ||
|
||
return true, nil | ||
} | ||
|
||
type ServiceAccountTokensControllerOptions struct { | ||
RootCA []byte | ||
ServiceServingCA []byte | ||
PrivateKey interface{} | ||
|
||
RootClientBuilder controller.SimpleControllerClientBuilder | ||
} | ||
|
||
func (c *ServiceAccountTokensControllerOptions) RunController(ctx ControllerContext) (bool, error) { | ||
go sacontroller.NewTokensController( | ||
ctx.DeprecatedOpenshiftInformers.KubernetesInformers().Core().V1().ServiceAccounts(), | ||
ctx.DeprecatedOpenshiftInformers.KubernetesInformers().Core().V1().Secrets(), | ||
c.RootClientBuilder.ClientOrDie(bootstrappolicy.InfraServiceAccountTokensControllerServiceAccountName), | ||
sacontroller.TokensControllerOptions{ | ||
TokenGenerator: serviceaccount.JWTTokenGenerator(c.PrivateKey), | ||
RootCA: c.RootCA, | ||
ServiceServingCA: c.ServiceServingCA, | ||
}, | ||
).Run(int(ctx.KubeControllerContext.Options.ConcurrentSATokenSyncs), ctx.Stop) | ||
return true, nil | ||
} | ||
|
||
func RunServiceAccountPullSecretsController(ctx ControllerContext) (bool, error) { | ||
kc := ctx.ClientBuilder.KubeInternalClientOrDie(bootstrappolicy.InfraServiceAccountPullSecretsControllerServiceAccountName) | ||
|
||
serviceaccountcontrollers.NewDockercfgDeletedController(kc, serviceaccountcontrollers.DockercfgDeletedControllerOptions{}).Run() | ||
serviceaccountcontrollers.NewDockercfgTokenDeletedController(kc, serviceaccountcontrollers.DockercfgTokenDeletedControllerOptions{}).Run() | ||
|
||
dockerURLsIntialized := make(chan struct{}) | ||
dockercfgController := serviceaccountcontrollers.NewDockercfgController(kc, serviceaccountcontrollers.DockercfgControllerOptions{DockerURLsIntialized: dockerURLsIntialized}) | ||
go dockercfgController.Run(5, ctx.Stop) | ||
|
||
dockerRegistryControllerOptions := serviceaccountcontrollers.DockerRegistryServiceControllerOptions{ | ||
RegistryNamespace: "default", | ||
RegistryServiceName: "docker-registry", | ||
DockercfgController: dockercfgController, | ||
DockerURLsIntialized: dockerURLsIntialized, | ||
} | ||
go serviceaccountcontrollers.NewDockerRegistryServiceController(kc, dockerRegistryControllerOptions).Run(10, ctx.Stop) | ||
|
||
return true, nil | ||
} |
Oops, something went wrong.