Explorar o código

Implemented IngressIP for cluster_handler list clusters

jnfrati %!s(int64=5) %!d(string=hai) anos
pai
achega
e747d5c319
Modificáronse 1 ficheiros con 24 adicións e 0 borrados
  1. 24 0
      server/api/cluster_handler.go

+ 24 - 0
server/api/cluster_handler.go

@@ -7,6 +7,8 @@ import (
 
 	"github.com/go-chi/chi"
 	"github.com/porter-dev/porter/internal/forms"
+	"github.com/porter-dev/porter/internal/kubernetes"
+	"github.com/porter-dev/porter/internal/kubernetes/domain"
 	"github.com/porter-dev/porter/internal/models"
 )
 
@@ -108,6 +110,28 @@ func (app *App) HandleListProjectClusters(w http.ResponseWriter, r *http.Request
 	extClusters := make([]*models.ClusterExternal, 0)
 
 	for _, cluster := range clusters {
+		form := &forms.K8sForm{
+			OutOfClusterConfig: &kubernetes.OutOfClusterConfig{
+				Repo:              app.Repo,
+				DigitalOceanOAuth: app.DOConf,
+				Cluster:           cluster,
+			},
+		}
+
+		var agent *kubernetes.Agent
+
+		if app.ServerConf.IsTesting {
+			agent = app.TestAgents.K8sAgent
+		} else {
+			agent, _ = kubernetes.GetAgentOutOfClusterConfig(form.OutOfClusterConfig)
+		}
+
+		endpoint, found, _ := domain.GetNGINXIngressServiceIP(agent.Clientset)
+
+		if found {
+			cluster.IngressIP = endpoint
+		}
+
 		extClusters = append(extClusters, cluster.Externalize())
 	}