| ... | ... |
@@ -111,6 +111,10 @@ func GetNodeFileReferences(config *NodeConfig) []*string {
|
| 111 | 111 |
|
| 112 | 112 |
refs = append(refs, &config.VolumeDirectory) |
| 113 | 113 |
|
| 114 |
+ if config.PodManifestConfig != nil {
|
|
| 115 |
+ refs = append(refs, &config.PodManifestConfig.Path) |
|
| 116 |
+ } |
|
| 117 |
+ |
|
| 114 | 118 |
return refs |
| 115 | 119 |
} |
| 116 | 120 |
|
| ... | ... |
@@ -36,6 +36,10 @@ type NodeConfig struct {
|
| 36 | 36 |
|
| 37 | 37 |
// AllowDisabledDocker if true, the Kubelet will ignore errors from Docker. This means that a node can start on a machine that doesn't have docker started. |
| 38 | 38 |
AllowDisabledDocker bool |
| 39 |
+ |
|
| 40 |
+ // PodManifestConfig holds the configuration for enabling the Kubelet to |
|
| 41 |
+ // create pods based from a manifest file(s) placed locally on the node |
|
| 42 |
+ PodManifestConfig *PodManifestConfig |
|
| 39 | 43 |
} |
| 40 | 44 |
|
| 41 | 45 |
type MasterConfig struct {
|
| ... | ... |
@@ -382,3 +386,13 @@ type CertInfo struct {
|
| 382 | 382 |
// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile |
| 383 | 383 |
KeyFile string |
| 384 | 384 |
} |
| 385 |
+ |
|
| 386 |
+type PodManifestConfig struct {
|
|
| 387 |
+ // Path specifies the path for the pod manifest file or directory |
|
| 388 |
+ // If its a directory, its expected to contain on or more manifest files |
|
| 389 |
+ // This is used by the Kubelet to create pods on the node |
|
| 390 |
+ Path string |
|
| 391 |
+ // FileCheckIntervalSeconds is the interval in seconds for checking the manifest file(s) for new data |
|
| 392 |
+ // The interval needs to be a positive value |
|
| 393 |
+ FileCheckIntervalSeconds int64 |
|
| 394 |
+} |
| ... | ... |
@@ -35,6 +35,10 @@ type NodeConfig struct {
|
| 35 | 35 |
|
| 36 | 36 |
// AllowDisabledDocker if true, the Kubelet will ignore errors from Docker. This means that a node can start on a machine that doesn't have docker started. |
| 37 | 37 |
AllowDisabledDocker bool `json:"allowDisabledDocker"` |
| 38 |
+ |
|
| 39 |
+ // PodManifestConfig holds the configuration for enabling the Kubelet to |
|
| 40 |
+ // create pods based from a manifest file(s) placed locally on the node |
|
| 41 |
+ PodManifestConfig *PodManifestConfig `json:"podManifestConfig"` |
|
| 38 | 42 |
} |
| 39 | 43 |
|
| 40 | 44 |
type MasterConfig struct {
|
| ... | ... |
@@ -365,3 +369,13 @@ type CertInfo struct {
|
| 365 | 365 |
CertFile string `json:"certFile"` |
| 366 | 366 |
KeyFile string `json:"keyFile"` |
| 367 | 367 |
} |
| 368 |
+ |
|
| 369 |
+type PodManifestConfig struct {
|
|
| 370 |
+ // Path specifies the path for the pod manifest file or directory |
|
| 371 |
+ // If its a directory, its expected to contain on or more manifest files |
|
| 372 |
+ // This is used by the Kubelet to create pods on the node |
|
| 373 |
+ Path string `json:"path"` |
|
| 374 |
+ // FileCheckIntervalSeconds is the interval in seconds for checking the manifest file(s) for new data |
|
| 375 |
+ // The interval needs to be a positive value |
|
| 376 |
+ FileCheckIntervalSeconds int64 `json:"fileCheckIntervalSeconds"` |
|
| 377 |
+} |
| ... | ... |
@@ -22,5 +22,9 @@ func ValidateNodeConfig(config *api.NodeConfig) fielderrors.ValidationErrorList |
| 22 | 22 |
|
| 23 | 23 |
allErrs = append(allErrs, ValidateImageConfig(config.ImageConfig).Prefix("imageConfig")...)
|
| 24 | 24 |
|
| 25 |
+ if config.PodManifestConfig != nil {
|
|
| 26 |
+ allErrs = append(allErrs, ValidatePodManifestConfig(config.PodManifestConfig).Prefix("podManifestConfig")...)
|
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 25 | 29 |
return allErrs |
| 26 | 30 |
} |
| ... | ... |
@@ -93,6 +93,18 @@ func ValidateRemoteConnectionInfo(remoteConnectionInfo api.RemoteConnectionInfo) |
| 93 | 93 |
return allErrs |
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 |
+func ValidatePodManifestConfig(podManifestConfig *api.PodManifestConfig) fielderrors.ValidationErrorList {
|
|
| 97 |
+ allErrs := fielderrors.ValidationErrorList{}
|
|
| 98 |
+ |
|
| 99 |
+ // the Path can be a file or a directory |
|
| 100 |
+ allErrs = append(allErrs, ValidateFile(podManifestConfig.Path, "path")...) |
|
| 101 |
+ if podManifestConfig.FileCheckIntervalSeconds < 1 {
|
|
| 102 |
+ allErrs = append(allErrs, fielderrors.NewFieldInvalid("fileCheckIntervalSeconds", podManifestConfig.FileCheckIntervalSeconds, "interval has to be positive"))
|
|
| 103 |
+ } |
|
| 104 |
+ |
|
| 105 |
+ return allErrs |
|
| 106 |
+} |
|
| 107 |
+ |
|
| 96 | 108 |
func ValidateSpecifiedIP(ipString string, field string) fielderrors.ValidationErrorList {
|
| 97 | 109 |
allErrs := fielderrors.ValidationErrorList{}
|
| 98 | 110 |
|
| ... | ... |
@@ -126,7 +126,20 @@ func (c *NodeConfig) RunKubelet() {
|
| 126 | 126 |
recorder := record.NewBroadcaster().NewRecorder(kapi.EventSource{Component: "kubelet", Host: c.NodeHost})
|
| 127 | 127 |
|
| 128 | 128 |
cfg := kconfig.NewPodConfig(kconfig.PodConfigNotificationSnapshotAndUpdates, recorder) |
| 129 |
- kconfig.NewSourceApiserver(c.Client, c.NodeHost, cfg.Channel("api"))
|
|
| 129 |
+ kconfig.NewSourceApiserver(c.Client, c.NodeHost, cfg.Channel(kubelet.ApiserverSource)) |
|
| 130 |
+ // define manifest file source for pods, if specified |
|
| 131 |
+ if len(c.PodManifestPath) > 0 {
|
|
| 132 |
+ _, err = os.Stat(c.PodManifestPath) |
|
| 133 |
+ if err == nil {
|
|
| 134 |
+ glog.Infof("Adding pod manifest file/dir: %v", c.PodManifestPath)
|
|
| 135 |
+ kconfig.NewSourceFile(c.PodManifestPath, c.NodeHost, |
|
| 136 |
+ time.Duration(c.PodManifestCheckIntervalSeconds)*time.Second, |
|
| 137 |
+ cfg.Channel(kubelet.FileSource)) |
|
| 138 |
+ } else {
|
|
| 139 |
+ glog.Errorf("WARNING: PodManifestPath specified is not a valid file/directory: %v", err)
|
|
| 140 |
+ } |
|
| 141 |
+ } |
|
| 142 |
+ |
|
| 130 | 143 |
gcPolicy := kubelet.ContainerGCPolicy{
|
| 131 | 144 |
MinAge: 10 * time.Second, |
| 132 | 145 |
MaxPerPodContainer: 5, |
| ... | ... |
@@ -54,6 +54,14 @@ type NodeConfig struct {
|
| 54 | 54 |
Client *client.Client |
| 55 | 55 |
// A client to connect to Docker |
| 56 | 56 |
DockerClient dockertools.DockerInterface |
| 57 |
+ |
|
| 58 |
+ // PodManifestPath specifies the path for the pod manifest file(s) |
|
| 59 |
+ // The path could point to a single file or a directory that contains multiple manifest files |
|
| 60 |
+ // This is used by the Kubelet to create pods on the node |
|
| 61 |
+ PodManifestPath string |
|
| 62 |
+ // PodManifestCheckIntervalSeconds is the interval in seconds for checking the manifest file(s) for new data |
|
| 63 |
+ // The interval needs to be a positive value |
|
| 64 |
+ PodManifestCheckIntervalSeconds int64 |
|
| 57 | 65 |
} |
| 58 | 66 |
|
| 59 | 67 |
func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error) {
|
| ... | ... |
@@ -83,6 +91,13 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error |
| 83 | 83 |
imageTemplate.Format = options.ImageConfig.Format |
| 84 | 84 |
imageTemplate.Latest = options.ImageConfig.Latest |
| 85 | 85 |
|
| 86 |
+ var path string |
|
| 87 |
+ var fileCheckInterval int64 |
|
| 88 |
+ if options.PodManifestConfig != nil {
|
|
| 89 |
+ path = options.PodManifestConfig.Path |
|
| 90 |
+ fileCheckInterval = options.PodManifestConfig.FileCheckIntervalSeconds |
|
| 91 |
+ } |
|
| 92 |
+ |
|
| 86 | 93 |
config := &NodeConfig{
|
| 87 | 94 |
NodeHost: options.NodeName, |
| 88 | 95 |
BindAddress: options.ServingInfo.BindAddress, |
| ... | ... |
@@ -101,6 +116,9 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error |
| 101 | 101 |
ImageFor: imageTemplate.ExpandOrDie, |
| 102 | 102 |
AllowDisabledDocker: options.AllowDisabledDocker, |
| 103 | 103 |
Client: kubeClient, |
| 104 |
+ |
|
| 105 |
+ PodManifestPath: path, |
|
| 106 |
+ PodManifestCheckIntervalSeconds: fileCheckInterval, |
|
| 104 | 107 |
} |
| 105 | 108 |
|
| 106 | 109 |
return config, nil |
| ... | ... |
@@ -114,6 +114,8 @@ func (args NodeArgs) BuildSerializeableNodeConfig() (*configapi.NodeConfig, erro |
| 114 | 114 |
DNSIP: dnsIP, |
| 115 | 115 |
|
| 116 | 116 |
MasterKubeConfig: admin.DefaultNodeKubeConfigFile(args.CertArgs.CertDir, args.NodeName), |
| 117 |
+ |
|
| 118 |
+ PodManifestConfig: nil, |
|
| 117 | 119 |
} |
| 118 | 120 |
|
| 119 | 121 |
if args.ListenArg.UseTLS() {
|