Last active
August 31, 2016 21:34
-
-
Save rawlingsj/65e4766d12b666004c9f75dc99838139 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
MINIKUBE_VERSION=0.8.0 | |
KUBECTL_VERSION=1.3.4 | |
GOFABRIC8_VERSION=0.4.45 | |
MAVEN_VERTSION=3.3.9 | |
QUICKSTART_VERSION=2.2.164 | |
function getMinikube { | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v$MINIKUBE_VERSION/minikube-linux-amd64 | |
chmod +x minikube | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
echo 'installing minikube dependency xhyve see https://github.com/kubernetes/minikube/blob/master/README.md#installation' | |
if [[ $(brew install docker-machine-driver-xhyve | grep 'already installed' > /dev/null 2>&1) ]]; then | |
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve | |
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve | |
fi | |
echo 'downloading minikube...' | |
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v$MINIKUBE_VERSION/minikube-darwin-amd64 | |
chmod +x minikube | |
elif [[ "$OSTYPE" == "cygwin" ]]; then | |
echo "$OSTYPE not yet implemented" | |
exit -0 | |
elif [[ "$OSTYPE" == "win32" ]]; then | |
echo "$OSTYPE not yet implemented" | |
exit -0 | |
else | |
echo "$OSTYPE not supported" | |
exit -0 | |
fi | |
} | |
function getKubectl { | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
curl -O https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl | |
chmod +x kubectl | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
curl -O https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/darwin/amd64/kubectl | |
chmod +x kubectl | |
else | |
echo "$OSTYPE not yet supported" | |
exit -0 | |
fi | |
} | |
function getGofabric8 { | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
curl -O https://github.com/fabric8io/gofabric8/releases/download/v$GOFABRIC8_VERSION/gofabric8-$GOFABRIC8_VERSION-linux-amd64.tar.gz | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
curl -O https://github.com/fabric8io/gofabric8/releases/download/v$GOFABRIC8_VERSION/gofabric8-$GOFABRIC8_VERSION-darwin-amd64.tar.gz | |
else | |
echo "$OSTYPE not yet supported" | |
exit -0 | |
fi | |
tar -xvzf gofabric8-$GOFABRIC8_VERSION-darwin-amd64.tar.gz | |
chmod +x gofabric8 | |
} | |
function getMaven { | |
curl -O http://mirrors.ukfast.co.uk/sites/ftp.apache.org/maven/maven-3/$MAVEN_VERTSION/binaries/apache-maven-$MAVEN_VERTSION-bin.tar.gz | |
tar -xvzf apache-maven-$MAVEN_VERTSION-bin.tar.gz | |
M2_HOME=apache-maven-$MAVEN_VERTSION | |
M2=$M2_HOME/bin | |
} | |
if [[ ! $(which minikube) ]]; then | |
echo 'minikube not installed, lets go get it!' | |
getMinikube | |
else | |
echo 'minikube is installed' | |
fi | |
if [[ ! $(which kubectl) ]]; then | |
echo 'kubectl not installed, lets go get it!' | |
getKubectl | |
else | |
echo 'kubectl is installed' | |
fi | |
if [[ ! $(which mvn) ]]; then | |
echo 'maven not installed, lets go get it!' | |
getMaven | |
else | |
echo 'maven is installed' | |
fi | |
if [[ ! $(which gofabric8) ]]; then | |
echo 'gofabric8 not installed, lets go get it!' | |
getGofabric8 | |
else | |
echo 'gofabric8 is installed' | |
fi | |
PATH=$PATH:. | |
echo 'starting minikube' | |
minikube start | |
sleep 5 | |
kubectl config use-context minikube | |
echo 'installing the fabric8 console' | |
gofabric8 deploy -y --app= | |
eval $(minikube docker-env) | |
echo 'generate the spring boot camel quickstart' | |
rm -rf sb-camel-quickstart | |
mvn org.apache.maven.plugins:maven-archetype-plugin:2.2:generate \ | |
-B -DarchetypeGroupId=io.fabric8.archetypes \ | |
-DarchetypeArtifactId=spring-boot-camel-archetype \ | |
-DgroupId=my.test -DartifactId=sb-camel-quickstart \ | |
-Dversion=1.0-SNAPSHOT \ | |
-Dpackage=com.company.project \ | |
-DarchetypeVersion=$QUICKSTART_VERSION | |
echo 'build java artifact, generate kubernetes resources, build docker image and deploy to Kubernetes' | |
cd sb-camel-quickstart | |
mvn install fabric8:deploy | |
cd .. | |
echo "Waiting for fabric8 console to be ready at $(minikube service fabric8 --url)" | |
minikube service fabric8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment