UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit c3ef764d authored by Micah Nagel's avatar Micah Nagel
Browse files

Merge branch...

Merge branch '528-add-ability-to-the-install_flux-sh-script-to-use-existing-registry-secret-if-it-exists' into 'master'

Added -s argument that attempts to use existing private-registry secret

Closes #528

See merge request platform-one/big-bang/bigbang!966
parents bcd09450 a407df36
No related branches found
No related tags found
2 merge requests!1386Master,!966Added -s argument that attempts to use existing private-registry secret
Pipeline #554464 passed with warnings
......@@ -21,14 +21,27 @@ WAIT_TIMEOUT=300
function help {
cat << EOF
usage: $(basename "$0") <arguments>
-h|--help - print this help message and exit
-r|--registry-url - (optional, default: registry1.dso.mil) registry url to use for flux installation
-u|--registry-username - (required) registry username to use for flux installation
-p|--registry-password - (required) registry password to use for flux installation
-w|--wait-timeout - (optional, default: 120) how long to wait; in seconds, for each key flux resource component
-h|--help - print this help message and exit
-r|--registry-url - (optional, default: registry1.dso.mil) registry url to use for flux installation
-s|--use-existing-secret - (optional) use existing private-registry secret
-u|--registry-username - (required) registry username to use for flux installation
-p|--registry-password - (required) registry password to use for flux installation
-w|--wait-timeout - (optional, default: 120) how long to wait; in seconds, for each key flux resource component
EOF
}
# script check for existing pull secret
function check_secrets {
if kubectl get secrets/"$FLUX_SECRET" -n flux-system > /dev/null 2>&1;
then
#the secret exists
FLUX_SECRET_EXISTS=0
else
#the secret does not exist
FLUX_SECRET_EXISTS=1
fi
}
#
# cli parsing
#
......@@ -90,6 +103,11 @@ while (( "$#" )); do
-h|--help)
help; exit 0
;;
# Check if private-registry secret exists
-s|--use-existing-secret)
check_secrets;
shift
;;
# unsupported flags
-*|--*=)
echo "Error: Unsupported flag $1" >&2
......@@ -103,31 +121,33 @@ while (( "$#" )); do
esac
done
# check required arguments
if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_PASSWORD" ]; then
help; exit 1
fi
# check if secret exists
if [ -z "$FLUX_SECRET_EXISTS" ] || [ "$FLUX_SECRET_EXISTS" -eq 1 ]; then
# check required arguments
if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_PASSWORD" ]; then
help; exit 1
fi
# debug print cli args
echo "REGISTRY_URL: $REGISTRY_URL"
echo "REGISTRY_USERNAME: $REGISTRY_USERNAME"
# debug print cli args
echo "REGISTRY_URL: $REGISTRY_URL"
echo "REGISTRY_USERNAME: $REGISTRY_USERNAME"
kubectl create namespace flux-system || true
echo "Creating secret $FLUX_SECRET in namespace flux-system"
kubectl create secret docker-registry "$FLUX_SECRET" -n flux-system \
--docker-server="$REGISTRY_URL" \
--docker-username="$REGISTRY_USERNAME" \
--docker-password="$REGISTRY_PASSWORD" \
--docker-email="$REGISTRY_EMAIL" \
--dry-run=client -o yaml | kubectl apply -n flux-system -f -
fi
#
# install flux
#
kubectl create namespace flux-system || true
echo "Creating secret $FLUX_SECRET in namespace flux-system"
kubectl create secret docker-registry "$FLUX_SECRET" -n flux-system \
--docker-server="$REGISTRY_URL" \
--docker-username="$REGISTRY_USERNAME" \
--docker-password="$REGISTRY_PASSWORD" \
--docker-email="$REGISTRY_EMAIL" \
--dry-run=client -o yaml | kubectl apply -n flux-system -f -
echo "Installing flux from kustomization"
kustomize build "$FLUX_KUSTOMIZATION" | sed "s/registry1.dso.mil/${REGISTRY_URL}/g" | kubectl apply -f -
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment