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 #25 from TheNewNormal/v0.4.9
Browse files Browse the repository at this point in the history
v0.4.9
  • Loading branch information
rimusz committed Jan 26, 2016
2 parents 704b785 + 6059abe commit 8dda4a6
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 117 deletions.
4 changes: 4 additions & 0 deletions src/Kube-Solo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
1329DEB51BD4FB5F008AA719 /* up.command in Resources */ = {isa = PBXBuildFile; fileRef = 1329DEAA1BD4FB5F008AA719 /* up.command */; };
1329DEB61BD4FB5F008AA719 /* update_osx_clients_files.command in Resources */ = {isa = PBXBuildFile; fileRef = 1329DEAB1BD4FB5F008AA719 /* update_osx_clients_files.command */; };
1329DEB81BD526A3008AA719 /* update_k8s.command in Resources */ = {isa = PBXBuildFile; fileRef = 1329DEB71BD526A3008AA719 /* update_k8s.command */; };
1345D2771C57002B000BCBC6 /* change_vm_ram.command in Resources */ = {isa = PBXBuildFile; fileRef = 1345D2761C57002B000BCBC6 /* change_vm_ram.command */; };
1347C2F91C30570D0083CDF9 /* change_sudo_password.command in Resources */ = {isa = PBXBuildFile; fileRef = 1347C2F81C30570D0083CDF9 /* change_sudo_password.command */; };
13BCE1C01BEBC0BD00A1A48E /* update_k8s_version.command in Resources */ = {isa = PBXBuildFile; fileRef = 13BCE1BF1BEBC0BD00A1A48E /* update_k8s_version.command */; };
13D9B8671C35B09B00EBB078 /* restore_update_fleet_units.command in Resources */ = {isa = PBXBuildFile; fileRef = 13D9B8661C35B09B00EBB078 /* restore_update_fleet_units.command */; };
Expand Down Expand Up @@ -81,6 +82,7 @@
1329DEAA1BD4FB5F008AA719 /* up.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = up.command; sourceTree = "<group>"; };
1329DEAB1BD4FB5F008AA719 /* update_osx_clients_files.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update_osx_clients_files.command; sourceTree = "<group>"; };
1329DEB71BD526A3008AA719 /* update_k8s.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update_k8s.command; sourceTree = "<group>"; };
1345D2761C57002B000BCBC6 /* change_vm_ram.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = change_vm_ram.command; sourceTree = "<group>"; };
1347C2F81C30570D0083CDF9 /* change_sudo_password.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = change_sudo_password.command; sourceTree = "<group>"; };
13BCE1BF1BEBC0BD00A1A48E /* update_k8s_version.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update_k8s_version.command; sourceTree = "<group>"; };
13D9B8661C35B09B00EBB078 /* restore_update_fleet_units.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = restore_update_fleet_units.command; sourceTree = "<group>"; };
Expand Down Expand Up @@ -197,6 +199,7 @@
1329DEA51BD4FB5F008AA719 /* functions.sh */,
1329DEA11BD4FB5F008AA719 /* check_vm_status.command */,
011BBA3A1A2A842A00AAB35B /* change_release_channel.command */,
1345D2761C57002B000BCBC6 /* change_vm_ram.command */,
1347C2F81C30570D0083CDF9 /* change_sudo_password.command */,
1329DEA31BD4FB5F008AA719 /* destroy.command */,
019410671BE11DFA00723E19 /* kill_VM.command */,
Expand Down Expand Up @@ -289,6 +292,7 @@
1329DE9A1BD4FA58008AA719 /* kube-solo-install.command in Resources */,
01E2855618A6C4E300BC630D /* Images.xcassets in Resources */,
1329DEB21BD4FB5F008AA719 /* reload.command in Resources */,
1345D2771C57002B000BCBC6 /* change_vm_ram.command in Resources */,
01741B63190DB80500BB1F91 /* first-init.command in Resources */,
011BBA3B1A2A842A00AAB35B /* change_release_channel.command in Resources */,
13FE22191C1C410100F465F1 /* cloud-init in Resources */,
Expand Down
6 changes: 6 additions & 0 deletions src/Kube-Solo/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ - (IBAction)changeReleaseChannel:(id)sender {
}


