4040kind create cluster || echo " cluster already exists, continuing..."
4141kubectl wait --for=jsonpath=' {.status.phase}' =Active --timeout=1s namespace/${NAMESPACE}
4242
43- # build image for loading local data via NetBox API
44- cd ./kind/load-data-job && docker build -t netbox-load-local-data:1.0 --no-cache --progress=plain -f ./dockerfile . && cd -
45- # load local images
46- declare -a Local_Images=( \
47- " netbox-load-local-data:1.0" \
48- )
49- for img in " ${Local_Images[@]} " ; do
50- kind load docker-image " $img "
51- done
52-
5343# load remote images
5444if [[ " ${VERSION} " == " 3.7.8" ]] ; then
5545 echo " Using version ${VERSION} "
@@ -64,17 +54,11 @@ if [[ "${VERSION}" == "3.7.8" ]] ;then
6454 )
6555 NETBOX_HELM_CHART=" https://github.com/netbox-community/netbox-chart/releases/download/netbox-5.0.0-beta5/netbox-5.0.0-beta5.tgz"
6656
67- # # perform patching, as we need different demo data and adapt to the database schema
68- # # to avoid accidental check-in of the files, the base file is renamed to xx.orig.yy, and the xx.yy is added to .gitignore
6957 # patch load-data.sh
7058 sed ' s/netbox-demo-v4.1.sql/netbox-demo-v3.7.sql/g' $( dirname " $0 " ) /load-data-job/load-data.orig.sh > $( dirname " $0 " ) /load-data-job/load-data.sh && chmod +x $( dirname " $0 " ) /load-data-job/load-data.sh
7159
72- # # patch local-demo-data.sql
73- # sed \
74- # -e "s/public.extras_customfield_object_types (id, customfield_id, objecttype_id)/public.extras_customfield_content_types (id, customfield_id, contenttype_id)/g" \
75- # -e 's/related_object_type_id/object_type_id/g' \
76- # -e 's/, comments, \"unique\", related_object_filter//g' \
77- # -e "s/, '', false, NULL//g" $(dirname "$0")/load-data-job/local-demo-data.orig.sql > $(dirname "$0")/load-data-job/local-demo-data.sql
60+ # patch dockerfile (See README at https://github.com/netbox-community/pynetbox for the supported version matrix)
61+ sed ' s/RUN pip install -Iv pynetbox==7.4.1/RUN pip install -Iv pynetbox==7.3.4/g' $( dirname " $0 " ) /load-data-job/dockerfile.orig > $( dirname " $0 " ) /load-data-job/dockerfile
7862elif [[ " ${VERSION} " == " 4.0.11" ]] ; then
7963 echo " Using version ${VERSION} "
8064 # need to align with netbox-chart otherwise the creation of the cluster will hang
@@ -90,11 +74,8 @@ elif [[ "${VERSION}" == "4.0.11" ]] ;then
9074
9175 # patch load-data.sh
9276 sed ' s/netbox-demo-v4.1.sql/netbox-demo-v4.0.sql/g' $( dirname " $0 " ) /load-data-job/load-data.orig.sh > $( dirname " $0 " ) /load-data-job/load-data.sh && chmod +x $( dirname " $0 " ) /load-data-job/load-data.sh
93-
94- # # patch local-demo-data.sql
95- # sed \
96- # -e "s/comments, \"unique\", related_object_filter)/comments)/g" \
97- # -e "s/'', false, NULL);/'');/g" $(dirname "$0")/load-data-job/local-demo-data.orig.sql > $(dirname "$0")/load-data-job/local-demo-data.sql
77+
78+ cp $( dirname " $0 " ) /load-data-job/dockerfile.orig $( dirname " $0 " ) /load-data-job/dockerfile
9879elif [[ " ${VERSION} " == " 4.1.8" ]] ; then
9980 echo " Using version ${VERSION} "
10081 # need to align with netbox-chart otherwise the creation of the cluster will hang
@@ -107,8 +88,10 @@ elif [[ "${VERSION}" == "4.1.8" ]] ;then
10788 " ghcr.io/zalando/spilo-16:3.2-p3" \
10889 )
10990
91+ # create load-data.sh
11092 cp $( dirname " $0 " ) /load-data-job/load-data.orig.sh $( dirname " $0 " ) /load-data-job/load-data.sh
111- # cp $(dirname "$0")/load-data-job/local-demo-data.orig.sql $(dirname "$0")/load-data-job/local-demo-data.sql
93+
94+ cp $( dirname " $0 " ) /load-data-job/dockerfile.orig $( dirname " $0 " ) /load-data-job/dockerfile
11295else
11396 echo " Unknown version ${VERSION} "
11497 exit 1
@@ -119,6 +102,16 @@ for img in "${Remote_Images[@]}"; do
119102 kind load docker-image " $img "
120103done
121104
105+ # build image for loading local data via NetBox API
106+ cd ./kind/load-data-job && docker build -t netbox-load-local-data:1.0 --no-cache --progress=plain -f ./dockerfile . && cd -
107+ # load local images
108+ declare -a Local_Images=( \
109+ " netbox-load-local-data:1.0" \
110+ )
111+ for img in " ${Local_Images[@]} " ; do
112+ kind load docker-image " $img "
113+ done
114+
122115# install helm charts
123116helm upgrade --install --namespace=" ${NAMESPACE} " postgres-operator \
124117https://opensource.zalando.com/postgres-operator/charts/postgres-operator/postgres-operator-1.12.2.tgz
@@ -145,3 +138,7 @@ kubectl rollout status --namespace="${NAMESPACE}" deployment netbox
145138kubectl create job netbox-load-local-data --image=netbox-load-local-data:1.0
146139kubectl wait --namespace=" ${NAMESPACE} " --timeout=600s --for=condition=complete job/netbox-load-local-data
147140docker rmi netbox-load-local-data:1.0
141+
142+ # clean up
143+ rm $( dirname " $0 " ) /load-data-job/load-data.sh
144+ rm $( dirname " $0 " ) /load-data-job/dockerfile
0 commit comments