Skip to content

Commit 0048d91

Browse files
committed
fix(kube): fix kube path typo
fix kube path typo Signed-off-by: ysicing <[email protected]>
1 parent e2c6cf9 commit 0048d91

File tree

9 files changed

+39
-25
lines changed

9 files changed

+39
-25
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
### Linux 发行版
2020

2121
* **Debian** *11(推荐), 10*
22+
* **Rocky** *9, 8*
2223
* **Ubuntu** *20.04, 18.04*
2324
* **CentOS** *7*
2425

@@ -82,15 +83,15 @@ q init -q edge
8283
8384
```bash
8485
# debian
85-
echo "deb [trusted=yes] https://apt.fury.io/qucheng/ /" | tee /etc/apt/sources.list.d/qcadmin.list
86+
echo "deb [trusted=yes] https://repo.qucheng.com/qucheng/ /" | tee /etc/apt/sources.list.d/qcadmin.list
8687
apt update
8788
apt search qcadmin
8889
apt install qcadmin
8990
# centos7
9091
cat > /etc/yum.repos.d/qcadmin.repo << EOF
9192
[fury]
9293
name=Qucheng Yum Repo
93-
baseurl=https://yum.fury.io/qucheng/
94+
baseurl=https://repo.qucheng.com/qucheng/
9495
enabled=1
9596
gpgcheck=0
9697
EOF
@@ -105,10 +106,15 @@ yum install qcadmin
105106
```bash
106107
# create qucheng cluster
107108
q init
108-
# create a k3s cluster with other cidr
109-
q init --podsubnet 10.42.0.0/16 --svcsubnet 10.43.0.0/16
110-
# custom domain
111-
q init --domain qucheng.example.com
109+
```
110+
111+
### 高级使用
112+
113+
```bash
114+
# step 1. 创建k3s集群
115+
q cluster init
116+
# step 2. 初始化渠成平台
117+
q quickon init
112118
```
113119

114120
## 相关文档

cmd/app/get.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ package app
99
import (
1010
"os"
1111

12+
"github.com/easysoft/qcadmin/common"
13+
1214
"github.com/easysoft/qcadmin/internal/app/debug"
1315
qcexec "github.com/easysoft/qcadmin/internal/pkg/util/exec"
1416
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
@@ -32,7 +34,7 @@ func NewCmdAppGet(f factory.Factory) *cobra.Command {
3234
if err != nil {
3335
return err
3436
}
35-
extargs := []string{"exp", "kubectl", "get", "-o", "wide", "pods,deploy,pvc,svc,ing", "-l", "release=" + appdata.K8Name}
37+
extargs := []string{"exp", "kubectl", "get", "-o", "wide", "pods,deploy,pvc,svc,ing", "-l", "release=" + appdata.K8Name, "--kubeconfig", common.GetDefaultNewKubeConfig()}
3638
// extargs = append(extargs, args...)
3739
return qcexec.CommandRun(os.Args[0], extargs...)
3840
},

cmd/init.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ var (
2525
Use: "init",
2626
Short: "Run this command in order to set up the QuCheng control plane",
2727
}
28-
skip bool
28+
skip bool
29+
appName string
2930
)
3031

3132
func init() {
3233
initCmd.PersistentFlags().BoolVar(&skip, "skip-precheck", false, "skip precheck")
34+
initCmd.PersistentFlags().StringVar(&appName, "app", "zentao", "app name")
3335
}
3436

3537
func newCmdInit(f factory.Factory) *cobra.Command {
@@ -58,13 +60,17 @@ func newCmdInit(f factory.Factory) *cobra.Command {
5860
if name == "native" {
5961
log.Infof("start init native provider")
6062
if err := qcexec.CommandRun(globalToolPath, "cluster", "init", fmt.Sprintf("--debug=%v", globalFlags.Debug)); err != nil {
61-
log.Warnf("init k8s cluster failed, reason: %v", err)
63+
log.Errorf("init k8s cluster failed, reason: %v", err)
6264
return
6365
}
6466
}
6567
if err := qcexec.CommandRun(globalToolPath, "quickon", "init", fmt.Sprintf("--debug=%v", globalFlags.Debug)); err != nil {
66-
log.Warnf("init quickon failed, reason: %v", err)
67-
return
68+
log.Errorf("init quickon failed, reason: %v", err)
69+
return
70+
}
71+
if err := qcexec.CommandRun(globalToolPath, "app", "install", "--name", appName, "--api-useip", fmt.Sprintf("--debug=%v", globalFlags.Debug)); err != nil {
72+
log.Errorf("init quickon failed, reason: %v", err)
73+
return
6874
}
6975
}
7076
return initCmd

internal/pkg/cli/tool/domain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ func domainAdd(f factory.Factory) *cobra.Command {
134134
if err := helmClient.UpdateRepo(); err != nil {
135135
log.Warnf("update repo failed, reason: %v", err)
136136
}
137-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/hack/haogstls/haogs.yaml", common.GetDefaultDataDir()), "-n", common.GetDefaultSystemNamespace(true)).Run(); err != nil {
137+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/hack/haogstls/haogs.yaml", common.GetDefaultDataDir()), "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
138138
log.Warnf("load tls cert for %s failed, reason: %v", common.GetDefaultSystemNamespace(true), err)
139139
} else {
140140
log.Donef("load tls cert for %s success", common.GetDefaultSystemNamespace(true))
141141
}
142-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/hack/haogstls/haogs.yaml", common.GetDefaultDataDir()), "-n", "default").Run(); err != nil {
142+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/hack/haogstls/haogs.yaml", common.GetDefaultDataDir()), "-n", "default", "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
143143
log.Warnf("load tls cert for default failed, reason: %v", err)
144144
} else {
145145
log.Done("load tls cert for default success")

internal/pkg/cluster/qucheng.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ func (p *Cluster) InstallQuCheng() error {
117117
if _, err := os.Stat(defaultTLS); err == nil {
118118
p.Log.StopWait()
119119
p.Log.Done("download tls cert success")
120-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", common.GetDefaultSystemNamespace(true)).Run(); err != nil {
120+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
121121
p.Log.Warnf("load default tls cert failed, reason: %v", err)
122122
} else {
123123
p.Log.Done("load default tls cert success")
124124
}
125-
qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", "default").Run()
125+
qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", "default", "--kubeconfig", common.GetDefaultNewKubeConfig()).Run()
126126
break
127127
}
128128
_, mainDomain := kutil.SplitDomain(p.Domain)

internal/pkg/plugin/plugin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (p *Item) UnInstall() error {
117117
}
118118
} else {
119119
// #nosec
120-
applycmd := qcexec.Command(os.Args[0], "experimental", "kubectl", "delete", "-f", fmt.Sprintf("%s/%s", common.GetDefaultDataDir(), p.Path), "-n", common.GetDefaultSystemNamespace(true))
120+
applycmd := qcexec.Command(os.Args[0], "experimental", "kubectl", "delete", "-f", fmt.Sprintf("%s/%s", common.GetDefaultDataDir(), p.Path), "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig())
121121
if output, err := applycmd.CombinedOutput(); err != nil {
122122
p.log.Errorf("kubectl uninstall %s plugin %s failed: %s", p.Type, p.Name, string(output))
123123
return err
@@ -160,7 +160,7 @@ func (p *Item) Install() error {
160160
}
161161
} else {
162162
// #nosec
163-
applycmd := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/%s", common.GetDefaultDataDir(), p.Path), "-n", common.GetDefaultSystemNamespace(true))
163+
applycmd := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/%s", common.GetDefaultDataDir(), p.Path), "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig())
164164
if output, err := applycmd.CombinedOutput(); err != nil {
165165
p.log.Errorf("kubectl install %s plugin %s failed: %s", p.Type, p.Name, string(output))
166166
return err
@@ -209,7 +209,7 @@ func (p *Item) Upgrade() (err error) {
209209
}
210210
} else {
211211
// #nosec
212-
applycmd := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/%s", common.GetDefaultDataDir(), p.Path), "-n", common.GetDefaultSystemNamespace(true))
212+
applycmd := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", fmt.Sprintf("%s/%s", common.GetDefaultDataDir(), p.Path), "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig())
213213
if output, err := applycmd.CombinedOutput(); err != nil {
214214
p.log.Errorf("kubectl upgrade %s plugin %s failed: %s", p.Type, p.Name, string(output))
215215
return err

internal/pkg/util/httptls/httptls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ func renewCertificate(domain string) error {
8181
coreDomain := fmt.Sprintf("%s.%s.%s", ds[len(ds)-3], ds[len(ds)-2], ds[len(ds)-1])
8282
tlsfile := fmt.Sprintf("https://pkg.qucheng.com/ssl/%s/%s/tls.yaml", mainDomain, coreDomain)
8383
log.Debugf("renew default tls certificate use %s", tlsfile)
84-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", tlsfile, "-n", common.GetDefaultSystemNamespace(true)).Run(); err != nil {
84+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", tlsfile, "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
8585
log.Warnf("load renew tls cert for %s failed, reason: %v", common.GetDefaultSystemNamespace(true), err)
8686
}
8787
log.Debugf("renew ingress tls certificate")
88-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", tlsfile).Run(); err != nil {
88+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", tlsfile, "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
8989
log.Warnf("load renew tls cert for default failed, reason: %v", err)
9090
}
9191
return nil

pkg/qucheng/upgrade/upgrade.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ func Upgrade(flagVersion string, log log.Logger) error {
121121
if _, err := os.Stat(defaultTLS); err == nil {
122122
log.StopWait()
123123
log.Done("download tls cert success")
124-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", common.GetDefaultSystemNamespace(true)).Run(); err != nil {
124+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
125125
log.Warnf("load default tls cert failed, reason: %v", err)
126126
} else {
127127
log.Done("load default tls cert success")
128128
}
129-
qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", "default").Run()
129+
qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", "default", "--kubeconfig", common.GetDefaultNewKubeConfig()).Run()
130130
args := []string{"ingress.tls.enabled=true", "ingress.tls.secretName=tls-haogs-cn"}
131131
values, _ := helm.MergeValues(args)
132132
defaultValue = helm.MergeMaps(defaultValue, values)

pkg/quickon/quickon.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ func (m *Meta) Init() error {
190190
m.log.StartWait(fmt.Sprintf("start issuing domain %s certificate, may take 3-5min", m.Domain))
191191
waittls := time.Now()
192192
for {
193-
if _, err := os.Stat(defaultTLS); err == nil {
193+
if file.CheckFileExists(defaultTLS) {
194194
m.log.StopWait()
195195
m.log.Done("download tls cert success")
196-
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", common.GetDefaultSystemNamespace(true)).Run(); err != nil {
196+
if err := qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", common.GetDefaultSystemNamespace(true), "--kubeconfig", common.GetDefaultNewKubeConfig()).Run(); err != nil {
197197
m.log.Warnf("load default tls cert failed, reason: %v", err)
198198
} else {
199199
m.log.Done("load default tls cert success")
200200
}
201-
qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", "default").Run()
201+
qcexec.Command(os.Args[0], "experimental", "kubectl", "apply", "-f", defaultTLS, "-n", "default", "--kubeconfig", common.GetDefaultNewKubeConfig()).Run()
202202
break
203203
}
204204
_, mainDomain := kutil.SplitDomain(m.Domain)

0 commit comments

Comments
 (0)