Add flag to control probing pods statuses from kubelets.

This commit is contained in:
Filip Grzadkowski 2015-02-25 14:33:08 +01:00
parent 6c5b390160
commit 86b1c90097
3 changed files with 11 additions and 1 deletions

View File

@ -183,6 +183,7 @@ func startComponents(manifestURL string) (apiServerURL string) {
ReadOnlyPort: portNumber, ReadOnlyPort: portNumber,
PublicAddress: publicAddress, PublicAddress: publicAddress,
CacheTimeout: 2 * time.Second, CacheTimeout: 2 * time.Second,
SyncPodStatus: true,
}) })
handler.delegate = m.Handler handler.delegate = m.Handler

View File

@ -73,6 +73,7 @@ type APIServer struct {
RuntimeConfig util.ConfigurationMap RuntimeConfig util.ConfigurationMap
KubeletConfig client.KubeletConfig KubeletConfig client.KubeletConfig
ClusterName string ClusterName string
SyncPodStatus bool
} }
// NewAPIServer creates a new APIServer object with default parameters // NewAPIServer creates a new APIServer object with default parameters
@ -92,6 +93,7 @@ func NewAPIServer() *APIServer {
EnableLogsSupport: true, EnableLogsSupport: true,
MasterServiceNamespace: api.NamespaceDefault, MasterServiceNamespace: api.NamespaceDefault,
ClusterName: "kubernetes", ClusterName: "kubernetes",
SyncPodStatus: true,
RuntimeConfig: make(util.ConfigurationMap), RuntimeConfig: make(util.ConfigurationMap),
KubeletConfig: client.KubeletConfig{ KubeletConfig: client.KubeletConfig{
@ -146,6 +148,7 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
fs.BoolVar(&s.AllowPrivileged, "allow_privileged", s.AllowPrivileged, "If true, allow privileged containers.") fs.BoolVar(&s.AllowPrivileged, "allow_privileged", s.AllowPrivileged, "If true, allow privileged containers.")
fs.Var(&s.PortalNet, "portal_net", "A CIDR notation IP range from which to assign portal IPs. This must not overlap with any IP ranges assigned to nodes for pods.") fs.Var(&s.PortalNet, "portal_net", "A CIDR notation IP range from which to assign portal IPs. This must not overlap with any IP ranges assigned to nodes for pods.")
fs.StringVar(&s.MasterServiceNamespace, "master_service_namespace", s.MasterServiceNamespace, "The namespace from which the kubernetes master services should be injected into pods") fs.StringVar(&s.MasterServiceNamespace, "master_service_namespace", s.MasterServiceNamespace, "The namespace from which the kubernetes master services should be injected into pods")
fs.BoolVar(&s.SyncPodStatus, "sync_pod_status", s.SyncPodStatus, "If true, periodically fetch pods statuses from kubelets.")
fs.Var(&s.RuntimeConfig, "runtime_config", "A set of key=value pairs that describe runtime configuration that may be passed to the apiserver.") fs.Var(&s.RuntimeConfig, "runtime_config", "A set of key=value pairs that describe runtime configuration that may be passed to the apiserver.")
client.BindKubeletClientConfigFlags(fs, &s.KubeletConfig) client.BindKubeletClientConfigFlags(fs, &s.KubeletConfig)
fs.StringVar(&s.ClusterName, "cluster_name", s.ClusterName, "The instance prefix for the cluster") fs.StringVar(&s.ClusterName, "cluster_name", s.ClusterName, "The instance prefix for the cluster")
@ -245,6 +248,7 @@ func (s *APIServer) Run(_ []string) error {
EnableV1Beta3: v1beta3, EnableV1Beta3: v1beta3,
MasterServiceNamespace: s.MasterServiceNamespace, MasterServiceNamespace: s.MasterServiceNamespace,
ClusterName: s.ClusterName, ClusterName: s.ClusterName,
SyncPodStatus: s.SyncPodStatus,
} }
m := master.New(config) m := master.New(config)

View File

@ -115,6 +115,9 @@ type Config struct {
// The name of the cluster. // The name of the cluster.
ClusterName string ClusterName string
// If true we will periodically probe pods statuses.
SyncPodStatus bool
} }
// Master contains state for a Kubernetes cluster master/api server. // Master contains state for a Kubernetes cluster master/api server.
@ -393,7 +396,9 @@ func (m *Master) init(c *Config) {
nodeStorageClient.Nodes(), nodeStorageClient.Nodes(),
podRegistry, podRegistry,
) )
if c.SyncPodStatus {
go util.Forever(func() { podCache.UpdateAllContainers() }, m.cacheTimeout) go util.Forever(func() { podCache.UpdateAllContainers() }, m.cacheTimeout)
}
go util.Forever(func() { podCache.GarbageCollectPodStatus() }, time.Minute*30) go util.Forever(func() { podCache.GarbageCollectPodStatus() }, time.Minute*30)
// TODO: refactor podCache to sit on top of podStorage via status calls // TODO: refactor podCache to sit on top of podStorage via status calls