| #!/usr/bin/env bash |
| |
| set -ex |
| |
| echo "Kubectl plugin for Apache Bigtop" |
| |
| BIGTOP_HOME=${BIGTOP_HOME:-/bigtop} |
| |
| |
| detect_java() { |
| # detect JAVA_HOME |
| source $BIGTOP_HOME/bigtop-packages/src/common/bigtop-utils/bigtop-detect-javahome |
| |
| if [ -x "$JAVA_HOME/bin/java" ]; then |
| JAVA="$JAVA_HOME/bin/java" |
| else |
| JAVA=`which java` |
| fi |
| |
| if [ -z "$JAVA" ]; then |
| echo "could not find java; set JAVA_HOME or ensure java is in PATH" |
| exit 1 |
| fi |
| } |
| |
| # version of Bigtop plugin |
| if [[ "$1" == "version" ]]; then |
| # FIXME |
| echo "9.9.9" |
| exit 0 |
| fi |
| |
| # Configure kubectl |
| if [[ "$1" == "kubectl-config" ]]; then |
| # FIXME |
| if [[ ! -f "$HOME/.kube/config" ]]; then |
| echo "configuring kubectl..." |
| sudo mkdir -p ~/.kube |
| sudo cp /etc/kubernetes/admin.conf ~/.kube/config |
| sudo chown -R $USER:$USER ~/.kube |
| kubectl config view |
| fi |
| fi |
| |
| # Cluster info |
| if [[ "$1" == "cluster-info" ]]; then |
| kubectl cluster-info |
| exit 0 |
| fi |
| |
| # Install Helm |
| if [[ "$1" == "helm-deploy" ]]; then |
| curl -L https://git.io/get_helm.sh | bash |
| helm version -c |
| kubectl --namespace kube-system create serviceaccount tiller |
| kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| helm init --history-max 200 |
| sleep 10s |
| kubectl --namespace kube-system patch deploy tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' |
| sleep 10s |
| helm version |
| exit 0 |
| fi |
| |
| # Hostpah storageClass |
| if [[ "$1" == "hostpath-deploy" ]]; then |
| helm repo add rimusz https://charts.rimusz.net |
| helm repo update |
| helm upgrade --install hostpath-provisioner --namespace kube-system --set storageClass.defaultClass=true rimusz/hostpath-provisioner |
| sleep 5s ; kubectl get storageclass |
| |
| exit 0 |
| fi |
| |
| # Install Rook-Ceph |
| if [[ "$1" == "rook-ceph-deploy" ]]; then |
| |
| kubectl create -f $BIGTOP_HOME/dl/rook-1.1.2/cluster/examples/kubernetes/ceph/common.yaml |
| kubectl create -f $BIGTOP_HOME/dl/rook-1.1.2/cluster/examples/kubernetes/ceph/operator.yaml |
| kubectl -n rook-ceph get pod |
| |
| sleep 10s |
| |
| # Ceph cluster |
| # test |
| kubectl create -f $BIGTOP_HOME/storage/rook/ceph/cluster-test.yaml |
| # production |
| # kubectl create -f $BIGTOP_HOME/storage/rook/ceph/cluster.yaml |
| |
| sleep 10s |
| |
| # Ceph toolbox |
| kubectl create -f $BIGTOP_HOME/dl/rook-1.1.2/cluster/examples/kubernetes/ceph/toolbox.yaml |
| |
| # StorageClass: Ceph RBD |
| kubectl create -f $BIGTOP_HOME/dl/rook-1.1.2/cluster/examples/kubernetes/ceph/csi/rbd/storageclass.yaml |
| # Make the storageClass as default |
| kubectl patch storageclass rook-ceph-block -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' |
| kubectl get storageclass |
| exit 0 |
| fi |
| |
| # Rook Ceph toolbox |
| if [[ "$1" == "rook-ceph-toolbox" ]]; then |
| kubectl -n rook-ceph exec -it $(kubectl -n rook-ceph get pod -l "app=rook-ceph-tools" -o jsonpath='{.items[0].metadata.name}') bash |
| exit 0 |
| fi |
| |
| # Rook NFS |
| if [[ "$1" == "rook-nfs-deploy" ]]; then |
| kubectl create -f $BIGTOP_HOME/dl/rook-1.1.2/cluster/examples/kubernetes/nfs/operator.yaml |
| sleep 10s |
| kubectl -n rook-nfs-system get pod |
| kubectl create -f $BIGTOP_HOME/storage/rook/nfs/nfs.yaml |
| # kubectl create -f $BIGTOP_HOME/storage/rook/nfs/nfs-ceph.yaml |
| kubectl create -f $BIGTOP_HOME/storage/rook/nfs/storageclass.yaml |
| kubectl get storageclass |
| fi |
| |
| # Minio |
| if [[ "$1" == "minio-deploy" ]]; then |
| helm install --name bigtop-minio --namespace bigtop -f storage/minio/values.yaml stable/minio |
| exit 0 |
| fi |
| |
| # Loki |
| if [[ "$1" == "loki-deploy" ]]; then |
| helm repo add loki https://grafana.github.io/loki/charts |
| helm repo update |
| helm upgrade --install --namespace default loki -f logs/loki/loki-values.yaml loki/loki |
| sleep 10s |
| helm upgrade --install --namespace default promtail -f logs/loki/proimtail-values.yaml loki/promtail --set "loki.serviceName=loki" |
| # http url for loki server: http://loki:3100 |
| helm list && kubectl get po -A |
| exit 0 |
| fi |