disable service name

This commit is contained in:
w-mj 2023-03-22 21:59:21 +08:00
parent da6c8cf029
commit 3d53d3a83c
No known key found for this signature in database
GPG Key ID: 3A2CB5BE2F835897
5 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,7 @@
## 数据管理 ## 数据管理
- 来自NFS的数据 - 来自NFS的数据
- 来自数据库的数据 - 来自数据库的数据
- 我的数据 WebDav挂载
## 应用管理 ## 应用管理
### 创建应用 ### 创建应用
- 通过在线实验工作台 - 通过在线实验工作台

View File

@ -1,4 +1,4 @@
TAG ?= v1.2.1 TAG ?= v1.2.2
IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:$(TAG) IMAGE_TAG ?= docker.educg.net/cg/k8s-manager:$(TAG)
build: export CGO_ENABLED=0 build: export CGO_ENABLED=0

View File

@ -104,7 +104,7 @@ func GetAppsController(c *gin.Context) {
for i := range appsvm { for i := range appsvm {
a := &appsvm[i] a := &appsvm[i]
a.Status = statusString(a) a.Status = statusString(a)
a.ServiceDisplayName = a.ServiceName() a.ServiceDisplayName = a.URLPrefix()
} }
vm := &AppsViewModel{ vm := &AppsViewModel{
Username: username, Username: username,

View File

@ -25,6 +25,7 @@ type AppModel struct {
CreateTime time.Time CreateTime time.Time
UpdateTime time.Time UpdateTime time.Time
IsPublished bool IsPublished bool
AppType string
} }
func (*AppModel) TableName() string { func (*AppModel) TableName() string {
@ -122,7 +123,9 @@ func (a *AppModel) DeploymentName() string {
func (a *AppModel) GetCommandOrBlack() []string { func (a *AppModel) GetCommandOrBlack() []string {
if strings.TrimSpace(a.Command) != "" { if strings.TrimSpace(a.Command) != "" {
return []string{"/bin/sh", "-c", a.Command} t := a.Command
t = strings.ReplaceAll(t, "$URL_PREFIX", a.URLPrefix())
return []string{"/bin/sh", "-c", t}
} else { } else {
return nil return nil
} }
@ -169,6 +172,10 @@ func (a *AppModel) IngressName() string {
return fmt.Sprintf("%s-ingress", a.NamePrefix()) return fmt.Sprintf("%s-ingress", a.NamePrefix())
} }
func (a *AppModel) URLPrefix() string {
return a.ServiceName()
}
func (a *AppModel) PersistentVolumeName() string { func (a *AppModel) PersistentVolumeName() string {
return a.UserName + "-pv" return a.UserName + "-pv"
} }

View File

@ -111,7 +111,7 @@ func (c *K8sClient) UpdateDeployment(app *model.AppModel) {
Command: app.GetCommandOrBlack(), Command: app.GetCommandOrBlack(),
Env: append(app.GetEnv(), v1.EnvVar{ Env: append(app.GetEnv(), v1.EnvVar{
Name: "URL_PREFIX", Name: "URL_PREFIX",
Value: app.ServiceName(), Value: app.URLPrefix(),
}), }),
VolumeMounts: []v1.VolumeMount{ VolumeMounts: []v1.VolumeMount{
{ {
@ -322,7 +322,7 @@ func (c *K8sClient) UpdateIngress(a *model.AppModel) {
HTTP: &netv1.HTTPIngressRuleValue{ HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{ Paths: []netv1.HTTPIngressPath{
{ {
Path: "/svc/" + a.ServiceName() + "(/|$)(.*)", Path: "/svc/" + a.URLPrefix() + "(/|$)(.*)",
PathType: k8s_manager.UnnamedPointer(netv1.PathTypePrefix), PathType: k8s_manager.UnnamedPointer(netv1.PathTypePrefix),
Backend: netv1.IngressBackend{ Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{ Service: &netv1.IngressServiceBackend{