Commit 95ff805c authored by Erik Wilson's avatar Erik Wilson

Fix broken K3S_TOKEN env

parent 35715bd9
...@@ -31,6 +31,10 @@ func Run(ctx *cli.Context) error { ...@@ -31,6 +31,10 @@ func Run(ctx *cli.Context) error {
cmds.AgentConfig.Token = token cmds.AgentConfig.Token = token
} }
if cmds.AgentConfig.Token == "" && cmds.AgentConfig.ClusterSecret != "" {
cmds.AgentConfig.Token = cmds.AgentConfig.ClusterSecret
}
if cmds.AgentConfig.Token == "" { if cmds.AgentConfig.Token == "" {
return fmt.Errorf("--token is required") return fmt.Errorf("--token is required")
} }
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
type Agent struct { type Agent struct {
Token string Token string
TokenFile string TokenFile string
ClusterSecret string
ServerURL string ServerURL string
DisableLoadBalancer bool DisableLoadBalancer bool
ResolvConf string ResolvConf string
...@@ -189,7 +190,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command { ...@@ -189,7 +190,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
cli.StringFlag{ cli.StringFlag{
Name: "cluster-secret", Name: "cluster-secret",
Usage: "(deprecated) use --token", Usage: "(deprecated) use --token",
Destination: &AgentConfig.Token, Destination: &AgentConfig.ClusterSecret,
EnvVar: "K3S_CLUSTER_SECRET", EnvVar: "K3S_CLUSTER_SECRET",
}, },
}, },
......
...@@ -12,6 +12,7 @@ type Server struct { ...@@ -12,6 +12,7 @@ type Server struct {
AgentTokenFile string AgentTokenFile string
Token string Token string
TokenFile string TokenFile string
ClusterSecret string
ServiceCIDR string ServiceCIDR string
ClusterDNS string ClusterDNS string
ClusterDomain string ClusterDomain string
...@@ -121,7 +122,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { ...@@ -121,7 +122,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
Name: "token,t", Name: "token,t",
Usage: "(cluster) Shared secret used to join a server or agent to a cluster", Usage: "(cluster) Shared secret used to join a server or agent to a cluster",
Destination: &ServerConfig.Token, Destination: &ServerConfig.Token,
EnvVar: "K3S_CLUSTER_SECRET,K3S_TOKEN", EnvVar: "K3S_TOKEN",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "token-file", Name: "token-file",
...@@ -231,7 +232,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { ...@@ -231,7 +232,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
}, },
cli.StringFlag{ cli.StringFlag{
Name: "agent-token", Name: "agent-token",
Usage: "(experimental/cluster) Shared secret used to join agents to the cluster, but not agents", Usage: "(experimental/cluster) Shared secret used to join agents to the cluster, but not servers",
Destination: &ServerConfig.AgentToken, Destination: &ServerConfig.AgentToken,
EnvVar: "K3S_AGENT_TOKEN", EnvVar: "K3S_AGENT_TOKEN",
}, },
...@@ -268,7 +269,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { ...@@ -268,7 +269,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
cli.StringFlag{ cli.StringFlag{
Name: "cluster-secret", Name: "cluster-secret",
Usage: "(deprecated) use --token", Usage: "(deprecated) use --token",
Destination: &ServerConfig.Token, Destination: &ServerConfig.ClusterSecret,
EnvVar: "K3S_CLUSTER_SECRET", EnvVar: "K3S_CLUSTER_SECRET",
}, },
cli.BoolFlag{ cli.BoolFlag{
......
...@@ -55,6 +55,10 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -55,6 +55,10 @@ func run(app *cli.Context, cfg *cmds.Server) error {
} }
} }
if cfg.Token == "" && cfg.ClusterSecret != "" {
cfg.Token = cfg.ClusterSecret
}
serverConfig := server.Config{} serverConfig := server.Config{}
serverConfig.DisableAgent = cfg.DisableAgent serverConfig.DisableAgent = cfg.DisableAgent
serverConfig.ControlConfig.Token = cfg.Token serverConfig.ControlConfig.Token = cfg.Token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment