mirror of https://github.com/k3s-io/k3s
Merge pull request #72588 from prksu/kubectl-config-set-example
Add kubectl config set examplepull/564/head
commit
408d4c0cb8
|
@ -40,12 +40,29 @@ type setOptions struct {
|
|||
setRawBytes flag.Tristate
|
||||
}
|
||||
|
||||
var setLong = templates.LongDesc(`
|
||||
var (
|
||||
setLong = templates.LongDesc(`
|
||||
Sets an individual value in a kubeconfig file
|
||||
|
||||
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
|
||||
|
||||
PROPERTY_VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64 encoded string unless the --set-raw-bytes flag is used.`)
|
||||
PROPERTY_VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64 encoded string unless the --set-raw-bytes flag is used.
|
||||
|
||||
Specifying a attribute name that already exists will merge new fields on top of existing values.`)
|
||||
|
||||
setExample = templates.Examples(`
|
||||
# Set server field on the my-cluster cluster to https://1.2.3.4
|
||||
kubectl config set clusters.my-cluster.server https://1.2.3.4
|
||||
|
||||
# Set certificate-authority-data field on the my-cluster cluster.
|
||||
kubectl config set clusters.my-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)
|
||||
|
||||
# Set cluster field in the my-context context to my-cluster.
|
||||
kubectl config set contexts.my-context.cluster my-cluster
|
||||
|
||||
# Set client-key-data field in the cluster-admin user using --set-raw-bytes option.
|
||||
kubectl config set users.cluster-admin.client-key-data cert_data_here --set-raw-bytes=true`)
|
||||
)
|
||||
|
||||
// NewCmdConfigSet returns a Command instance for 'config set' sub command
|
||||
func NewCmdConfigSet(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command {
|
||||
|
@ -56,6 +73,7 @@ func NewCmdConfigSet(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.
|
|||
DisableFlagsInUseLine: true,
|
||||
Short: i18n.T("Sets an individual value in a kubeconfig file"),
|
||||
Long: setLong,
|
||||
Example: setExample,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cmdutil.CheckErr(options.complete(cmd))
|
||||
cmdutil.CheckErr(options.run())
|
||||
|
|
Loading…
Reference in New Issue