You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/stackit_ske_kubeconfig_create.md
+13-7Lines changed: 13 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,16 @@
1
1
## stackit ske kubeconfig create
2
2
3
-
Creates a kubeconfig for an SKE cluster
3
+
Creates or update a kubeconfig for an SKE cluster
4
4
5
5
### Synopsis
6
6
7
-
Creates a kubeconfig for a STACKIT Kubernetes Engine (SKE) cluster.
7
+
Creates a kubeconfig for a STACKIT Kubernetes Engine (SKE) cluster, if the config exits in the kubeconfig file the information will be updated.
8
8
9
-
By default the kubeconfig is created in the .kube folder, in the user's home directory. The kubeconfig file will be overwritten if it already exists.
9
+
By default, the kubeconfig information of the SKE cluster is merged into the default kubeconfig file of the current user. If the kubeconfig file doesn't exist, a new one will be created.
10
10
You can override this behavior by specifying a custom filepath with the --filepath flag.
11
+
11
12
An expiration time can be set for the kubeconfig. The expiration time is set in seconds(s), minutes(m), hours(h), days(d) or months(M). Default is 1h.
13
+
12
14
Note that the format is <value><unit>, e.g. 30d for 30 days and you can't combine units.
Create a kubeconfig for the SKE cluster with name "my-cluster"
23
+
Create or update a kubeconfig for the SKE cluster with name "my-cluster. If the config exits in the kubeconfig file the information will be updated."
22
24
$ stackit ske kubeconfig create my-cluster
23
25
24
26
Get a login kubeconfig for the SKE cluster with name "my-cluster". This kubeconfig does not contain any credentials and instead obtains valid credentials via the `stackit ske kubeconfig login` command.
Create a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 30 days
29
+
Create a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 30 days. If the config exits in the kubeconfig file the information will be updated.
Create a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 2 months
32
+
Create or update a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 2 months. If the config exits in the kubeconfig file the information will be updated.
Create a kubeconfig for the SKE cluster with name "my-cluster" in a custom filepath
35
+
Create or update a kubeconfig for the SKE cluster with name "my-cluster" in a custom filepath. If the config exits in the kubeconfig file the information will be updated.
--filepath string Path to create the kubeconfig file. By default, the kubeconfig is created as 'config' in the .kube folder, in the user's home directory.
46
51
-h, --help Help for "stackit ske kubeconfig create"
47
52
-l, --login Create a login kubeconfig that obtains valid credentials via the STACKIT CLI. This flag is mutually exclusive with the expiration flag.
Copy file name to clipboardExpand all lines: internal/cmd/ske/kubeconfig/create/create.go
+38-22Lines changed: 38 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -22,52 +22,57 @@ import (
22
22
const (
23
23
clusterNameArg="CLUSTER_NAME"
24
24
25
-
loginFlag="login"
25
+
disableWritingFlag="disable-writing"
26
26
expirationFlag="expiration"
27
27
filepathFlag="filepath"
28
-
disableWritingFlag="disable-writing"
28
+
loginFlag="login"
29
+
overwriteFlag="overwrite"
29
30
)
30
31
31
32
typeinputModelstruct {
32
33
*globalflags.GlobalFlagModel
33
34
ClusterNamestring
34
-
Filepath*string
35
+
DisableWritingbool
35
36
ExpirationTime*string
37
+
Filepath*string
36
38
Loginbool
37
-
DisableWritingbool
39
+
Overwritebool
38
40
}
39
41
40
42
funcNewCmd(p*print.Printer) *cobra.Command {
41
43
cmd:=&cobra.Command{
42
44
Use: fmt.Sprintf("create %s", clusterNameArg),
43
-
Short: "Creates a kubeconfig for an SKE cluster",
45
+
Short: "Creates or update a kubeconfig for an SKE cluster",
44
46
Long: fmt.Sprintf("%s\n\n%s\n%s\n%s\n%s",
45
-
"Creates a kubeconfig for a STACKIT Kubernetes Engine (SKE) cluster.",
46
-
"By default the kubeconfig is created in the .kube folder, in the user's home directory. The kubeconfig file will be overwritten if it already exists.",
47
-
"You can override this behavior by specifying a custom filepath with the --filepath flag.",
48
-
"An expiration time can be set for the kubeconfig. The expiration time is set in seconds(s), minutes(m), hours(h), days(d) or months(M). Default is 1h.",
47
+
"Creates a kubeconfig for a STACKIT Kubernetes Engine (SKE) cluster, if the config exits in the kubeconfig file the information will be updated.",
48
+
"By default, the kubeconfig information of the SKE cluster is merged into the default kubeconfig file of the current user. If the kubeconfig file doesn't exist, a new one will be created.",
49
+
"You can override this behavior by specifying a custom filepath with the --filepath flag.\n",
50
+
"An expiration time can be set for the kubeconfig. The expiration time is set in seconds(s), minutes(m), hours(h), days(d) or months(M). Default is 1h.\n",
49
51
"Note that the format is <value><unit>, e.g. 30d for 30 days and you can't combine units."),
50
52
Args: args.SingleArg(clusterNameArg, nil),
51
53
Example: examples.Build(
52
54
examples.NewExample(
53
-
`Create a kubeconfig for the SKE cluster with name "my-cluster"`,
55
+
`Create or update a kubeconfig for the SKE cluster with name "my-cluster. If the config exits in the kubeconfig file the information will be updated."`,
54
56
"$ stackit ske kubeconfig create my-cluster"),
55
57
examples.NewExample(
56
58
`Get a login kubeconfig for the SKE cluster with name "my-cluster". `+
57
59
"This kubeconfig does not contain any credentials and instead obtains valid credentials via the `stackit ske kubeconfig login` command.",
`Create a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 30 days`,
62
+
`Create a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 30 days. If the config exits in the kubeconfig file the information will be updated.`,
`Create a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 2 months`,
65
+
`Create or update a kubeconfig for the SKE cluster with name "my-cluster" and set the expiration time to 2 months. If the config exits in the kubeconfig file the information will be updated.`,
`Create a kubeconfig for the SKE cluster with name "my-cluster" in a custom filepath`,
68
+
`Create or update a kubeconfig for the SKE cluster with name "my-cluster" in a custom filepath. If the config exits in the kubeconfig file the information will be updated.`,
prompt:=fmt.Sprintf("Are you sure you want to create a kubeconfig for SKE cluster %q? This will OVERWRITE your current kubeconfig file, if it exists.", model.ClusterName)
91
+
varpromptstring
92
+
ifmodel.Overwrite {
93
+
prompt=fmt.Sprintf("Are you sure you want to create a kubeconfig for SKE cluster %q? This will OVERWRITE your current kubeconfig file, if it exists.", model.ClusterName)
94
+
} else {
95
+
prompt=fmt.Sprintf("Are you sure you want to update your kubeconfig for SKE cluster %q? This will update your kubeconfig file. \nIf it the kubeconfig file doesn't exists, it will create a new one.", model.ClusterName)
cmd.Flags().Bool(disableWritingFlag, false, fmt.Sprintf("Disable the writing of kubeconfig. Set the output format to json or yaml using the --%s flag to display the kubeconfig.", globalflags.OutputFormatFlag))
154
170
cmd.Flags().BoolP(loginFlag, "l", false, "Create a login kubeconfig that obtains valid credentials via the STACKIT CLI. This flag is mutually exclusive with the expiration flag.")
155
-
cmd.Flags().StringP(expirationFlag, "e", "", "Expiration time for the kubeconfig in seconds(s), minutes(m), hours(h), days(d) or months(M). Example: 30d. By default, expiration time is 1h")
156
171
cmd.Flags().String(filepathFlag, "", "Path to create the kubeconfig file. By default, the kubeconfig is created as 'config' in the .kube folder, in the user's home directory.")
157
-
cmd.Flags().Bool(disableWritingFlag, false, fmt.Sprintf("Disable the writing of kubeconfig. Set the output format to json or yaml using the --%s flag to display the kubeconfig.", globalflags.OutputFormatFlag))
158
-
172
+
cmd.Flags().StringP(expirationFlag, "e", "", "Expiration time for the kubeconfig in seconds(s), minutes(m), hours(h), days(d) or months(M). Example: 30d. By default, expiration time is 1h")
173
+
cmd.Flags().Bool(overwriteFlag, false, "Overwrite the kubeconfig file.")
0 commit comments