mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #54133 from shun-miyoshi-com/add_output_option
Automatic merge from submit-queue (batch tested with PRs 55594, 47849, 54692, 55478, 54133). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. add kubeadm alpha phase kubeconfig option(--output) **What this PR does / why we need it**: This PR will add --output option to `kubeadm alpha phase kubeconfig [command]` This option can change output directory of kubeconfig. Prev: kubeadm alpha phase kubeconfig admin we can get admin.conf in /etc/kubernetes/ . This PR: kubeadm alpha phase kubeconfig admin --output /root we can get admin.conf in /root/ . Of course, --output is optional.(default directory is /etc/kubernetes) Note) I have no confidence about my test code. Thank you. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note ```
This commit is contained in:
commit
81fa823a6c
@ -124,6 +124,7 @@ func getKubeConfigSubCommands(out io.Writer, outDir, defaultKubernetesVersion st
|
||||
cmd.Flags().StringVar(&cfg.CertificatesDir, "cert-dir", cfg.CertificatesDir, "The path where certificates are stored.")
|
||||
cmd.Flags().StringVar(&cfg.API.AdvertiseAddress, "apiserver-advertise-address", cfg.API.AdvertiseAddress, "The IP address or DNS name the API Server is accessible on.")
|
||||
cmd.Flags().Int32Var(&cfg.API.BindPort, "apiserver-bind-port", cfg.API.BindPort, "The port the API Server is accessible on.")
|
||||
cmd.Flags().StringVar(&outDir, "kubeconfig-dir", outDir, "The path where to save and store the kubeconfig file.")
|
||||
if properties.use == "all" || properties.use == "kubelet" {
|
||||
cmd.Flags().StringVar(&cfg.NodeName, "node-name", cfg.NodeName, `The node name that the kubelet client cert should use.`)
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ func TestKubeConfigCSubCommandsHasFlags(t *testing.T) {
|
||||
"cert-dir",
|
||||
"apiserver-advertise-address",
|
||||
"apiserver-bind-port",
|
||||
"kubeconfig-dir",
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
@ -167,6 +168,8 @@ func TestKubeConfigSubCommandsThatCreateFilesWithFlags(t *testing.T) {
|
||||
// Adds a pki folder with a ca certs to the temp folder
|
||||
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
|
||||
|
||||
outputdir := tmpdir
|
||||
|
||||
// Retrives ca cert for assertions
|
||||
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(pkidir, kubeadmconstants.CACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
@ -178,7 +181,9 @@ func TestKubeConfigSubCommandsThatCreateFilesWithFlags(t *testing.T) {
|
||||
|
||||
// Execute the subcommand
|
||||
certDirFlag := fmt.Sprintf("--cert-dir=%s", pkidir)
|
||||
outputDirFlag := fmt.Sprintf("--kubeconfig-dir=%s", outputdir)
|
||||
allFlags := append(commonFlags, certDirFlag)
|
||||
allFlags = append(allFlags, outputDirFlag)
|
||||
allFlags = append(allFlags, test.additionalFlags...)
|
||||
cmdtestutil.RunSubCommand(t, subCmds, test.command, allFlags...)
|
||||
|
||||
@ -320,6 +325,8 @@ func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
||||
// Adds a pki folder with a ca cert to the temp folder
|
||||
pkidir := testutil.SetupPkiDirWithCertificateAuthorithy(t, tmpdir)
|
||||
|
||||
outputdir := tmpdir
|
||||
|
||||
// Retrives ca cert for assertions
|
||||
caCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(pkidir, kubeadmconstants.CACertAndKeyBaseName)
|
||||
if err != nil {
|
||||
@ -331,6 +338,7 @@ func TestKubeConfigSubCommandsThatWritesToOut(t *testing.T) {
|
||||
"--apiserver-bind-port=1234",
|
||||
"--client-name=myUser",
|
||||
fmt.Sprintf("--cert-dir=%s", pkidir),
|
||||
fmt.Sprintf("--kubeconfig-dir=%s", outputdir),
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
|
Loading…
Reference in New Issue
Block a user