- (IBAction)changeVMRAM:(id)sender {
[self notifyUserWithText:NSLocalizedString(@"VMRAMChangeNotificationMessage", nil)];
[self.vmManager changeVMRAM];
}


- (IBAction)changeSudoPassword:(id)sender {
[self notifyUserWithText:NSLocalizedString(@"SudoPasswordChangeNotificationMessage", nil)];
[self.vmManager changeSudoPassword];
Expand Down
13 changes: 10 additions & 3 deletions src/Kube-Solo/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
Expand Down Expand Up @@ -759,10 +759,17 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="2qm-xK-2AI"/>
<menuItem title="Change 'sudo' password" id="YJ4-BU-RHT">
<menuItem title="Change VM's RAM size" id="YJ4-BU-RHT">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="changeSudoPassword:" target="494" id="zih-wE-heQ"/>
<action selector="changeVMRAM:" target="494" id="8SR-l6-uOC"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="NmB-Yu-0V6"/>
<menuItem title="Change 'sudo' password" id="TTp-IO-ybw">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="changeSudoPassword:" target="494" id="DX4-cn-wRQ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="IpY-jd-Luh"/>
Expand Down
4 changes: 2 additions & 2 deletions src/Kube-Solo/Kube-Solo-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.4.8</string>
<string>0.4.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>151</string>
<string>153</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
1 change: 1 addition & 0 deletions src/Kube-Solo/VMManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef NS_ENUM(NSInteger, VMStatus) {
- (void)restoreFleetUnits;
- (void)updateISO;
- (void)changeReleaseChannel;
- (void)changeVMRAM;
- (void)changeSudoPassword;
- (void)destroy;
- (void)install;
Expand Down
4 changes: 4 additions & 0 deletions src/Kube-Solo/VMManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ - (void)changeReleaseChannel {
[self runApp:@"iTerm" arguments:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"change_release_channel.command"]];
}

- (void)changeVMRAM {
[self runApp:@"iTerm" arguments:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"change_vm_ram.command"]];
}

- (void)changeSudoPassword {
[self runApp:@"iTerm" arguments:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"change_sudo_password.command"]];
}
Expand Down
1 change: 1 addition & 0 deletions src/Kube-Solo/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"ClientsWillBeUpdatedNotificationMessage" = "OS X clients will be updated";
"ISOImageWillBeUpdatedNotificationMessage" = "CoreOS ISO image will be updated";
"ReleaseChannelChangeNotificationMessage" = "CoreOS release channel change";
"VMRAMChangeNotificationMessage" = "VM RAM size change";
"SudoPasswordChangeNotificationMessage" = "sudo password change";
"SSHShellWillOpenNotificationMessage" = "VM ssh shell will be opened";
"ShellWillOpenNotificationMessage" = "OS X shell will be opened";
Expand Down
16 changes: 16 additions & 0 deletions src/change_vm_ram.command
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# change_vm_ram.command

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "${DIR}"/functions.sh

#
change_vm_ram

#
((ram_size=$new_ram_size/1024))

echo "You need to reload your VM if it is running or on next VM's boot new $ram_size GB RAM will be used ..."
echo " "
pause 'Press [Enter] key to continue...'
8 changes: 4 additions & 4 deletions src/cloud-init/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ coreos:
reboot-strategy: off
etcd2:
name: k8solo-01
initial-advertise-peer-urls: http://127.0.0.1:2380
initial-advertise-peer-urls: http://$private_ipv4:2380
initial-cluster-token: k8solo-01_etcd
initial-cluster: k8solo-01=http://127.0.0.1:2380
initial-cluster: k8solo-01=http://$private_ipv4:2380
initial-cluster-state: new
listen-peer-urls: http://0.0.0.0:2380,http://0.0.0.0:7001
listen-peer-urls: http://$private_ipv4:2380,http://$private_ipv4:7001
listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
advertise-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
units:
- name: docker-tcp.socket
command: start
Expand Down
5 changes: 1 addition & 4 deletions src/destroy.command
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ source "${DIR}"/functions.sh
# get App's Resources folder
res_folder=$(cat ~/kube-solo/.env/resouces_path)

