-
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.
run kube controllers separately based on their command
- Loading branch information
Showing
4 changed files
with
131 additions
and
84 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,103 @@ | ||
package start | ||
|
||
import ( | ||
"github.com/golang/glog" | ||
|
||
kerrors "k8s.io/apimachinery/pkg/util/errors" | ||
controllerapp "k8s.io/kubernetes/cmd/kube-controller-manager/app" | ||
controlleroptions "k8s.io/kubernetes/cmd/kube-controller-manager/app/options" | ||
_ "k8s.io/kubernetes/plugin/pkg/scheduler/algorithmprovider" | ||
|
||
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" | ||
"k8s.io/kubernetes/pkg/api/v1" | ||
kapiv1 "k8s.io/kubernetes/pkg/api/v1" | ||
"k8s.io/kubernetes/pkg/volume" | ||
|
||
cmdflags "github.com/openshift/origin/pkg/cmd/util/flags" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
// newPersistentVolumeRecyclerPodTemplate provides a function which makes our recycler pod template for use in the kube-controller-manager | ||
// this is a stop-gap until the kube-controller-manager take a pod manifest | ||
func newPersistentVolumeRecyclerPodTemplate(recyclerImageName string) func() *v1.Pod { | ||
oldTemplateFunc := volume.NewPersistentVolumeRecyclerPodTemplate | ||
return func() *v1.Pod { | ||
uid := int64(0) | ||
defaultScrubPod := oldTemplateFunc() | ||
// TODO: Move the recycler pods to dedicated namespace instead of polluting openshift-infra. | ||
defaultScrubPod.Namespace = "openshift-infra" | ||
defaultScrubPod.Spec.ServiceAccountName = bootstrappolicy.InfraPersistentVolumeRecyclerControllerServiceAccountName | ||
defaultScrubPod.Spec.Containers[0].Image = recyclerImageName | ||
defaultScrubPod.Spec.Containers[0].Command = []string{"/usr/bin/openshift-recycle"} | ||
defaultScrubPod.Spec.Containers[0].Args = []string{"/scrub"} | ||
defaultScrubPod.Spec.Containers[0].SecurityContext = &kapiv1.SecurityContext{RunAsUser: &uid} | ||
defaultScrubPod.Spec.Containers[0].ImagePullPolicy = kapiv1.PullIfNotPresent | ||
|
||
return defaultScrubPod | ||
} | ||
} | ||
|
||
func kubeControllerManagerAddFlags(cmserver *controlleroptions.CMServer) func(flags *pflag.FlagSet) { | ||
return func(flags *pflag.FlagSet) { | ||
cmserver.AddFlags(flags, controllerapp.KnownControllers(), controllerapp.ControllersDisabledByDefault.List()) | ||
} | ||
} | ||
|
||
func newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile string, cmdLineArgs map[string][]string) (*controlleroptions.CMServer, error) { | ||
if cmdLineArgs == nil { | ||
cmdLineArgs = map[string][]string{} | ||
} | ||
|
||
if len(cmdLineArgs["controllers"]) == 0 { | ||
cmdLineArgs["controllers"] = []string{} | ||
} | ||
// these two are ones we disable in addition to others | ||
cmdLineArgs["controllers"] = []string{ | ||
// we don't appear to use this | ||
"-ttl", | ||
// we have to configure this separately until it is generic | ||
"-horizontalpodautoscaler", | ||
// we carry patches on this. For now.... | ||
"-serviceaccount-token", | ||
} | ||
if len(cmdLineArgs["use-service-account-credentials"]) == 0 { | ||
cmdLineArgs["use-service-account-credentials"] = []string{"true"} | ||
} | ||
if len(cmdLineArgs["service-account-private-key-file"]) == 0 { | ||
cmdLineArgs["service-account-private-key-file"] = []string{saPrivateKeyFile} | ||
} | ||
if len(cmdLineArgs["root-ca-file"]) == 0 { | ||
cmdLineArgs["root-ca-file"] = []string{saRootCAFile} | ||
} | ||
if len(cmdLineArgs["kubeconfig"]) == 0 { | ||
cmdLineArgs["kubeconfig"] = []string{kubeconfigFile} | ||
} | ||
|
||
// disable serving http since we didn't used to expose it | ||
if len(cmdLineArgs["port"]) == 0 { | ||
cmdLineArgs["port"] = []string{"-1"} | ||
} | ||
|
||
// resolve arguments | ||
controllerManager := controlleroptions.NewCMServer() | ||
if err := cmdflags.Resolve(cmdLineArgs, kubeControllerManagerAddFlags(controllerManager)); len(err) > 0 { | ||
return nil, kerrors.NewAggregate(err) | ||
} | ||
|
||
return controllerManager, nil | ||
} | ||
|
||
func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile string, cmdLineArgs map[string][]string, recyclerImage string) { | ||
volume.NewPersistentVolumeRecyclerPodTemplate = newPersistentVolumeRecyclerPodTemplate(recyclerImage) | ||
|
||
// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to. | ||
controllerManager, err := newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, cmdLineArgs) | ||
if err != nil { | ||
glog.Fatal(err) | ||
} | ||
// this does a second leader election, but doing the second leader election will allow us to move out process in | ||
// 3.8 if we so choose. | ||
if err := controllerapp.Run(controllerManager); err != nil { | ||
glog.Fatal(err) | ||
} | ||
} |
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
40 changes: 21 additions & 19 deletions
40
vendor/k8s.io/kubernetes/cmd/kube-controller-manager/app/controllermanager.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.