Skip to content

Commit

Permalink
Merge pull request #9411 from johngmyers/apply-logic
Browse files Browse the repository at this point in the history
Move apply logic down into pkg for import use
  • Loading branch information
k8s-ci-robot authored Jun 20, 2020
2 parents 80e1da9 + 99c8c4b commit f79f368
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
26 changes: 1 addition & 25 deletions cmd/kops/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/viper"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog"
"k8s.io/kops/cmd/kops/util"
Expand Down Expand Up @@ -236,33 +235,10 @@ func RunUpdateCluster(ctx context.Context, f *util.Factory, clusterName string,
lifecycleOverrideMap[taskName] = lifecycleOverride
}

var instanceGroups []*kops.InstanceGroup
{
list, err := clientset.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
for i := range list.Items {
instanceGroups = append(instanceGroups, &list.Items[i])

// Try to guess the path for additional third party volume plugins in Flatcar
image := strings.ToLower(list.Items[i].Spec.Image)
if strings.Contains(image, "flatcar") {
if cluster.Spec.Kubelet == nil {
cluster.Spec.Kubelet = &kops.KubeletConfigSpec{}
}
if cluster.Spec.Kubelet.VolumePluginDirectory == "" {
cluster.Spec.Kubelet.VolumePluginDirectory = "/var/lib/kubelet/volumeplugins/"
}
}
}
}

applyCmd := &cloudup.ApplyClusterCmd{
Clientset: clientset,
Cluster: cluster,
DryRun: isDryrun,
InstanceGroups: instanceGroups,
RunTasksOptions: &c.RunTasksOptions,
Models: strings.Split(c.Models, ","),
OutDir: c.OutDir,
Expand Down Expand Up @@ -360,7 +336,7 @@ func RunUpdateCluster(ctx context.Context, f *util.Factory, clusterName string,
fmt.Fprintf(sb, "Suggestions:\n")
fmt.Fprintf(sb, " * validate cluster: kops validate cluster --wait 10m\n")
fmt.Fprintf(sb, " * list nodes: kubectl get nodes --show-labels\n")
if !usesBastion(instanceGroups) {
if !usesBastion(applyCmd.InstanceGroups) {
fmt.Fprintf(sb, " * ssh to the master: ssh -i ~/.ssh/id_rsa ubuntu@%s\n", cluster.Spec.MasterPublicName)
} else {
bastionPublicName := findBastionPublicName(cluster)
Expand Down
13 changes: 13 additions & 0 deletions upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ func (c *ApplyClusterCmd) Run(ctx context.Context) error {
c.InstanceGroups = instanceGroups
}

for _, ig := range c.InstanceGroups {
// Try to guess the path for additional third party volume plugins in Flatcar
image := strings.ToLower(ig.Spec.Image)
if strings.Contains(image, "flatcar") {
if c.Cluster.Spec.Kubelet == nil {
c.Cluster.Spec.Kubelet = &kops.KubeletConfigSpec{}
}
if c.Cluster.Spec.Kubelet.VolumePluginDirectory == "" {
c.Cluster.Spec.Kubelet.VolumePluginDirectory = "/var/lib/kubelet/volumeplugins/"
}
}
}

if c.Models == nil {
c.Models = CloudupModels
}
Expand Down

0 comments on commit f79f368

Please sign in to comment.