mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-06 20:09:44 +00:00
tests/k8s: add utils to get kbs service address
Added functions to return the service host, port or full-qualified HTTP address, respectively, kbs_k8s_svc_host(), kbs_k8s_svc_port(), and kbs_k8s_svc_http_addr(). Fixes #9056 Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
parent
73a8b61c2e
commit
e410aef4fa
@ -160,7 +160,7 @@ function kbs_k8s_deploy() {
|
|||||||
# otherwise the cluster IP.
|
# otherwise the cluster IP.
|
||||||
#
|
#
|
||||||
kbs_k8s_svc_host() {
|
kbs_k8s_svc_host() {
|
||||||
if kubectl get ingress -n "$KBS_NS" | grep -q kbs; then
|
if kubectl get ingress -n "$KBS_NS" 2>/dev/null | grep -q kbs; then
|
||||||
kubectl get ingress kbs -n "$KBS_NS" \
|
kubectl get ingress kbs -n "$KBS_NS" \
|
||||||
-o jsonpath='{.spec.rules[0].host}' 2>/dev/null
|
-o jsonpath='{.spec.rules[0].host}' 2>/dev/null
|
||||||
else
|
else
|
||||||
@ -169,6 +169,31 @@ kbs_k8s_svc_host() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return the kbs service port number. In case ingress is configured
|
||||||
|
# it will return "80", otherwise the pod's service port.
|
||||||
|
#
|
||||||
|
kbs_k8s_svc_port() {
|
||||||
|
if kubectl get ingress -n "$KBS_NS" 2>/dev/null | grep -q kbs; then
|
||||||
|
# Assume served on default HTTP port 80
|
||||||
|
echo "80"
|
||||||
|
else
|
||||||
|
kubectl get svc kbs -n "$KBS_NS" \
|
||||||
|
-o jsonpath='{.spec.ports[0].port}' 2>/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return the kbs service HTTP address (http://host:port).
|
||||||
|
#
|
||||||
|
kbs_k8s_svc_http_addr() {
|
||||||
|
local host
|
||||||
|
local port
|
||||||
|
|
||||||
|
host=$(kbs_k8s_svc_host)
|
||||||
|
port=$(kbs_k8s_svc_port)
|
||||||
|
|
||||||
|
echo "http://${host}:${port}"
|
||||||
|
}
|
||||||
|
|
||||||
# Choose the appropriated ingress handler.
|
# Choose the appropriated ingress handler.
|
||||||
#
|
#
|
||||||
# To add a new handler, create a function named as _handle_ingress_NAME where
|
# To add a new handler, create a function named as _handle_ingress_NAME where
|
||||||
|
Loading…
Reference in New Issue
Block a user