@@ -27,8 +27,8 @@ source "${REPO_ROOT}/hack/ensure-kubectl.sh"
27
27
on_exit () {
28
28
# release IPClaim
29
29
echo " Releasing IP claims"
30
- kubectl --kubeconfig=" ${KUBECONFIG} " delete " $( append_api_group ipclaim) " " ${IPCLAIM_NAME } " || true
31
- kubectl --kubeconfig=" ${KUBECONFIG} " delete " $( append_api_group ipclaim) " " ${WORKLOAD_IPCLAIM_NAME} " || true
30
+ kubectl --kubeconfig=" ${KUBECONFIG} " delete " ipclaim.ipam.metal3.io " " ${CONTROL_PLANE_IPCLAIM_NAME } " || true
31
+ kubectl --kubeconfig=" ${KUBECONFIG} " delete " ipclaim.ipam.metal3.io " " ${WORKLOAD_IPCLAIM_NAME} " || true
32
32
33
33
# kill the VPN
34
34
docker kill vpn
@@ -73,18 +73,14 @@ docker logs vpn
73
73
# Sleep to allow vpn container to start running
74
74
sleep 30
75
75
76
- function append_api_group() {
77
- resource=$1
78
- echo " ${resource} .ipam.metal3.io"
79
- }
80
76
81
77
function kubectl_get_jsonpath() {
82
78
local OBJECT_KIND=" ${1} "
83
79
local OBJECT_NAME=" ${2} "
84
80
local JSON_PATH=" ${3} "
85
81
local n=0
86
82
until [ $n -ge 30 ]; do
87
- OUTPUT=$( kubectl --kubeconfig=" ${KUBECONFIG} " get " $( append_api_group " $ {OBJECT_KIND}" ) " " ${OBJECT_NAME} " -o=jsonpath=" ${JSON_PATH} " )
83
+ OUTPUT=$( kubectl --kubeconfig=" ${KUBECONFIG} " get " ${OBJECT_KIND} .ipam.metal3.io " " ${OBJECT_NAME} " -o=jsonpath=" ${JSON_PATH} " )
88
84
if [[ " ${OUTPUT} " != " " ]]; then
89
85
break
90
86
fi
@@ -101,20 +97,27 @@ function kubectl_get_jsonpath() {
101
97
fi
102
98
}
103
99
100
+ function claim_ip() {
101
+ IPCLAIM_NAME=" $1 "
102
+ export IPCLAIM_NAME
103
+ envsubst < " ${REPO_ROOT} /hack/ipclaim-template.yaml" | kubectl --kubeconfig=" ${KUBECONFIG} " create -f - 1>&2
104
+ IPADDRESS_NAME=$( kubectl_get_jsonpath ipclaim " ${IPCLAIM_NAME} " ' {@.status.address.name}' )
105
+ kubectl --kubeconfig=" ${KUBECONFIG} " get " ipaddresses.ipam.metal3.io" " ${IPADDRESS_NAME} " -o=jsonpath=' {@.spec.address}'
106
+ }
107
+
108
+ export KUBECONFIG=" /root/ipam-conf/capv-services.conf"
109
+
110
+ make envsubst
111
+
104
112
# Retrieve an IP to be used as the kube-vip IP
105
- KUBECONFIG=" /root/ipam-conf/capv-services.conf"
106
- IPCLAIM_NAME=" ip-claim-$( openssl rand -hex 20) "
107
- sed " s/IPCLAIM_NAME/${IPCLAIM_NAME} /" " ${REPO_ROOT} /hack/ipclaim-template.yaml" | kubectl --kubeconfig=${KUBECONFIG} create -f -
108
- IPADDRESS_NAME=$( kubectl_get_jsonpath ipclaim " ${IPCLAIM_NAME} " ' {@.status.address.name}' )
109
- CONTROL_PLANE_ENDPOINT_IP=$( kubectl --kubeconfig=${KUBECONFIG} get " $( append_api_group ipaddresses) " " ${IPADDRESS_NAME} " -o=jsonpath=' {@.spec.address}' )
113
+ CONTROL_PLANE_IPCLAIM_NAME=" ip-claim-$( openssl rand -hex 20) "
114
+ CONTROL_PLANE_ENDPOINT_IP=$( claim_ip " ${CONTROL_PLANE_IPCLAIM_NAME} " )
110
115
export CONTROL_PLANE_ENDPOINT_IP
111
116
echo " Acquired Control Plane IP: $CONTROL_PLANE_ENDPOINT_IP "
112
117
113
118
# Retrieve an IP to be used for the workload cluster in v1a3/v1a4 -> v1b1 upgrade tests
114
119
WORKLOAD_IPCLAIM_NAME=" workload-ip-claim-$( openssl rand -hex 20) "
115
- sed " s/IPCLAIM_NAME/${WORKLOAD_IPCLAIM_NAME} /" " ${REPO_ROOT} /hack/ipclaim-template.yaml" | kubectl --kubeconfig=${KUBECONFIG} create -f -
116
- WORKLOAD_IPADDRESS_NAME=$( kubectl_get_jsonpath ipclaim " ${WORKLOAD_IPCLAIM_NAME} " ' {@.status.address.name}' )
117
- WORKLOAD_CONTROL_PLANE_ENDPOINT_IP=$( kubectl --kubeconfig=${KUBECONFIG} get " $( append_api_group ipaddresses) " " ${WORKLOAD_IPADDRESS_NAME} " -o=jsonpath=' {@.spec.address}' )
120
+ WORKLOAD_CONTROL_PLANE_ENDPOINT_IP=$( claim_ip " ${WORKLOAD_IPCLAIM_NAME} " )
118
121
export WORKLOAD_CONTROL_PLANE_ENDPOINT_IP
119
122
echo " Acquired Workload Cluster Control Plane IP: $WORKLOAD_CONTROL_PLANE_ENDPOINT_IP "
120
123
0 commit comments