mirror of https://github.com/k3s-io/k3s
Merge pull request #1691 from ibuildthecloud/staticpod
Suppport static pods at ${datadir}/agent/staticpodspull/1753/head
commit
70ddc799bd
|
@ -29,6 +29,10 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/net"
|
"k8s.io/apimachinery/pkg/util/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultPodManifestPath = "pod-manifests"
|
||||||
|
)
|
||||||
|
|
||||||
func Get(ctx context.Context, agent cmds.Agent) *config.Node {
|
func Get(ctx context.Context, agent cmds.Agent) *config.Node {
|
||||||
for {
|
for {
|
||||||
agentConfig, err := get(&agent)
|
agentConfig, err := get(&agent)
|
||||||
|
@ -476,6 +480,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||||
nodeConfig.AgentConfig.DisableNPC = controlConfig.DisableNPC
|
nodeConfig.AgentConfig.DisableNPC = controlConfig.DisableNPC
|
||||||
nodeConfig.AgentConfig.DisableKubeProxy = controlConfig.DisableKubeProxy
|
nodeConfig.AgentConfig.DisableKubeProxy = controlConfig.DisableKubeProxy
|
||||||
nodeConfig.AgentConfig.Rootless = envInfo.Rootless
|
nodeConfig.AgentConfig.Rootless = envInfo.Rootless
|
||||||
|
nodeConfig.AgentConfig.PodManifests = filepath.Join(envInfo.DataDir, DefaultPodManifestPath)
|
||||||
nodeConfig.DisableSELinux = envInfo.DisableSELinux
|
nodeConfig.DisableSELinux = envInfo.DisableSELinux
|
||||||
|
|
||||||
return nodeConfig, nil
|
return nodeConfig, nil
|
||||||
|
|
|
@ -75,6 +75,12 @@ func startKubelet(cfg *config.Agent) {
|
||||||
"anonymous-auth": "false",
|
"anonymous-auth": "false",
|
||||||
"authorization-mode": modes.ModeWebhook,
|
"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 != "" {
|
if cfg.RootDir != "" {
|
||||||
argsMap["root-dir"] = cfg.RootDir
|
argsMap["root-dir"] = cfg.RootDir
|
||||||
argsMap["cert-dir"] = filepath.Join(cfg.RootDir, "pki")
|
argsMap["cert-dir"] = filepath.Join(cfg.RootDir, "pki")
|
||||||
|
|
|
@ -49,6 +49,7 @@ type Containerd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Agent struct {
|
type Agent struct {
|
||||||
|
PodManifests string
|
||||||
NodeName string
|
NodeName string
|
||||||
NodeConfigPath string
|
NodeConfigPath string
|
||||||
ServingKubeletCert string
|
ServingKubeletCert string
|
||||||
|
|
Loading…
Reference in New Issue