Skip to content

Commit

Permalink
fix(clustertool): dont needlessly try to configure kubeconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
PrivatePuffin committed Oct 26, 2024
1 parent 90bed57 commit cc10a39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
20 changes: 11 additions & 9 deletions clustertool/cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var apply = &cobra.Command{
if helper.GetYesOrNo("Do you want to bootstrap now? (yes/no) [y/n]: ") {
gencmd.RunBootstrap(extraArgs)
if helper.GetYesOrNo("Do you want to apply config to all remaining clusternodes as well? (yes/no) [y/n]: ") {
RunApply("", extraArgs)
RunApply(false, "", extraArgs)
}
} else {
log.Info().Msg("Exiting bootstrap, as apply is not possible...")
Expand All @@ -90,26 +90,28 @@ var apply = &cobra.Command{
} else {
log.Info().Msg("Detected maintenance mode, but first node does not require to be bootrapped.")
log.Info().Msg("Assuming apply is requested... continuing with Apply...")
RunApply(node, extraArgs)
RunApply(true, node, extraArgs)
}

} else if status == "running" {
log.Info().Msg("Apply: running first controlnode detected, continuing...")
RunApply(node, extraArgs)
RunApply(true, node, extraArgs)
}
},
}

func RunApply(node string, extraArgs []string) {
func RunApply(kubeconfig bool, node string, extraArgs []string) {
taloscmds := gencmd.GenApply(node, extraArgs)
gencmd.ExecCmds(taloscmds, true)

kubeconfigcmds := gencmd.GenKubeConfig(helper.TalEnv["VIP_IP"])
gencmd.ExecCmd(kubeconfigcmds)

if helper.GetYesOrNo("Do you want to (re)load ssh, Sops and ClusterEnv onto the cluster? (yes/no) [y/n]: ") {

if kubeconfig {
kubeconfigcmds := gencmd.GenKubeConfig(helper.TalEnv["VIP_IP"])
gencmd.ExecCmd(kubeconfigcmds)
}

//if helper.GetYesOrNo("Do you want to (re)load ssh, Sops and ClusterEnv onto the cluster? (yes/no) [y/n]: ") {
//
//}
}

func init() {
Expand Down
10 changes: 0 additions & 10 deletions clustertool/cmd/genconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/truecharts/public/clustertool/pkg/gencmd"
"github.com/truecharts/public/clustertool/pkg/helper"
"github.com/truecharts/public/clustertool/pkg/nodestatus"
"github.com/truecharts/public/clustertool/pkg/sops"
)

Expand All @@ -31,14 +29,6 @@ var genConfig = &cobra.Command{
}

gencmd.GenConfig(args)
err := nodestatus.CheckHealth(helper.TalEnv["VIP_IP"], "", true)
if err == nil {
log.Info().Msg("Running Cluster Detected, setting KubeConfig...")
kubeconfigcmds := gencmd.GenKubeConfig(helper.TalEnv["VIP_IP"])
gencmd.ExecCmd(kubeconfigcmds)
} else {
log.Info().Msg("No Running Cluster Detected, Skipping KubeConfig...")
}
},
}

Expand Down

0 comments on commit cc10a39

Please sign in to comment.