mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #1080 from erikwilson/fix-agent-token-env
Fix broken K3S_TOKEN env
This commit is contained in:
commit
39c0224f0e
@ -31,6 +31,10 @@ func Run(ctx *cli.Context) error {
|
||||
cmds.AgentConfig.Token = token
|
||||
}
|
||||
|
||||
if cmds.AgentConfig.Token == "" && cmds.AgentConfig.ClusterSecret != "" {
|
||||
cmds.AgentConfig.Token = cmds.AgentConfig.ClusterSecret
|
||||
}
|
||||
|
||||
if cmds.AgentConfig.Token == "" {
|
||||
return fmt.Errorf("--token is required")
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
type Agent struct {
|
||||
Token string
|
||||
TokenFile string
|
||||
ClusterSecret string
|
||||
ServerURL string
|
||||
DisableLoadBalancer bool
|
||||
ResolvConf string
|
||||
@ -189,7 +190,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
|
||||
cli.StringFlag{
|
||||
Name: "cluster-secret",
|
||||
Usage: "(deprecated) use --token",
|
||||
Destination: &AgentConfig.Token,
|
||||
Destination: &AgentConfig.ClusterSecret,
|
||||
EnvVar: "K3S_CLUSTER_SECRET",
|
||||
},
|
||||
},
|
||||
|
@ -12,6 +12,7 @@ type Server struct {
|
||||
AgentTokenFile string
|
||||
Token string
|
||||
TokenFile string
|
||||
ClusterSecret string
|
||||
ServiceCIDR string
|
||||
ClusterDNS string
|
||||
ClusterDomain string
|
||||
@ -121,7 +122,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
Name: "token,t",
|
||||
Usage: "(cluster) Shared secret used to join a server or agent to a cluster",
|
||||
Destination: &ServerConfig.Token,
|
||||
EnvVar: "K3S_CLUSTER_SECRET,K3S_TOKEN",
|
||||
EnvVar: "K3S_TOKEN",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "token-file",
|
||||
@ -231,7 +232,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
},
|
||||
cli.StringFlag{
|
||||
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,
|
||||
EnvVar: "K3S_AGENT_TOKEN",
|
||||
},
|
||||
@ -268,7 +269,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
cli.StringFlag{
|
||||
Name: "cluster-secret",
|
||||
Usage: "(deprecated) use --token",
|
||||
Destination: &ServerConfig.Token,
|
||||
Destination: &ServerConfig.ClusterSecret,
|
||||
EnvVar: "K3S_CLUSTER_SECRET",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
|
@ -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.DisableAgent = cfg.DisableAgent
|
||||
serverConfig.ControlConfig.Token = cfg.Token
|
||||
|
Loading…
Reference in New Issue
Block a user