# get VM IP
vm_ip=$("${res_folder}"/bin/corectl q -i k8solo-01)

# get password for sudo
my_password=$(security find-generic-password -wa kube-solo-app)
# reset sudo
Expand All @@ -38,7 +35,7 @@ do
# send halt to VM
echo -e "$my_password\n" | sudo -S "${res_folder}"/bin/corectl halt k8solo-01 > /dev/null 2>&1

# delete root image
# delete data image
rm -f ~/kube-solo/data.img

# delete password in keychain
Expand Down
36 changes: 4 additions & 32 deletions src/first-init.command
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,14 @@ save_password
# Set release channel
release_channel

# set VM's RAM
change_vm_ram

# create Data disk
create_data_disk

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

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

# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8solo-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1

# save VM's IP
"${res_folder}"/bin/corectl q -i k8solo-01 | tr -d "\n" > ~/kube-solo/.env/ip_address
# get VM IP
vm_ip=$("${res_folder}"/bin/corectl q -i k8solo-01)
#
start_vm

# install k8s files on to VM
install_k8s_files
Expand Down
60 changes: 60 additions & 0 deletions src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,66 @@ fi
}


change_vm_ram() {
echo " "
echo " "
echo "Please type VM's RAM size in GBs followed by [ENTER]:"
echo -n "[default is 2]: "
read ram_size
if [ -z "$ram_size" ]
then
ram_size=2
echo "Changing VM's RAM to "$ram_size"GB..."
((new_ram_size=$ram_size*1024))
sed -i "" 's/\(memory = \)\(.*\)/\1'$new_ram_size'/g' ~/kube-solo/settings/k8solo-01.toml
echo " "
else
echo "Changing VM's RAM to "$ram_size"GB..."
((new_ram_size=$ram_size*1024))
sed -i "" 's/\(memory = \)\(.*\)/\1'$new_ram_size'/g' ~/kube-solo/settings/k8solo-01.toml
echo " "
fi

}


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

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

# check if /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8solo-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1

# save VM's IP
"${res_folder}"/bin/corectl q -i k8solo-01 | tr -d "\n" > ~/kube-solo/.env/ip_address
# get VM IP
vm_ip=$("${res_folder}"/bin/corectl q -i k8solo-01)
#

}


function download_osx_clients() {
# download fleetctl file
FLEETCTL_VERSION=$("${res_folder}"/bin/corectl ssh k8solo-01 'fleetctl --version' | awk '{print $3}' | tr -d '\r')
Expand Down
34 changes: 6 additions & 28 deletions src/reload.command
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,18 @@ echo "Stopping VM ..."
echo -e "$my_password\n" | sudo -Sv > /dev/null 2>&1
sudo "${res_folder}"/bin/corectl halt k8solo-01

sleep 2
sleep 3

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

# check id /Users/homefolder is mounted, if not mount it
"${res_folder}"/bin/corectl ssh k8solo-01 'source /etc/environment; if df -h | grep ${HOMEDIR}; then echo 0; else sudo systemctl restart ${HOMEDIR}; fi' > /dev/null 2>&1
echo " "

# save VM's IP
"${res_folder}"/bin/corectl q -i k8solo-01 | tr -d "\n" > ~/kube-solo/.env/ip_address
# get VM's IP
vm_ip=$("${res_folder}"/bin/corectl q -i k8solo-01)
start_vm

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

# wait till VM is ready
echo " "
echo "Waiting for VM to be ready..."
spin='-\|/'
i=1
Expand All @@ -72,7 +48,9 @@ sleep 2
echo " "
echo "fleetctl list-machines:"
fleetctl list-machines
echo ""
echo " "

sleep 2

# deploy fleet units from ~/kube-solo/fleet
deploy_fleet_units
Expand Down
2 changes: 1 addition & 1 deletion src/settings/k8solo-01.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
volume = "data.img"
cloud_config = "cloud-init/user-data"
cpus = 2
memory = "2048"
memory = 2048
local = "true"
Loading

0 comments on commit 8dda4a6

Please sign in to comment.