Skip to content

Commit

Permalink
feat(install): fix install chart version (#29)
Browse files Browse the repository at this point in the history
Feat/install version
  • Loading branch information
ysicing authored Jul 6, 2022
1 parent de9d1ea commit 7dc0adc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 37 deletions.
49 changes: 25 additions & 24 deletions common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,31 @@ const (
)

const (
K3sBinName = "k3s"
K3sBinPath = "/usr/local/bin/k3s"
HelmBinName = "helm"
HelmBinPath = "/usr/local/bin/helm"
K3sBinVersion = "v1.23.5+k3s1"
K3sBinURL = "https://github.com/k3s-io/k3s/releases/download"
K3sAgentEnv = "/etc/systemd/system/k3s-agent.service.env"
K3sKubeConfig = "/etc/rancher/k3s/k3s.yaml"
KubeQPS = 5.0
KubeBurst = 10
KubectlBinPath = "/usr/local/bin/kubectl"
QcAdminBinPath = "/usr/local/bin/qcadmin"
StatusWaitDuration = 5 * time.Minute
WaitRetryInterval = 5 * time.Second
DefaultHelmRepoName = "install"
DefaultSystem = "cne-system"
DefaultChartName = "qucheng"
DefaultAPIChartName = "cne-api"
DefaultQuchengName = "qucheng"
DefaultCneAPIName = "cne-api"
DefaultDBName = "qucheng-mysql"
InitFileName = ".initdone"
InitLockFileName = ".qlock"
InitModeCluster = ".incluster"
DefaultQuchengVersion = "stable-1.1.0"
K3sBinName = "k3s"
K3sBinPath = "/usr/local/bin/k3s"
HelmBinName = "helm"
HelmBinPath = "/usr/local/bin/helm"
K3sBinVersion = "v1.23.5+k3s1"
K3sBinURL = "https://github.com/k3s-io/k3s/releases/download"
K3sAgentEnv = "/etc/systemd/system/k3s-agent.service.env"
K3sKubeConfig = "/etc/rancher/k3s/k3s.yaml"
KubeQPS = 5.0
KubeBurst = 10
KubectlBinPath = "/usr/local/bin/kubectl"
QcAdminBinPath = "/usr/local/bin/qcadmin"
StatusWaitDuration = 5 * time.Minute
WaitRetryInterval = 5 * time.Second
DefaultHelmRepoName = "install"
DefaultSystem = "cne-system"
DefaultChartName = "qucheng"
DefaultAPIChartName = "cne-api"
DefaultQuchengName = "qucheng"
DefaultCneAPIName = "cne-api"
DefaultDBName = "qucheng-mysql"
InitFileName = ".initdone"
InitLockFileName = ".qlock"
InitModeCluster = ".incluster"
)

const (
Expand Down
24 changes: 18 additions & 6 deletions common/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,36 @@ func GetDefaultLogDir() string {

// GetChartRepo 获取chartrepo地址
func GetChartRepo(p string) string {
if p == "stable" || p == "latest" {
p = "stable"
} else {
if strings.HasPrefix(p, "test") || strings.HasPrefix(p, "edge") {
p = "test"
} else {
p = "stable"
}
return fmt.Sprintf("https://hub.qucheng.com/chartrepo/%s", p)
}

// GetChannel 获取chartrepo channel地址
func GetChannel(p string) string {
if p == "stable" || p == "latest" {
p = "stable"
} else {
if strings.HasPrefix(p, "test") || strings.HasPrefix(p, "edge") {
p = "test"
} else {
p = "stable"
}
return p
}

// GetChannel 获取chartrepo channel地址
func GetVersion(p string) string {
if strings.Contains(p, "-") {
v := strings.Split(p, "-")
if len(v) != 2 {
return DefaultQuchengVersion
}
return v[1]
}
return DefaultQuchengVersion
}

func GetDefaultConfig() string {
home := zos.GetHomeDir()
return home + "/" + DefaultCfgDir + "/cluster.yaml"
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewCluster() *Cluster {
ClusterCidr: "10.42.0.0/16",
ServiceCidr: "10.43.0.0/16",
Network: "flannel",
QuchengVersion: "stable",
QuchengVersion: common.DefaultQuchengVersion,
DisableIngress: false,
},
M: new(syncmap.Map),
Expand Down Expand Up @@ -126,7 +126,7 @@ func (p *Cluster) GetCreateExtOptions() []types.Flag {
P: &p.QuchengVersion,
V: p.QuchengVersion,
ShortHand: "q",
Usage: "qucheng version: stable, test",
Usage: "qucheng version",
},
{
Name: "domain",
Expand Down
7 changes: 2 additions & 5 deletions internal/pkg/cluster/qucheng.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,9 @@ func (p *Cluster) InstallQuCheng() error {
// helm upgrade -i nginx-ingress-controller bitnami/nginx-ingress-controller -n kube-system
helmargs := []string{"experimental", "helm", "upgrade", "--name", common.DefaultChartName, "--repo", common.DefaultHelmRepoName, "--chart", common.DefaultChartName, "--namespace", common.DefaultSystem, "--set", fmt.Sprintf("ingress.host=console.%s", p.Domain), "--set", "env.APP_DOMAIN=" + p.Domain, "--set", "env.CNE_API_TOKEN=" + token, "--set", "cloud.defaultChannel=" + helmchan}
if helmchan != "stable" {
imagetag := "image.tag=test"
if strings.HasPrefix(p.QuchengVersion, "v") {
imagetag = "image.tag=" + p.QuchengVersion
}
helmargs = append(helmargs, "--set", "env.PHP_DEBUG=2", "--set", imagetag)
helmargs = append(helmargs, "--set", "env.PHP_DEBUG=2")
}
helmargs = append(helmargs, "--version", common.GetVersion(p.QuchengVersion))
output, err = qcexec.Command(os.Args[0], helmargs...).CombinedOutput()
if err != nil {
p.Log.Errorf("upgrade install qucheng web failed: %s", string(output))
Expand Down

0 comments on commit 7dc0adc

Please sign in to comment.