Skip to content

Commit

Permalink
feat: migrate console to cluster (#176)
Browse files Browse the repository at this point in the history
* fix: modify the default container runtime to Docker

* feat: migrate the console to the cluster deployment
  • Loading branch information
ZhangSetSail authored Nov 29, 2022
1 parent adb8d8b commit 9162e97
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions controllers/handler/app-ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,19 @@ func (a *appui) Before() error {
}

func (a *appui) Resources() []client.Object {
port, ok := a.component.Labels["port"]
if !ok {
port = "7070"
}
p, err := strconv.Atoi(port)
if err != nil {
p = 7070
port = "7070"
log.Error(err, "strconv.Atoi(port)")
}
res := []client.Object{
a.serviceForAppUI(),
a.ingressForAppUI(),
a.serviceForAppUI(int32(p)),
a.ingressForAppUI(port),
a.migrationsJob(),
}

Expand Down Expand Up @@ -261,7 +271,7 @@ func (a *appui) deploymentForAppUI() client.Object {
return deploy
}

func (a *appui) serviceForAppUI() client.Object {
func (a *appui) serviceForAppUI(port int32) client.Object {
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: AppUIName,
Expand All @@ -272,7 +282,7 @@ func (a *appui) serviceForAppUI() client.Object {
Ports: []corev1.ServicePort{
{
Name: "http",
Port: 7070,
Port: port,
TargetPort: intstr.IntOrString{
IntVal: 7070,
},
Expand All @@ -285,11 +295,11 @@ func (a *appui) serviceForAppUI() client.Object {
return svc
}

func (a *appui) ingressForAppUI() client.Object {
func (a *appui) ingressForAppUI(port string) client.Object {
annotations := map[string]string{
"nginx.ingress.kubernetes.io/l4-enable": "true",
"nginx.ingress.kubernetes.io/l4-host": "0.0.0.0",
"nginx.ingress.kubernetes.io/l4-port": "7070",
"nginx.ingress.kubernetes.io/l4-port": port,
}
if k8sutil.GetKubeVersion().AtLeast(utilversion.MustParseSemantic("v1.19.0")) {
return createIngress(AppUIName, a.component.Namespace, annotations, a.labels, AppUIName, "http")
Expand Down

0 comments on commit 9162e97

Please sign in to comment.