-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare test cluster #38
Changes from all commits
5648fed
a32b020
345a4f6
3c38ee6
8614a17
3c3dbd1
c3156e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Test clusters | ||
|
||
The ArangoDB operator is tested on various types of kubernetes clusters. | ||
|
||
To prepare a cluster for running the ArangoDB operator tests, | ||
do the following: | ||
|
||
- Create a `kubectl` config file for accessing the cluster. | ||
- Use that config file. | ||
- Run `./scripts/kube_configure_test_cluster.sh`. This creates a `ConfigMap` | ||
named `arango-operator-test` in the `kube-system` namespace containing the | ||
following environment variables. | ||
|
||
```bash | ||
REQUIRE_LOCAL_STORAGE=1 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Sets the configuration of the cluster in a ConfigMap in kube-system. | ||
|
||
cluster=$(kubectl config current-context) | ||
echo "Configuring cluster $cluster" | ||
|
||
read -p "Does the cluster require local storage (Y/n)? " answer | ||
case ${answer:0:1} in | ||
n|N ) | ||
REQUIRE_LOCAL_STORAGE= | ||
;; | ||
* ) | ||
REQUIRE_LOCAL_STORAGE=1 | ||
;; | ||
esac | ||
|
||
mapname="arango-operator-test" | ||
configfile=$(mktemp) | ||
cat <<EOF > $configfile | ||
REQUIRE_LOCAL_STORAGE=${REQUIRE_LOCAL_STORAGE} | ||
EOF | ||
kubectl delete configmap $mapname -n kube-system --ignore-not-found | ||
kubectl create configmap $mapname -n kube-system --from-env-file=$configfile || exit 1 | ||
|
||
echo Stored configuration: | ||
cat $configfile | ||
rm $configfile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Create the local storage in the cluster if the cluster needs it. | ||
|
||
NS=$1 | ||
|
||
if [ -z $NS ]; then | ||
echo "Specify a namespace argument" | ||
exit 1 | ||
fi | ||
|
||
# Fetch cluster config | ||
mapname="arango-operator-test" | ||
eval $(kubectl get configmap $mapname -n kube-system --ignore-not-found --template='{{ range $key, $value := .data }}export {{$key}}={{$value}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. qefs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If eval does not return 0 your program ends here. |
||
{{ end }}') | ||
|
||
if [ "${REQUIRE_LOCAL_STORAGE}" = "1" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (( REQUIRE_LOCAL_STORAGE == 1)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You had that in another script before and it broke CI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It must be bash and not dash or some other shell:) Other than that it is standard for years. |
||
echo "Preparing local storage" | ||
kubectl apply -n $NS -f examples/arango-local-storage.yaml || exit 1 | ||
else | ||
echo "No local storage needed for this cluster" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TRAP cleanup_function EXIT
to clean up tempfileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use read to store it in a variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be a file (for
--from-env-file
to work)Since it is temp, I'm not that worried about it being left behind a few times. In the normal case it is now removed.