@@ -9,11 +9,25 @@ if [ ! -f "$nodesConfigFile" ]; then
99 exit 1
1010fi
1111
12- # Generate a random namespace name
13- namespace=" openshift-node-joiner-$( tr -dc ' [:lower:]' < /dev/urandom | head -c 10) "
12+ # Setup a cleanup function to ensure to remove the temporary
13+ # file when the script will be completed.
14+ cleanup () {
15+ if [ -f " $pullSecretFile " ]; then
16+ echo " Removing temporary file $pullSecretFile "
17+ rm " $pullSecretFile "
18+ fi
19+ }
20+ trap cleanup EXIT TERM
21+
22+ # Retrieve the pullsecret and store it in a temporary file.
23+ pullSecretFile=$( mktemp -p " /tmp" -t " nodejoiner-XXXXXXXXXX" )
24+ oc get secret -n openshift-config pull-secret -o jsonpath=' {.data.\.dockerconfigjson}' | base64 -d > " $pullSecretFile "
25+
26+ # Extract the baremetal-installer image pullspec from the current cluster.
27+ nodeJoinerPullspec=$( oc adm release info --image-for=baremetal-installer --registry-config=" $pullSecretFile " )
1428
15- # Extract the installer image pullspec and release version .
16- nodeJoinerPullspec =$( oc get is installer -n openshift -o=jsonpath= ' {.spec.tags[0].from.name} ' )
29+ # Use the same random temp file suffix for the namespace .
30+ namespace =$( echo " openshift-node-joiner- ${pullSecretFile #/ tmp / nodejoiner-} " | tr ' [:upper:] ' ' [:lower:] ' )
1731
1832# Create the namespace to run the node-joiner, along with the required roles and bindings.
1933staticResources=$( cat << EOF
@@ -69,7 +83,7 @@ echo "$staticResources" | oc apply -f -
6983# Generate a configMap to store the user configuration
7084oc create configmap nodes-config --from-file=nodes-config.yaml=" ${nodesConfigFile} " -n " ${namespace} " -o yaml --dry-run=client | oc apply -f -
7185
72- # Runt the node-joiner pod to generate the ISO
86+ # Run the node-joiner pod to generate the ISO
7387nodeJoinerPod=$( cat << EOF
7488apiVersion: v1
7589kind: Pod
0 commit comments