mirror of https://github.com/kubernetes/kops.git
Implement "kops edit instancegroup --set" and "--unset"
This commit is contained in:
parent
8be10e96d0
commit
66024869a0
|
@ -42,18 +42,12 @@ go_library(
|
||||||
"rollingupdate.go",
|
"rollingupdate.go",
|
||||||
"rollingupdate_cluster.go",
|
"rollingupdate_cluster.go",
|
||||||
"root.go",
|
"root.go",
|
||||||
"set.go",
|
|
||||||
"set_cluster.go",
|
|
||||||
"set_instancegroups.go",
|
|
||||||
"toolbox.go",
|
"toolbox.go",
|
||||||
"toolbox_dump.go",
|
"toolbox_dump.go",
|
||||||
"toolbox_instance_selector.go",
|
"toolbox_instance_selector.go",
|
||||||
"toolbox_template.go",
|
"toolbox_template.go",
|
||||||
"trust.go",
|
"trust.go",
|
||||||
"trust_keypair.go",
|
"trust_keypair.go",
|
||||||
"unset.go",
|
|
||||||
"unset_cluster.go",
|
|
||||||
"unset_instancegroups.go",
|
|
||||||
"update.go",
|
"update.go",
|
||||||
"update_cluster.go",
|
"update_cluster.go",
|
||||||
"upgrade.go",
|
"upgrade.go",
|
||||||
|
|
|
@ -62,7 +62,7 @@ var (
|
||||||
To set your preferred editor, you can define the EDITOR environment variable.
|
To set your preferred editor, you can define the EDITOR environment variable.
|
||||||
When you have done this, kOps will use the editor that you have set.
|
When you have done this, kOps will use the editor that you have set.
|
||||||
|
|
||||||
kops edit does not update the cloud resources, to apply the changes use ` + pretty.Bash("kops update cluster") + `.`))
|
kops edit does not update the cloud resources; to apply the changes use ` + pretty.Bash("kops update cluster") + `.`))
|
||||||
|
|
||||||
editClusterExample = templates.Examples(i18n.T(`
|
editClusterExample = templates.Examples(i18n.T(`
|
||||||
# Edit a cluster configuration in AWS.
|
# Edit a cluster configuration in AWS.
|
||||||
|
|
|
@ -32,9 +32,13 @@ import (
|
||||||
api "k8s.io/kops/pkg/apis/kops"
|
api "k8s.io/kops/pkg/apis/kops"
|
||||||
"k8s.io/kops/pkg/apis/kops/validation"
|
"k8s.io/kops/pkg/apis/kops/validation"
|
||||||
"k8s.io/kops/pkg/assets"
|
"k8s.io/kops/pkg/assets"
|
||||||
|
"k8s.io/kops/pkg/client/simple"
|
||||||
|
"k8s.io/kops/pkg/commands"
|
||||||
"k8s.io/kops/pkg/commands/commandutils"
|
"k8s.io/kops/pkg/commands/commandutils"
|
||||||
"k8s.io/kops/pkg/edit"
|
"k8s.io/kops/pkg/edit"
|
||||||
|
"k8s.io/kops/pkg/featureflag"
|
||||||
"k8s.io/kops/pkg/kopscodecs"
|
"k8s.io/kops/pkg/kopscodecs"
|
||||||
|
"k8s.io/kops/pkg/pretty"
|
||||||
"k8s.io/kops/pkg/try"
|
"k8s.io/kops/pkg/try"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup"
|
"k8s.io/kops/upup/pkg/fi/cloudup"
|
||||||
"k8s.io/kubectl/pkg/cmd/util/editor"
|
"k8s.io/kubectl/pkg/cmd/util/editor"
|
||||||
|
@ -43,14 +47,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
editInstancegroupLong = templates.LongDesc(i18n.T(`Edit a cluster configuration.
|
editInstancegroupLong = pretty.LongDesc(i18n.T(`Edit a cluster configuration.
|
||||||
|
|
||||||
This command changes the instancegroup desired configuration in the registry.
|
This command changes the instance group desired configuration in the registry.
|
||||||
|
|
||||||
To set your preferred editor, you can define the EDITOR environment variable.
|
To set your preferred editor, you can define the EDITOR environment variable.
|
||||||
When you have done this, kOps will use the editor that you have set.
|
When you have done this, kOps will use the editor that you have set.
|
||||||
|
|
||||||
kops edit does not update the cloud resources, to apply the changes use "kops update cluster".`))
|
kops edit does not update the cloud resources; to apply the changes use ` + pretty.Bash("kops update cluster") + `.`))
|
||||||
|
|
||||||
editInstancegroupExample = templates.Examples(i18n.T(`
|
editInstancegroupExample = templates.Examples(i18n.T(`
|
||||||
# Edit an instancegroup desired configuration.
|
# Edit an instancegroup desired configuration.
|
||||||
|
@ -63,6 +67,11 @@ var (
|
||||||
type EditInstanceGroupOptions struct {
|
type EditInstanceGroupOptions struct {
|
||||||
ClusterName string
|
ClusterName string
|
||||||
GroupName string
|
GroupName string
|
||||||
|
|
||||||
|
// Sets allows setting values directly in the spec.
|
||||||
|
Sets []string
|
||||||
|
// Unsets allows unsetting values directly in the spec.
|
||||||
|
Unsets []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmdEditInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command {
|
func NewCmdEditInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command {
|
||||||
|
@ -99,6 +108,17 @@ func NewCmdEditInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if featureflag.SpecOverrideFlag.Enabled() {
|
||||||
|
cmd.Flags().StringSliceVar(&options.Sets, "set", options.Sets, "Directly set values in the spec")
|
||||||
|
cmd.RegisterFlagCompletionFunc("set", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
})
|
||||||
|
cmd.Flags().StringSliceVar(&options.Unsets, "unset", options.Unsets, "Directly unset values in the spec")
|
||||||
|
cmd.RegisterFlagCompletionFunc("unset", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +148,25 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, o
|
||||||
return fmt.Errorf("InstanceGroup %q not found", groupName)
|
return fmt.Errorf("InstanceGroup %q not found", groupName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(options.Unsets)+len(options.Sets) > 0 {
|
||||||
|
newGroup := oldGroup.DeepCopy()
|
||||||
|
if err := commands.UnsetInstancegroupFields(options.Unsets, newGroup); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := commands.SetInstancegroupFields(options.Sets, newGroup); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
failure, err := updateInstanceGroup(ctx, clientset, channel, cluster, oldGroup, newGroup)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if failure != "" {
|
||||||
|
return fmt.Errorf("%s", failure)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
editor = editor.NewDefaultEditor(commandutils.EditorEnvs)
|
editor = editor.NewDefaultEditor(commandutils.EditorEnvs)
|
||||||
)
|
)
|
||||||
|
@ -226,54 +265,53 @@ func RunEditInstanceGroup(ctx context.Context, f *util.Factory, out io.Writer, o
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
cloud, err := cloudup.BuildCloud(cluster)
|
failure, err := updateInstanceGroup(ctx, clientset, channel, cluster, oldGroup, newGroup)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fullGroup, err := cloudup.PopulateInstanceGroupSpec(cluster, newGroup, cloud, channel)
|
|
||||||
if err != nil {
|
|
||||||
results = editResults{
|
|
||||||
file: file,
|
|
||||||
}
|
|
||||||
results.header.addError(fmt.Sprintf("error populating instance group spec: %s", err))
|
|
||||||
containsError = true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need the full cluster spec to perform deep validation
|
|
||||||
// Note that we don't write it back though
|
|
||||||
err = cloudup.PerformAssignments(cluster, cloud)
|
|
||||||
if err != nil {
|
|
||||||
return preservedFile(fmt.Errorf("error populating configuration: %v", err), file, out)
|
|
||||||
}
|
|
||||||
|
|
||||||
assetBuilder := assets.NewAssetBuilder(cluster, false)
|
|
||||||
fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, cloud, assetBuilder)
|
|
||||||
if err != nil {
|
|
||||||
results = editResults{
|
|
||||||
file: file,
|
|
||||||
}
|
|
||||||
results.header.addError(fmt.Sprintf("error populating cluster spec: %s", err))
|
|
||||||
containsError = true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validation.CrossValidateInstanceGroup(fullGroup, fullCluster, cloud).ToAggregate()
|
|
||||||
if err != nil {
|
|
||||||
results = editResults{
|
|
||||||
file: file,
|
|
||||||
}
|
|
||||||
results.header.addError(fmt.Sprintf("validation failed: %s", err))
|
|
||||||
containsError = true
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note we perform as much validation as we can, before writing a bad config
|
|
||||||
_, err = clientset.InstanceGroupsFor(cluster).Update(ctx, fullGroup, metav1.UpdateOptions{})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return preservedFile(err, file, out)
|
return preservedFile(err, file, out)
|
||||||
}
|
}
|
||||||
|
if failure != "" {
|
||||||
|
results = editResults{
|
||||||
|
file: file,
|
||||||
|
}
|
||||||
|
results.header.addError(failure)
|
||||||
|
containsError = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateInstanceGroup(ctx context.Context, clientset simple.Clientset, channel *api.Channel, cluster *api.Cluster, oldGroup, newGroup *api.InstanceGroup) (string, error) {
|
||||||
|
cloud, err := cloudup.BuildCloud(cluster)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
fullGroup, err := cloudup.PopulateInstanceGroupSpec(cluster, newGroup, cloud, channel)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("error populating instance group spec: %s", err), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need the full cluster spec to perform deep validation
|
||||||
|
// Note that we don't write it back though
|
||||||
|
err = cloudup.PerformAssignments(cluster, cloud)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("error populating configuration: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assetBuilder := assets.NewAssetBuilder(cluster, false)
|
||||||
|
fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, cloud, assetBuilder)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("error populating cluster spec: %s", err), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validation.CrossValidateInstanceGroup(fullGroup, fullCluster, cloud).ToAggregate()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("validation failed: %s", err), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note we perform as much validation as we can, before writing a bad config
|
||||||
|
_, err = clientset.InstanceGroupsFor(cluster).Update(ctx, fullGroup, metav1.UpdateOptions{})
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
|
@ -154,10 +154,8 @@ func NewCmdRoot(f *util.Factory, out io.Writer) *cobra.Command {
|
||||||
cmd.AddCommand(NewCmdPromote(f, out))
|
cmd.AddCommand(NewCmdPromote(f, out))
|
||||||
cmd.AddCommand(NewCmdReplace(f, out))
|
cmd.AddCommand(NewCmdReplace(f, out))
|
||||||
cmd.AddCommand(NewCmdRollingUpdate(f, out))
|
cmd.AddCommand(NewCmdRollingUpdate(f, out))
|
||||||
cmd.AddCommand(NewCmdSet(f, out))
|
|
||||||
cmd.AddCommand(NewCmdToolbox(f, out))
|
cmd.AddCommand(NewCmdToolbox(f, out))
|
||||||
cmd.AddCommand(NewCmdTrust(f, out))
|
cmd.AddCommand(NewCmdTrust(f, out))
|
||||||
cmd.AddCommand(NewCmdUnset(f, out))
|
|
||||||
cmd.AddCommand(NewCmdUpdate(f, out))
|
cmd.AddCommand(NewCmdUpdate(f, out))
|
||||||
cmd.AddCommand(NewCmdUpgrade(f, out))
|
cmd.AddCommand(NewCmdUpgrade(f, out))
|
||||||
cmd.AddCommand(NewCmdValidate(f, out))
|
cmd.AddCommand(NewCmdValidate(f, out))
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2019 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/kops/cmd/kops/util"
|
|
||||||
"k8s.io/kubectl/pkg/util/i18n"
|
|
||||||
"k8s.io/kubectl/pkg/util/templates"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
setLong = templates.LongDesc(i18n.T(`Set a configuration field.
|
|
||||||
|
|
||||||
kops set does not update the cloud resources; to apply the changes use "kops update cluster".
|
|
||||||
`))
|
|
||||||
|
|
||||||
setExample = templates.Examples(i18n.T(`
|
|
||||||
# Set cluster to run kubernetes version 1.17.0
|
|
||||||
kops set cluster k8s-cluster.example.com spec.kubernetesVersion=1.17.0
|
|
||||||
kops set instancegroup --name k8s-cluster.example.com nodes-1a spec.maxSize=4
|
|
||||||
`))
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCmdSet(f *util.Factory, out io.Writer) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "set",
|
|
||||||
Short: i18n.T("Set fields on clusters and other resources."),
|
|
||||||
Long: setLong,
|
|
||||||
Example: setExample,
|
|
||||||
}
|
|
||||||
|
|
||||||
// create subcommands
|
|
||||||
cmd.AddCommand(NewCmdSetInstancegroup(f, out))
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2021 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/kubectl/pkg/util/i18n"
|
|
||||||
"k8s.io/kubectl/pkg/util/templates"
|
|
||||||
|
|
||||||
"k8s.io/kops/cmd/kops/util"
|
|
||||||
"k8s.io/kops/pkg/commands"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
setInstancegroupLong = templates.LongDesc(i18n.T(`Set an instance group field value.
|
|
||||||
|
|
||||||
This command changes the desired instance group configuration in the registry.
|
|
||||||
|
|
||||||
kops set does not update the cloud resources; to apply the changes use "kops update cluster".`))
|
|
||||||
|
|
||||||
setInstancegroupExample = templates.Examples(i18n.T(`
|
|
||||||
# Set instance group to run image custom-ami-image
|
|
||||||
kops set instancegroup --name k8s-cluster.example.com nodes spec.image=custom-ami-image
|
|
||||||
`))
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewCmdSetInstancegroup builds a cobra command for the kops set instancegroup command.
|
|
||||||
func NewCmdSetInstancegroup(f *util.Factory, out io.Writer) *cobra.Command {
|
|
||||||
options := &commands.SetInstanceGroupOptions{}
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "instancegroup",
|
|
||||||
Aliases: []string{"instancegroups", "ig"},
|
|
||||||
Short: i18n.T("Set instancegroup fields."),
|
|
||||||
Long: setInstancegroupLong,
|
|
||||||
Example: setInstancegroupExample,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
for i, arg := range args {
|
|
||||||
index := strings.Index(arg, "=")
|
|
||||||
|
|
||||||
if i == 0 {
|
|
||||||
if index != -1 {
|
|
||||||
exitWithError(fmt.Errorf("Specify name of instance group to edit"))
|
|
||||||
}
|
|
||||||
options.InstanceGroupName = arg
|
|
||||||
} else {
|
|
||||||
if index == -1 {
|
|
||||||
exitWithError(fmt.Errorf("unrecognized parameter %q (missing '=')", arg))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
options.Fields = append(options.Fields, arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options.ClusterName = rootCommand.ClusterName(true)
|
|
||||||
|
|
||||||
if err := commands.RunSetInstancegroup(ctx, f, cmd, out, options); err != nil {
|
|
||||||
exitWithError(err)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2021 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/kops/cmd/kops/util"
|
|
||||||
"k8s.io/kubectl/pkg/util/i18n"
|
|
||||||
"k8s.io/kubectl/pkg/util/templates"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
unsetLong = templates.LongDesc(i18n.T(`Unset a configuration field.
|
|
||||||
|
|
||||||
kops unset does not update the cloud resources; to apply the changes use "kops update cluster".
|
|
||||||
`))
|
|
||||||
|
|
||||||
unsetExample = templates.Examples(i18n.T(`
|
|
||||||
kops unset cluster k8s-cluster.example.com spec.iam.allowContainerRegistry
|
|
||||||
kops unset instancegroup --name k8s-cluster.example.com nodes-1a spec.maxSize
|
|
||||||
`))
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewCmdUnset(f *util.Factory, out io.Writer) *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "unset",
|
|
||||||
Short: i18n.T("Unset fields on clusters and other resources."),
|
|
||||||
Long: unsetLong,
|
|
||||||
Example: unsetExample,
|
|
||||||
}
|
|
||||||
|
|
||||||
// create subcommands
|
|
||||||
cmd.AddCommand(NewCmdUnsetInstancegroup(f, out))
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2021 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"k8s.io/kubectl/pkg/util/i18n"
|
|
||||||
"k8s.io/kubectl/pkg/util/templates"
|
|
||||||
|
|
||||||
"k8s.io/kops/cmd/kops/util"
|
|
||||||
"k8s.io/kops/pkg/commands"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
unsetInstancegroupLong = templates.LongDesc(i18n.T(`Unset an instance group field value.
|
|
||||||
|
|
||||||
This command changes the desired instance group configuration in the registry.
|
|
||||||
|
|
||||||
kops unset does not update the cloud resources; to apply the changes use "kops update cluster".`))
|
|
||||||
|
|
||||||
unsetInstancegroupExample = templates.Examples(i18n.T(`
|
|
||||||
# Set instance group to run default image
|
|
||||||
kops unset instancegroup --name k8s-cluster.example.com nodes spec.image
|
|
||||||
`))
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewCmdUnsetInstancegroup builds a cobra command for the kops set instancegroup command.
|
|
||||||
func NewCmdUnsetInstancegroup(f *util.Factory, out io.Writer) *cobra.Command {
|
|
||||||
options := &commands.UnsetInstanceGroupOptions{}
|
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "instancegroup",
|
|
||||||
Aliases: []string{"instancegroups", "ig"},
|
|
||||||
Short: i18n.T("Unset instancegroup fields."),
|
|
||||||
Long: unsetInstancegroupLong,
|
|
||||||
Example: unsetInstancegroupExample,
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
for i, arg := range args {
|
|
||||||
if i == 0 && !strings.HasPrefix(arg, "spec.") && !strings.HasPrefix(arg, "instancegroup.") {
|
|
||||||
options.InstanceGroupName = arg
|
|
||||||
} else {
|
|
||||||
options.Fields = append(options.Fields, arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options.ClusterName = rootCommand.ClusterName(true)
|
|
||||||
|
|
||||||
if err := commands.RunUnsetInstancegroup(ctx, f, cmd, out, options); err != nil {
|
|
||||||
exitWithError(err)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
|
@ -48,10 +48,8 @@ kOps is Kubernetes Operations.
|
||||||
* [kops promote](kops_promote.md) - Promote a resource.
|
* [kops promote](kops_promote.md) - Promote a resource.
|
||||||
* [kops replace](kops_replace.md) - Replace cluster resources.
|
* [kops replace](kops_replace.md) - Replace cluster resources.
|
||||||
* [kops rolling-update](kops_rolling-update.md) - Rolling update a cluster.
|
* [kops rolling-update](kops_rolling-update.md) - Rolling update a cluster.
|
||||||
* [kops set](kops_set.md) - Set fields on clusters and other resources.
|
|
||||||
* [kops toolbox](kops_toolbox.md) - Misc infrequently used commands.
|
* [kops toolbox](kops_toolbox.md) - Misc infrequently used commands.
|
||||||
* [kops trust](kops_trust.md) - Trust keypairs.
|
* [kops trust](kops_trust.md) - Trust keypairs.
|
||||||
* [kops unset](kops_unset.md) - Unset fields on clusters and other resources.
|
|
||||||
* [kops update](kops_update.md) - Update a cluster.
|
* [kops update](kops_update.md) - Update a cluster.
|
||||||
* [kops upgrade](kops_upgrade.md) - Upgrade a kubernetes cluster.
|
* [kops upgrade](kops_upgrade.md) - Upgrade a kubernetes cluster.
|
||||||
* [kops validate](kops_validate.md) - Validate a kOps cluster.
|
* [kops validate](kops_validate.md) - Validate a kOps cluster.
|
||||||
|
|
|
@ -14,7 +14,7 @@ This command changes the desired cluster configuration in the registry.
|
||||||
To set your preferred editor, you can define the EDITOR environment variable.
|
To set your preferred editor, you can define the EDITOR environment variable.
|
||||||
When you have done this, kOps will use the editor that you have set.
|
When you have done this, kOps will use the editor that you have set.
|
||||||
|
|
||||||
kops edit does not update the cloud resources, to apply the changes use `kops update cluster`.
|
kops edit does not update the cloud resources; to apply the changes use `kops update cluster`.
|
||||||
|
|
||||||
```
|
```
|
||||||
kops edit cluster [CLUSTER] [flags]
|
kops edit cluster [CLUSTER] [flags]
|
||||||
|
|
|
@ -9,11 +9,12 @@ Edit instancegroup.
|
||||||
|
|
||||||
Edit a cluster configuration.
|
Edit a cluster configuration.
|
||||||
|
|
||||||
This command changes the instancegroup desired configuration in the registry.
|
This command changes the instance group desired configuration in the registry.
|
||||||
|
|
||||||
To set your preferred editor, you can define the EDITOR environment variable. When you have done this, kOps will use the editor that you have set.
|
To set your preferred editor, you can define the EDITOR environment variable.
|
||||||
|
When you have done this, kOps will use the editor that you have set.
|
||||||
|
|
||||||
kops edit does not update the cloud resources, to apply the changes use "kops update cluster".
|
kops edit does not update the cloud resources; to apply the changes use `kops update cluster`.
|
||||||
|
|
||||||
```
|
```
|
||||||
kops edit instancegroup INSTANCE_GROUP [flags]
|
kops edit instancegroup INSTANCE_GROUP [flags]
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
|
|
||||||
<!--- This file is automatically generated by make gen-cli-docs; changes should be made in the go CLI command code (under cmd/kops) -->
|
|
||||||
|
|
||||||
## kops set
|
|
||||||
|
|
||||||
Set fields on clusters and other resources.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Set a configuration field.
|
|
||||||
|
|
||||||
kops set does not update the cloud resources; to apply the changes use "kops update cluster".
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
# Set cluster to run kubernetes version 1.17.0
|
|
||||||
kops set cluster k8s-cluster.example.com spec.kubernetesVersion=1.17.0
|
|
||||||
kops set instancegroup --name k8s-cluster.example.com nodes-1a spec.maxSize=4
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for set
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--add_dir_header If true, adds the file directory to the header of the log messages
|
|
||||||
--alsologtostderr log to standard error as well as files
|
|
||||||
--config string yaml config file (default is $HOME/.kops.yaml)
|
|
||||||
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
|
|
||||||
--log_dir string If non-empty, write log files in this directory
|
|
||||||
--log_file string If non-empty, use this log file
|
|
||||||
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
|
|
||||||
--logtostderr log to standard error instead of files (default true)
|
|
||||||
--name string Name of cluster. Overrides KOPS_CLUSTER_NAME environment variable
|
|
||||||
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level)
|
|
||||||
--skip_headers If true, avoid header prefixes in the log messages
|
|
||||||
--skip_log_headers If true, avoid headers when opening log files
|
|
||||||
--state string Location of state storage (kops 'config' file). Overrides KOPS_STATE_STORE environment variable
|
|
||||||
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
|
|
||||||
-v, --v Level number for the log level verbosity
|
|
||||||
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kops](kops.md) - kOps is Kubernetes Operations.
|
|
||||||
* [kops set instancegroup](kops_set_instancegroup.md) - Set instancegroup fields.
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
|
|
||||||
<!--- This file is automatically generated by make gen-cli-docs; changes should be made in the go CLI command code (under cmd/kops) -->
|
|
||||||
|
|
||||||
## kops set instancegroup
|
|
||||||
|
|
||||||
Set instancegroup fields.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Set an instance group field value.
|
|
||||||
|
|
||||||
This command changes the desired instance group configuration in the registry.
|
|
||||||
|
|
||||||
kops set does not update the cloud resources; to apply the changes use "kops update cluster".
|
|
||||||
|
|
||||||
```
|
|
||||||
kops set instancegroup [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
# Set instance group to run image custom-ami-image
|
|
||||||
kops set instancegroup --name k8s-cluster.example.com nodes spec.image=custom-ami-image
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for instancegroup
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--add_dir_header If true, adds the file directory to the header of the log messages
|
|
||||||
--alsologtostderr log to standard error as well as files
|
|
||||||
--config string yaml config file (default is $HOME/.kops.yaml)
|
|
||||||
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
|
|
||||||
--log_dir string If non-empty, write log files in this directory
|
|
||||||
--log_file string If non-empty, use this log file
|
|
||||||
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
|
|
||||||
--logtostderr log to standard error instead of files (default true)
|
|
||||||
--name string Name of cluster. Overrides KOPS_CLUSTER_NAME environment variable
|
|
||||||
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level)
|
|
||||||
--skip_headers If true, avoid header prefixes in the log messages
|
|
||||||
--skip_log_headers If true, avoid headers when opening log files
|
|
||||||
--state string Location of state storage (kops 'config' file). Overrides KOPS_STATE_STORE environment variable
|
|
||||||
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
|
|
||||||
-v, --v Level number for the log level verbosity
|
|
||||||
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kops set](kops_set.md) - Set fields on clusters and other resources.
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
|
|
||||||
<!--- This file is automatically generated by make gen-cli-docs; changes should be made in the go CLI command code (under cmd/kops) -->
|
|
||||||
|
|
||||||
## kops unset
|
|
||||||
|
|
||||||
Unset fields on clusters and other resources.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Unset a configuration field.
|
|
||||||
|
|
||||||
kops unset does not update the cloud resources; to apply the changes use "kops update cluster".
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
kops unset cluster k8s-cluster.example.com spec.iam.allowContainerRegistry
|
|
||||||
kops unset instancegroup --name k8s-cluster.example.com nodes-1a spec.maxSize
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for unset
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--add_dir_header If true, adds the file directory to the header of the log messages
|
|
||||||
--alsologtostderr log to standard error as well as files
|
|
||||||
--config string yaml config file (default is $HOME/.kops.yaml)
|
|
||||||
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
|
|
||||||
--log_dir string If non-empty, write log files in this directory
|
|
||||||
--log_file string If non-empty, use this log file
|
|
||||||
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
|
|
||||||
--logtostderr log to standard error instead of files (default true)
|
|
||||||
--name string Name of cluster. Overrides KOPS_CLUSTER_NAME environment variable
|
|
||||||
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level)
|
|
||||||
--skip_headers If true, avoid header prefixes in the log messages
|
|
||||||
--skip_log_headers If true, avoid headers when opening log files
|
|
||||||
--state string Location of state storage (kops 'config' file). Overrides KOPS_STATE_STORE environment variable
|
|
||||||
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
|
|
||||||
-v, --v Level number for the log level verbosity
|
|
||||||
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kops](kops.md) - kOps is Kubernetes Operations.
|
|
||||||
* [kops unset instancegroup](kops_unset_instancegroup.md) - Unset instancegroup fields.
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
|
|
||||||
<!--- This file is automatically generated by make gen-cli-docs; changes should be made in the go CLI command code (under cmd/kops) -->
|
|
||||||
|
|
||||||
## kops unset instancegroup
|
|
||||||
|
|
||||||
Unset instancegroup fields.
|
|
||||||
|
|
||||||
### Synopsis
|
|
||||||
|
|
||||||
Unset an instance group field value.
|
|
||||||
|
|
||||||
This command changes the desired instance group configuration in the registry.
|
|
||||||
|
|
||||||
kops unset does not update the cloud resources; to apply the changes use "kops update cluster".
|
|
||||||
|
|
||||||
```
|
|
||||||
kops unset instancegroup [flags]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
```
|
|
||||||
# Set instance group to run default image
|
|
||||||
kops unset instancegroup --name k8s-cluster.example.com nodes spec.image
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
```
|
|
||||||
-h, --help help for instancegroup
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options inherited from parent commands
|
|
||||||
|
|
||||||
```
|
|
||||||
--add_dir_header If true, adds the file directory to the header of the log messages
|
|
||||||
--alsologtostderr log to standard error as well as files
|
|
||||||
--config string yaml config file (default is $HOME/.kops.yaml)
|
|
||||||
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
|
|
||||||
--log_dir string If non-empty, write log files in this directory
|
|
||||||
--log_file string If non-empty, use this log file
|
|
||||||
--log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
|
|
||||||
--logtostderr log to standard error instead of files (default true)
|
|
||||||
--name string Name of cluster. Overrides KOPS_CLUSTER_NAME environment variable
|
|
||||||
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level)
|
|
||||||
--skip_headers If true, avoid header prefixes in the log messages
|
|
||||||
--skip_log_headers If true, avoid headers when opening log files
|
|
||||||
--state string Location of state storage (kops 'config' file). Overrides KOPS_STATE_STORE environment variable
|
|
||||||
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
|
|
||||||
-v, --v Level number for the log level verbosity
|
|
||||||
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
|
|
||||||
```
|
|
||||||
|
|
||||||
### SEE ALSO
|
|
||||||
|
|
||||||
* [kops unset](kops_unset.md) - Unset fields on clusters and other resources.
|
|
||||||
|
|
|
@ -60,10 +60,8 @@ nav:
|
||||||
- kops promote: "cli/kops_promote.md"
|
- kops promote: "cli/kops_promote.md"
|
||||||
- kops replace: "cli/kops_replace.md"
|
- kops replace: "cli/kops_replace.md"
|
||||||
- kops rolling-update: "cli/kops_rolling-update.md"
|
- kops rolling-update: "cli/kops_rolling-update.md"
|
||||||
- kops set: "cli/kops_set.md"
|
|
||||||
- kops toolbox: "cli/kops_toolbox.md"
|
- kops toolbox: "cli/kops_toolbox.md"
|
||||||
- kops trust: "cli/kops_trust.md"
|
- kops trust: "cli/kops_trust.md"
|
||||||
- kops unset: "cli/kops_unset.md"
|
|
||||||
- kops update: "cli/kops_update.md"
|
- kops update: "cli/kops_update.md"
|
||||||
- kops upgrade: "cli/kops_upgrade.md"
|
- kops upgrade: "cli/kops_upgrade.md"
|
||||||
- kops validate: "cli/kops_validate.md"
|
- kops validate: "cli/kops_validate.md"
|
||||||
|
|
Loading…
Reference in New Issue