-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash -x | ||
check_kubeconfig() { | ||
if [[ -z "$KUBECONFIG" && ! -f "${HOME}/.kube/config" ]]; then | ||
echo 'ERROR: Cannot find KUBECONFIG! Set as environment variable.' | ||
exit 1 | ||
fi | ||
} | ||
|
||
get_storageclass() { | ||
default_storageclass="$(kubectl get sc | grep default | awk '{print $1}')" | ||
if [[ -z "$default_storageclass" ]]; then | ||
enable_storage | ||
fi | ||
} | ||
|
||
enable_storage() { | ||
if leader="$(juju status --format json| jq -r '.applications["microk8s"].units|to_entries[]|select(.value["leader"])|.key' 2> /dev/null)"; then | ||
echo 'Enabling hostpath-storage on Microk8s.' | ||
juju ssh "$leader" sudo microk8s enable hostpath-storage | ||
elif leader="$(juju status --format json| jq -r '.applications["k8s"].units|to_entries[]|select(.value["leader"])|.key' 2> /dev/null)"; then | ||
echo 'Enabling local-storage on Canonical K8s.' | ||
juju ssh "$leader" sudo k8s enable local-storage | ||
else | ||
echo 'ERROR: No default storage class in Kubernetes. Try deploying a k8s bundle with --ceph.' | ||
exit 1 | ||
fi | ||
} | ||
|
||
bootstrap_k8s() { | ||
juju add-k8s k8s-cloud --client | ||
juju bootstrap k8s-cloud | ||
juju add-model secloud | ||
} | ||
|
||
check_kubeconfig | ||
get_storageclass | ||
bootstrap_k8s |