Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #1 from TheNewNormal/v0.1.3
Browse files Browse the repository at this point in the history
V0.1.3
  • Loading branch information
rimusz committed Jan 25, 2016
2 parents 95e1abc + 8ac842b commit 6ae8de9
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 273 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ Kubernetes Cluster for OS X

**Kube-Cluster for Mac OS X** is a Mac Status bar App which works like a wrapper around the [corectl](https://github.com/TheNewNormal/corectl) command line tool (it makes easier to control [xhyve](https://github.com/xhyve-xyz/xhyve) based VMs) and bootstraps Kubernetes cluster with one master and two nodes based on [CoreOS VMs](https://coreos.com).

Includes [Helm](https://helm.sh) - The Kubernetes Package Manager.
**Includes:** [Helm](https://helm.sh) - The Kubernetes Package Manager.

Kube-Cluster App can be used together with [CoreOS VM App](https://github.com/TheNewNormal/coreos-osx) which allows to build Docker containers and has a private local Docker registry v2 which is accessible from Kube-Cluster App.
**Includes:** an option from shell to install [Deis open source PaaS](http://deis.io/overview/) v2 alpha on top of Kubernetes: `$ install_deis`

**Kube-Cluster App** can be used together with [CoreOS VM App](https://github.com/TheNewNormal/coreos-osx) which allows to build Docker containers and has a private local Docker registry v2 which is accessible from Kube-Cluster App.

![Kube-Cluster](kube-cluster-osx.png "Kubernetes-Cluster")

Expand Down
4 changes: 2 additions & 2 deletions src/Kube-Cluster/Kube-Cluster-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.2</string>
<string>0.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>25</string>
<string>27</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion src/bin/etcdctl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# get App's Resources folder
res_folder=$(cat ~/kube-cluster/.env/resouces_path)

# get VM's IP
# get master VM's IP
master_vm_ip=$("${res_folder}"/bin/corectl q -i k8smaster-01)

cmd=(ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet core@$master_vm_ip sudo /usr/bin/etcdctl "${@+$@}")
Expand Down
16 changes: 8 additions & 8 deletions src/bin/install_deis
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ node1_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-01)
current_folder=$(pwd)
cd ~/kube-cluster/bin
echo " "
echo "Installing latest helm ..."
echo "Installing latest helm version..."
curl -s https://get.helm.sh | bash > /dev/null 2>&1
cd $current_folder
echo "helm is installed to ~/kube-cluster/bin ... "

# run helm for the first time
helm up
# add Chart repo
helm repo add kube-charts https://github.com/TheNewNormal/kube-charts
# add Deis Chart repo
helm repo add deis https://github.com/deis/charts
# Get the latest version of all Charts from repos
helm up
# Fetch Deis-Lite Chart to your helm's working directory
helm fetch kube-charts/deis-lite
# Install Deis-Lite PaaS
helm install deis-lite
# Fetch Deis Chart to your helm's working directory
helm fetch deis/deis
# Install Deis PaaS
helm install deis

# Install deis client
current_folder=$(pwd)
cd ~/kube-cluster/bin
echo " "
echo "Installing deis client ..."
echo "Installing deis OS X client ..."
curl -sSL http://deis.io/deis-cli/install-v2-alpha.sh | bash > /dev/null 2>&1
cd $current_folder
echo "deis client is installed to ~/kube-cluster/bin ..."
Expand Down
85 changes: 4 additions & 81 deletions src/first-init.command
Original file line number Diff line number Diff line change
Expand Up @@ -37,85 +37,8 @@ my_password=$(security find-generic-password -wa kube-cluster-app)
# reset sudo
sudo -k > /dev/null 2>&1

# Start VMs
cd ~/kube-cluster
echo " "
echo "Starting k8smaster-01 VM ..."
echo " "
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8smaster-01.toml 2>&1 | tee ~/kube-cluster/logs/first-init_master_vm_up.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/first-init_master_vm_up.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Master VM has not booted, please check '~/kube-cluster/logs/first-init_master_vm_up.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Master VM successfully started !!!" >> ~/kube-cluster/logs/first-init_master_vm_up.log
fi
# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8smaster-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
# save master VM's IP
"${res_folder}"/bin/corectl q -i k8smaster-01 | tr -d "\n" > ~/kube-cluster/.env/master_ip_address
# get master VM's IP
master_vm_ip=$("${res_folder}"/bin/corectl q -i k8smaster-01)
# update nodes cloud-init files with master's IP
sed -i "" "s/_MASTER_IP_/$master_vm_ip/" ~/kube-cluster/cloud-init/user-data.node1
sed -i "" "s/_MASTER_IP_/$master_vm_ip/" ~/kube-cluster/cloud-init/user-data.node2
#
sleep 2
#
echo " "
echo "Starting k8snode-01 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8snode-01.toml 2>&1 | tee ~/kube-cluster/logs/first-init_node1_vm_up.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/first-init_node1_vm_up.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Node1 VM has not booted, please check '~/kube-cluster/logs/first-init_node1_vm_up.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Node1 VM successfully started !!!" >> ~/kube-cluster/logs/first-init_node1_vm_up.log
fi
# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8snode-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save node1 VM's IP
"${res_folder}"/bin/corectl q -i k8snode-01 | tr -d "\n" > ~/kube-cluster/.env/node1_ip_address
# get node1 VM's IP
node1_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-01)
#
#
echo "Starting k8snode-02 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8snode-02.toml 2>&1 | tee ~/kube-cluster/logs/first-init_node2_vm_up.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/first-init_node2_vm_up.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Node2 VM has not booted, please check '~/kube-cluster/logs/first-init_node2_vm_up.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Node2 VM successfully started !!!" >> ~/kube-cluster/logs/first-init_node2_vm_up.log
fi
# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8snode-02 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save node2 VM's IP
"${res_folder}"/bin/corectl q -i k8snode-02 | tr -d "\n" > ~/kube-cluster/.env/node2_ip_address
# get node2 VM's IP
node2_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-02)
###
# start cluster VMs
start_vms

# install k8s files on to VMs
install_k8s_files
Expand Down Expand Up @@ -194,8 +117,8 @@ echo " "
echo "You can control this App via status bar icon... "
echo " "

##echo "Also you can install Deis PaaS (http://deis.io) v2 alpha version with 'install_deis' command ..."
##echo " "
echo "Also you can install Deis PaaS (http://deis.io) v2 alpha version with 'install_deis' command ..."
echo " "

cd ~/kube-cluster
# open bash shell
Expand Down
91 changes: 88 additions & 3 deletions src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ export PATH=${HOME}/kube-cluster/bin:$PATH
# create persistent disks
cd ~/kube-cluster/
echo " "
echo "Creating 1GB Data disk for Master ..."
mkfile 1g master-data.img
echo "Creating 1.5GB Data disk for Master ..."
mkfile 1.5g master-data.img
echo "-"
echo "Created 1GB Data disk for Master"
echo "Created 1.5GB Data disk for Master"
echo " "

echo "Please type Node1/2 Data disk size in GBs followed by [ENTER]:"
Expand Down Expand Up @@ -128,6 +128,91 @@ fi
}


function start_vms() {
# get password for sudo
my_password=$(security find-generic-password -wa kube-cluster-app)
# reset sudo
sudo -k > /dev/null 2>&1

# Start VMs
cd ~/kube-cluster
echo " "
echo "Starting k8smaster-01 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8smaster-01.toml 2>&1 | tee ~/kube-cluster/logs/master_vm_up.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/master_vm_up.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Master VM has not booted, please check '~/kube-cluster/logs/master_vm_up.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Master VM successfully started !!!" >> ~/kube-cluster/logs/master_vm_up.log
fi

# check if /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8smaster-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
# save master VM's IP
"${res_folder}"/bin/corectl q -i k8smaster-01 | tr -d "\n" > ~/kube-cluster/.env/master_ip_address
# get master VM's IP
master_vm_ip=$("${res_folder}"/bin/corectl q -i k8smaster-01)
#
sleep 2
#
echo " "
echo "Starting k8snode-01 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8snode-01.toml 2>&1 | tee ~/kube-cluster/logs/node1_vm_up.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/node1_vm_up.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Node1 VM has not booted, please check '~/kube-cluster/logs/node1_vm_up.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Node1 VM successfully started !!!" >> ~/kube-cluster/logs/node1_vm_up.log
fi
# check if /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8snode-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save node1 VM's IP
"${res_folder}"/bin/corectl q -i k8snode-01 | tr -d "\n" > ~/kube-cluster/.env/node1_ip_address
# get node1 VM's IP
node1_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-01)
#
#
echo "Starting k8snode-02 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8snode-02.toml 2>&1 | tee ~/kube-cluster/logs/node2_vm_up.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/node2_vm_up.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Node2 VM has not booted, please check '~/kube-cluster/logs/node2_vm_up.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Node2 VM successfully started !!!" >> ~/kube-cluster/logs/node2_vm_up.log
fi
# check if /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8snode-02 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save node2 VM's IP
"${res_folder}"/bin/corectl q -i k8snode-02 | tr -d "\n" > ~/kube-cluster/.env/node2_ip_address
# get node2 VM's IP
node2_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-02)

}


function download_osx_clients() {
# download fleetctl file
FLEETCTL_VERSION=$("${res_folder}"/bin/corectl ssh k8smaster-01 'fleetctl --version' | awk '{print $3}' | tr -d '\r')
Expand Down
2 changes: 1 addition & 1 deletion src/os_shell.command
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ssh-add -K ~/.ssh/id_rsa &>/dev/null
# get App's Resources folder
res_folder=$(cat ~/kube-cluster/.env/resouces_path)

# get VM IP
# get master VM's IP
master_vm_ip=$("${res_folder}"/bin/corectl q -i k8smaster-01)

# path to the bin folder where we store our binary files
Expand Down
81 changes: 3 additions & 78 deletions src/reload.command
Original file line number Diff line number Diff line change
Expand Up @@ -37,91 +37,16 @@ sudo "${res_folder}"/bin/corectl halt k8snode-02
#
sleep 2

### Start VMs
cd ~/kube-cluster
#
echo " "
echo "Starting k8smaster-01 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8smaster-01.toml 2>&1 | tee ~/kube-cluster/logs/master_vm_reload.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/master_vm_reload.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Master VM has not booted, please check '~/kube-cluster/logs/master_vm_reload.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Master VM successfully started !!!" >> ~/kube-cluster/logs/master_vm_reload.log
fi
# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8smaster-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save master VM's IP
"${res_folder}"/bin/corectl q -i k8smaster-01 | tr -d "\n" > ~/kube-cluster/.env/master_ip_address
# get master VM's IP
master_vm_ip=$("${res_folder}"/bin/corectl q -i k8smaster-01)
#
#
echo " "
echo "Starting k8snode-01 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8snode-01.toml 2>&1 | tee ~/kube-cluster/logs/node1_vm_reload.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/node1_vm_reload.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Node1 VM has not booted, please check '~/kube-cluster/logs/node1_vm_reload.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Node1 VM successfully started !!!" >> ~/kube-cluster/logs/node1_vm_reload.log
fi
# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8snode-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save node1 VM's IP
"${res_folder}"/bin/corectl q -i k8snode-01 | tr -d "\n" > ~/kube-cluster/.env/node1_ip_address
# get node1 VM's IP
node1_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-01)
#
#
echo " "
echo "Starting k8snode-02 VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
#
sudo "${res_folder}"/bin/corectl load settings/k8snode-02.toml 2>&1 | tee ~/kube-cluster/logs/node2_vm_reload.log
CHECK_VM_STATUS=$(cat ~/kube-cluster/logs/node2_vm_reload.log | grep "started")
#
if [[ "$CHECK_VM_STATUS" == "" ]]; then
echo " "
echo "Node2 VM has not booted, please check '~/kube-cluster/logs/node2_vm_reload.log' and report the problem !!! "
echo " "
pause 'Press [Enter] key to continue...'
exit 0
else
echo "Node2 VM successfully started !!!" >> ~/kube-cluster/logs/node2_vm_reload.log
fi
# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8snode-02 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "
# save node2 VM's IP
"${res_folder}"/bin/corectl q -i k8snode-02 | tr -d "\n" > ~/kube-cluster/.env/node2_ip_address
# get node2 VM's IP
node2_vm_ip=$("${res_folder}"/bin/corectl q -i k8snode-02)
###
### Start cluster VMs
start_vms

# set fleetctl endpoint
export FLEETCTL_ENDPOINT=http://$master_vm_ip:2379
export FLEETCTL_DRIVER=etcd
export FLEETCTL_STRICT_HOST_KEY_CHECKING=false

# wait till VM is ready
echo "Waiting for VM to be ready..."
echo "Waiting for k8smaster-01 to be ready..."
spin='-\|/'
i=1
until curl -o /dev/null http://$master_vm_ip:2379 >/dev/null 2>&1; do i=$(( (i+1) %4 )); printf "\r${spin:$i:1}"; sleep .1; done
Expand Down
Loading

0 comments on commit 6ae8de9

Please sign in to comment.