Commit fcc0bb18 authored by Spiros Koulouzis's avatar Spiros Koulouzis

Fixed file not found bug

parent cef30a0f
...@@ -35,6 +35,10 @@ def PrintException(): ...@@ -35,6 +35,10 @@ def PrintException():
def install_manager(vm): def install_manager(vm):
try: try:
print "%s: ====== Start Kubernetes Master Installing ======" % (vm.ip) print "%s: ====== Start Kubernetes Master Installing ======" % (vm.ip)
parentDir = os.path.dirname(os.path.abspath(vm.key))
os.chmod(parentDir, 0o700)
os.chmod(vm.key, 0o600)
ssh = paramiko.SSHClient() ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(vm.ip, username=vm.user, key_filename=vm.key) ssh.connect(vm.ip, username=vm.user, key_filename=vm.key)
...@@ -48,8 +52,10 @@ def install_manager(vm): ...@@ -48,8 +52,10 @@ def install_manager(vm):
stdout.read() stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/kubernetes_setup.sh") stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/kubernetes_setup.sh")
stdout.read() stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo kubeadm reset")
stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo kubeadm init --api-advertise-addresses=%s" % (vm.ip)) stdin, stdout, stderr = ssh.exec_command("sudo kubeadm init --apiserver-advertise-address=%s" % (vm.ip))
retstr = stdout.readlines() retstr = stdout.readlines()
stdin, stdout, stderr = ssh.exec_command("sudo cp /etc/kubernetes/admin.conf /tmp/") stdin, stdout, stderr = ssh.exec_command("sudo cp /etc/kubernetes/admin.conf /tmp/")
...@@ -87,6 +93,8 @@ def install_worker(join_cmd, vm): ...@@ -87,6 +93,8 @@ def install_worker(join_cmd, vm):
stdout.read() stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/kubernetes_setup.sh") stdin, stdout, stderr = ssh.exec_command("sudo sh /tmp/kubernetes_setup.sh")
stdout.read() stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo kubeadm reset")
stdout.read()
stdin, stdout, stderr = ssh.exec_command("sudo %s" % (join_cmd)) stdin, stdout, stderr = ssh.exec_command("sudo %s" % (join_cmd))
stdout.read() stdout.read()
print "%s: ========= Kubernetes Slave Installed =========" % (vm.ip) print "%s: ========= Kubernetes Slave Installed =========" % (vm.ip)
...@@ -113,6 +121,7 @@ def run(vm_list): ...@@ -113,6 +121,7 @@ def run(vm_list):
if "ERROR" in worker_cmd: if "ERROR" in worker_cmd:
return worker_cmd return worker_cmd
file_path = os.path.dirname(os.path.abspath(__file__))
kuber_file = open(file_path + "/admin.conf", "r") kuber_file = open(file_path + "/admin.conf", "r")
kuber_string = kuber_file.read() kuber_string = kuber_file.read()
kuber_file.close() kuber_file.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment