Skip to content

Commit

Permalink
Merge pull request #7 from yudong2015/rp_k8s_dev_20190410
Browse files Browse the repository at this point in the history
return status of rp_k8s service
  • Loading branch information
yudong2015 authored Apr 16, 2019
2 parents 951669f + af96acb commit 7af3adb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/service/runtime_provider/kubernetes_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import (
"openpitrix.io/openpitrix/pkg/util/stringutil"
)

const (
Type = "type"
ExternalIp = "external_ip"
)

var (
NamespaceReg = `^[a-z]([-a-z0-9]*[a-z0-9])?$`
NamespaceRegExp = regexp.MustCompile(NamespaceReg)
Expand Down Expand Up @@ -181,10 +186,16 @@ func (p *KubeHandler) describeAdditionalInfo(namespace string, cluster *models.C
return err
}

additionalInfo[t][i]["type"] = string(service.Spec.Type)
additionalInfo[t][i][Type] = string(service.Spec.Type)
additionalInfo[t][i]["cluster_ip"] = service.Spec.ClusterIP
if service.Status.LoadBalancer.Ingress != nil && len(service.Status.LoadBalancer.Ingress) != 0 {
additionalInfo[t][i]["external_ip"] = service.Status.LoadBalancer.Ingress[0].IP
additionalInfo[t][i][ExternalIp] = service.Status.LoadBalancer.Ingress[0].IP
} else {
if additionalInfo[t][i][Type] == "LoadBalancer" {
additionalInfo[t][i][ExternalIp] = "pending"
} else {
additionalInfo[t][i][ExternalIp] = "none"
}
}

ports := []string{}
Expand Down

0 comments on commit 7af3adb

Please sign in to comment.