diff --git a/.gitignore b/.gitignore index 52b66b4..74092de 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ logs/ /deployments/k8s/mod.yaml /etc /deployments/.ixia-c-config.yaml +/deployments/k8s/manifests/.ixia-c-b2b-eth0.yaml \ No newline at end of file diff --git a/deployments/k8s/manifests/ixia-c-b2b-eth0.yaml b/deployments/k8s/manifests/ixia-c-b2b-eth0.yaml index c01ddc0..ee4d4a8 100644 --- a/deployments/k8s/manifests/ixia-c-b2b-eth0.yaml +++ b/deployments/k8s/manifests/ixia-c-b2b-eth0.yaml @@ -34,7 +34,7 @@ items: - args: - --accept-eula - --debug - image: ghcr.io/open-traffic-generator/keng-controller:local + image: $(configq .images[0].path):$(configq .images[0].tag) imagePullPolicy: IfNotPresent name: keng-controller volumeMounts: @@ -45,7 +45,7 @@ items: - -http-server - https://localhost:8443 - --debug - image: ghcr.io/open-traffic-generator/otg-gnmi-server:local + image: $(configq .images[1].path):$(configq .images[1].tag) imagePullPolicy: IfNotPresent name: otg-gnmi-server ports: @@ -77,7 +77,7 @@ items: value: "5555" - name: ARG_CORE_LIST value: 1 1 1 - image: ghcr.io/open-traffic-generator/ixia-c-traffic-engine:local + image: $(configq .images[2].path):$(configq .images[2].tag) imagePullPolicy: IfNotPresent name: otg-port-eth1-traffic-engine securityContext: @@ -85,7 +85,7 @@ items: - env: - name: INTF_LIST value: eth0 - image: ghcr.io/open-traffic-generator/ixia-c-protocol-engine:local + image: $(configq .images[3].path):$(configq .images[3].tag) imagePullPolicy: IfNotPresent name: otg-port-eth1-protocol-engine securityContext: @@ -110,7 +110,7 @@ items: value: "5555" - name: ARG_CORE_LIST value: 1 1 1 - image: ghcr.io/open-traffic-generator/ixia-c-traffic-engine:local + image: $(configq .images[2].path):$(configq .images[2].tag) imagePullPolicy: IfNotPresent name: otg-port-eth2-traffic-engine securityContext: @@ -118,7 +118,7 @@ items: - env: - name: INTF_LIST value: eth0 - image: ghcr.io/open-traffic-generator/ixia-c-protocol-engine:local + image: $(configq .images[3].path):$(configq .images[3].tag) imagePullPolicy: IfNotPresent name: otg-port-eth2-protocol-engine securityContext: diff --git a/do.sh b/do.sh index 0e0a0ca..64ca3e1 100755 --- a/do.sh +++ b/do.sh @@ -1136,10 +1136,41 @@ k8s_namespace() { grep namespace deployments/k8s/manifests/${1}.yaml -m 1 | cut -d \: -f2 | cut -d \ -f 2 } +eval_config_manifest() { + file={1} + new_file=".{1}" + get_yq \ + && rm -rf ${new_file} + + # avoid splitting based on whitespace + IFS='' + # mix of cat and echo is used to ensure the input file has + # at least one newline before EOF, otherwise read will not + # provide last line + { cat ${file}; echo; } | while read line; do + # replace all double-quotes with single quotes + line=$(echo "${line}" | sed s#\"#\'#g) + # and revert them back to double-quotes post eval; + # this will result in converting all single-quotes + # to double-quotes regardless of whether they were + # originally double-quotes, but hopefully this won't + # be an issue + # this workaround was put in place because eval gets + # rid of double-quotes + eval echo \"$line\" | sed s#\'#\"#g >> ${new_file} + done + # restore default IFS + unset IFS + cat ${new_file} +} + create_ixia_c_k8s() { echo "Creating K8S ${1} topology ..." ns=$(k8s_namespace ${1}) - kubectl apply -f deployments/k8s/manifests/${1}.yaml \ + cd deployments/k8s/manifests \ + && eval_config_manifest {1}.yaml \ + && kubectl apply -f .${1}.yaml \ + && cd ../../.. \ && wait_for_pods ${ns} \ && kubectl get pods -A \ && kubectl get services -A \ @@ -1150,7 +1181,7 @@ create_ixia_c_k8s() { rm_ixia_c_k8s() { echo "Removing K8S ${1} topology ..." ns=$(k8s_namespace ${1}) - kubectl delete -f deployments/k8s/manifests/${1}.yaml \ + kubectl delete -f deployments/k8s/manifests/.${1}.yaml \ && wait_for_no_namespace ${ns} }