11#! /bin/bash
22
3- # Copyright 2021-2024 Hewlett Packard Enterprise Development LP
3+ # Copyright 2021-2026 Hewlett Packard Enterprise Development LP
44# Other additional copyright holders may be indicated within.
55#
66# The entirety of this work is licensed under the Apache License,
2222set -e
2323set -o pipefail
2424
25+ usage () {
26+ echo " Usage: $0 [--no-argocd] <CMD>"
27+ echo
28+ echo " Options:"
29+ echo " --no-argocd Deploy without ArgoCD using the legacy overlay."
30+ echo " Installs cert-manager, mpi-operator, and lustre"
31+ echo " operators directly instead of via ArgoCD."
32+ echo
33+ echo " Commands:"
34+ echo " create Create a new KIND cluster."
35+ echo " destroy Destroy the existing KIND cluster."
36+ echo " reset Destroy the existing KIND cluster and create"
37+ echo " a new cluster. Note: locally-built images are"
38+ echo " not automatically reloaded -- re-run 'push' or"
39+ echo " './nnf-deploy make kind-push' after a reset."
40+ echo " push Execute 'make kind-push' in each submodule dir."
41+ echo " argocd_attach <new_password>"
42+ echo " Login to the argocd instance and set the new"
43+ echo " password. Then add the Git repo to the instance."
44+ echo " argocd_login <new_password>"
45+ echo " Only do the login to the argocd instance and set"
46+ echo " the password."
47+ echo " argocd_add_git_repo Only add the git repo to the argocd instance."
48+ echo " help Show this help message."
49+ }
50+
51+ NO_ARGOCD=
52+ while [[ " $1 " == --* ]]; do
53+ case " $1 " in
54+ --no-argocd) NO_ARGOCD=1 ;;
55+ --help) usage; exit 0 ;;
56+ * ) echo " Unknown option: $1 " ; exit 1 ;;
57+ esac
58+ shift
59+ done
60+
2561CMD=" $1 "
2662shift
2763
@@ -32,6 +68,22 @@ function clear_mock_fs {
3268 fi
3369}
3470
71+ # Create the integration test user on KIND Rabbit worker nodes.
72+ # The nnf-integration-test suite verifies that UID/GID exist on Rabbit nodes
73+ # (defaults: UID=1051 GID=1052, the flux user). Without this, the BeforeSuite
74+ # check fails and no tests run.
75+ function create_test_user {
76+ local uid=${NNF_USER_ID:- 1051}
77+ local gid=${NNF_GROUP_ID:- 1052}
78+
79+ echo " Creating test user (UID=$uid , GID=$gid ) on KIND Rabbit worker nodes..."
80+ for node in $( kind get nodes | grep -v control-plane) ; do
81+ # Create group and user if they don't already exist
82+ docker exec " $node " sh -c " getent group $gid >/dev/null 2>&1 || groupadd -g $gid testgroup"
83+ docker exec " $node " sh -c " getent passwd $uid >/dev/null 2>&1 || useradd -u $uid -g $gid -M -s /bin/bash testuser"
84+ done
85+ }
86+
3587function create_cluster {
3688 CONFIG=kind-config.yaml
3789
92144
93145 kind create cluster --wait 60s --image=kindest/node:v1.31.2 --config $CONFIG
94146
147+ # Inject any corporate/IT-installed CA certificates from the macOS system
148+ # keychain into the KIND nodes. These certs live in System.keychain (not the
149+ # Apple-shipped roots) and are typically added by corporate TLS inspection
150+ # proxies (e.g. Zscaler). On machines without such a proxy this is a no-op.
151+ if [[ " $( uname) " == " Darwin" ]]; then
152+ local CORP_CAS=/tmp/kind-corp-cas.pem
153+ security export -k /Library/Keychains/System.keychain -t certs -f pemseq -o " $CORP_CAS " 2> /dev/null || true
154+ if [[ -s " $CORP_CAS " ]]; then
155+ echo " Injecting corporate CA certificates into KIND nodes..."
156+ for node in $( kind get nodes) ; do
157+ docker cp " $CORP_CAS " " $node :/usr/local/share/ca-certificates/corp-cas.crt"
158+ docker exec " $node " update-ca-certificates
159+ docker exec " $node " systemctl restart containerd
160+ done
161+ fi
162+ rm -f " $CORP_CAS "
163+ fi
164+
95165 # Use the same init routines that we use on real hardware.
96166 # This applies taints and labels to rabbit nodes, and installs other
97167 # services that rabbit software requires.
168+ if [[ -n $NO_ARGOCD ]]; then
169+ echo " Deploying without ArgoCD (legacy overlay mode)..."
170+ cp config/overlay-legacy.yaml-template overlay-legacy.yaml
171+ fi
98172 ./nnf-deploy init
173+
174+ # Create the test user on Rabbit nodes for integration tests
175+ create_test_user
99176}
100177
101178function have_argocd {
@@ -180,23 +257,7 @@ function push_submodules {
180257 done
181258}
182259
183- usage () {
184- echo " Usage: $0 <CMD>"
185- echo
186- echo " create Create a new KIND cluster."
187- echo " destroy Destroy the existing KIND cluster."
188- echo " reset Destroy the existing KIND cluster and create"
189- echo " a new cluster."
190- echo " push Execute 'make kind-push' in each submodule dir."
191- echo " argocd_attach <new_password>"
192- echo " Login to the argocd instance and set the new"
193- echo " password. Then add the Git repo to the instance."
194- echo " argocd_login <new_password>"
195- echo " Only do the login to the argocd instance and set"
196- echo " the password."
197- echo " argocd_add_git_repo Only add the git repo to the argocd instance."
198260
199- }
200261
201262if [[ " $CMD " == " create" ]]; then
202263 create_cluster
@@ -213,6 +274,8 @@ elif [[ "$CMD" == "argocd_login" ]]; then
213274 argocd_login " $* "
214275elif [[ " $CMD " == " argocd_add_git_repo" ]]; then
215276 argocd_add_git_repo
277+ elif [[ " $CMD " == " help" || " $CMD " == " --help" ]]; then
278+ usage
216279else
217280 usage
218281 exit 1
0 commit comments