50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"kube-forge/internal/config"
|
|
"kube-forge/internal/kubespray"
|
|
"kube-forge/internal/templates"
|
|
"os"
|
|
)
|
|
|
|
func parseArgs() (string, string, string) {
|
|
var password, configPath, workDir string
|
|
flag.StringVar(&password, "p", "", "Password to access hosts")
|
|
flag.StringVar(&configPath, "c", "/etc/kube-forge/config.yaml", "Path to config file")
|
|
flag.StringVar(&workDir, "d", "/var/lib/kube-forge", "Path to kube-forge work dir")
|
|
flag.Parse()
|
|
return password, configPath, workDir
|
|
}
|
|
|
|
func main() {
|
|
password, configPath, workDir := parseArgs()
|
|
config := config.CreateConfig(configPath, workDir, password)
|
|
|
|
repositories, releases := templates.GetHelmAppsConfigData()
|
|
config.Repositories = repositories
|
|
config.Releases = releases
|
|
|
|
templates.ApplyK8sTemplates()
|
|
|
|
for _, cmd := range os.Args {
|
|
switch cmd {
|
|
case "apply":
|
|
kubespray.InstallCluster("")
|
|
kubespray.CopyK8SAdminConfig("k8s-admin.conf")
|
|
return
|
|
case "apply-modules":
|
|
kubespray.InstallCluster("helm-apps")
|
|
return
|
|
case "upgrade":
|
|
kubespray.UpgradeCluster("")
|
|
return
|
|
case "scale":
|
|
kubespray.ScaleCluster()
|
|
return
|
|
}
|
|
}
|
|
fmt.Println("No such command\nAvailable commands: apply, apply-modules, upgrade, scale")
|
|
}
|