X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fhelm%2Fhelm.go;h=157a117f61b2605e868d5efca2862ae8489c63ae;hb=refs%2Fchanges%2F95%2F2995%2F4;hp=886d015c5512f055969266d9dcd357422d87815f;hpb=aca8f3cfeaa7e6af5245c2f0370ef517254d62f2;p=ric-plt%2Fappmgr.git diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index 886d015..157a117 100755 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -30,10 +30,10 @@ import ( "strings" "time" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/appmgr" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/cm" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/models" - "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/util" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/appmgr" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/cm" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/models" + "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/util" ) type Helm struct { @@ -214,15 +214,30 @@ func (h *Helm) GetAddress(out string) (ip, port string) { return } -func (h *Helm) GetEndpointInfo(name string) (ip string, port int) { +func (h *Helm) GetEndpointInfo(name string) (svc string, port int) { + port = 4560 // Default ns := h.cm.GetNamespace("") - args := fmt.Sprintf(" get endpoints -o=jsonpath='{.subsets[*].addresses[*].ip}' service-%s-%s-rmr -n %s", ns, name, ns) + args := fmt.Sprintf(" get service -n ricxapp service-%s-%s-rmr -o json", ns, name) out, err := util.KubectlExec(args) if err != nil { - return + return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), 4560 } - appmgr.Logger.Info("Endpoint IP address of %s: %s", name, string(out)) - return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), 4560 + appmgr.Logger.Debug("Endpoint IP address of %s: %s", name, string(out)) + + v, err := h.cm.ParseJson(string(out)) + if err != nil { + return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), 4560 + } + + for _, p := range v.GetArray("spec", "ports") { + if string(p.GetStringBytes("name")) == "rmrdata" { + port = int(p.GetInt("port")) + break + } + } + appmgr.Logger.Info("service-%s-%s-rmr.%s %d", ns, name, ns, port) + + return fmt.Sprintf("service-%s-%s-rmr.%s", ns, name, ns), port } func (h *Helm) GetNames(out string) (names []string, err error) {