From 8c7fbe3dde0599dfe5db28b72c83c67c5185cb5f Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 27 Apr 2020 09:41:57 -0700 Subject: [PATCH] Suppport static pods at ${datadir}/agent/pod-manifests --- pkg/agent/config/config.go | 5 +++++ pkg/daemons/agent/agent.go | 6 ++++++ pkg/daemons/config/types.go | 1 + 3 files changed, 12 insertions(+) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index 52aa894cbc..84880576c6 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -29,6 +29,10 @@ import ( "k8s.io/apimachinery/pkg/util/net" ) +const ( + DefaultPodManifestPath = "pod-manifests" +) + func Get(ctx context.Context, agent cmds.Agent) *config.Node { for { agentConfig, err := get(&agent) @@ -475,6 +479,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { nodeConfig.AgentConfig.DisableCCM = controlConfig.DisableCCM nodeConfig.AgentConfig.DisableNPC = controlConfig.DisableNPC nodeConfig.AgentConfig.Rootless = envInfo.Rootless + nodeConfig.AgentConfig.PodManifests = filepath.Join(envInfo.DataDir, DefaultPodManifestPath) nodeConfig.DisableSELinux = envInfo.DisableSELinux return nodeConfig, nil diff --git a/pkg/daemons/agent/agent.go b/pkg/daemons/agent/agent.go index 1344c5224d..34349a50b3 100644 --- a/pkg/daemons/agent/agent.go +++ b/pkg/daemons/agent/agent.go @@ -70,6 +70,12 @@ func startKubelet(cfg *config.Agent) { "anonymous-auth": "false", "authorization-mode": modes.ModeWebhook, } + if cfg.PodManifests != "" && argsMap["pod-manifest-path"] == "" { + argsMap["pod-manifest-path"] = cfg.PodManifests + } + if err := os.MkdirAll(argsMap["pod-manifest-path"], 0755); err != nil { + logrus.Errorf("Failed to mkdir %s: %v", argsMap["pod-manifest-path"], err) + } if cfg.RootDir != "" { argsMap["root-dir"] = cfg.RootDir argsMap["cert-dir"] = filepath.Join(cfg.RootDir, "pki") diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index 696b5acc19..06942d76fe 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -49,6 +49,7 @@ type Containerd struct { } type Agent struct { + PodManifests string NodeName string NodeConfigPath string ServingKubeletCert string