Skip to content

Commit

Permalink
Merge pull request #48838 from mattmoyer/kubeadm-add-default-token-tt…
Browse files Browse the repository at this point in the history
…l-warning

Automatic merge from submit-queue (batch tested with PRs 48572, 48838, 48931, 48783, 47090)

kubeadm: add a warning about the default token TTL changing in 1.8

**What this PR does / why we need it**:
This adds a warning to `kubeadm init` and `kubeadm token create` if they are run without the `--token-ttl` / `--ttl` flags. In 1.7 and before, the tokens generated by these commands defaulted to an infinite TTL (no expiration) in 1.8, they will generate a token with a 24 hour TTL.

The actual default change is in #48783. This change is separate so we can cherry pick the warning into the `release-1.7` branch.

**Which issue this PR fixes**: ref kubernetes/kubeadm#343

**Special notes for your reviewer**:
This change is blocked on kubernetes/kubeadm#343. These warnings should probably be removed in the 1.9 cycle.

**Release note**:
```release-note
Add a runtime warning about the kubeadm default token TTL changes in 1.8.
```

/assign @luxas
  • Loading branch information
Kubernetes Submit Queue committed Jul 14, 2017
2 parents fd619b0 + 06bd22e commit c08a620
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/kubeadm/app/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func NewCmdInit(out io.Writer) *cobra.Command {
i, err := NewInit(cfgPath, internalcfg, skipPreFlight, skipTokenPrint)
kubeadmutil.CheckErr(err)
kubeadmutil.CheckErr(i.Validate(cmd))

// TODO: remove this warning in 1.9
if !cmd.Flags().Lookup("token-ttl").Changed {
fmt.Println("[kubeadm] WARNING: starting in 1.8, tokens expire after 24 hours by default (if you require a non-expiring token use --token-ttl 0)")
}

kubeadmutil.CheckErr(i.Run(out))
},
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/kubeadm/app/cmd/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func NewCmdToken(out io.Writer, errW io.Writer) *cobra.Command {
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile)
kubeadmutil.CheckErr(err)

// TODO: remove this warning in 1.9
if !tokenCmd.Flags().Lookup("ttl").Changed {
// sending this output to stderr s
fmt.Fprintln(errW, "[kubeadm] WARNING: starting in 1.8, tokens expire after 24 hours by default (if you require a non-expiring token use --ttl 0)")
}

err = RunCreateToken(out, client, token, tokenDuration, usages, description)
kubeadmutil.CheckErr(err)
},
Expand Down

0 comments on commit c08a620

Please sign in to comment.