Ejemplo n.º 1
0
    def registry_port_forward_disable(self):
        name = "Disable PortForward to Registy"

        cmd1 = "kill $(shell cat {0}/port-forward.pid) || true".format(
            self.settings.folder_user_populated)
        cmd1_out = Cmd.local_run_get_out(name, cmd1)
        cmd2 = "rm -f {0}/port-forward.pid".format(
            self.settings.folder_user_populated)
        cmd2_out = Cmd.local_run_get_out(name, cmd2)

        Static.msg(name, master_node)
        Static.msg(">", cmd)
        return master_node
Ejemplo n.º 2
0
 def registry_port_forward_enable(self):
     name = "Enable PortForward to Registy"
     cmd = "kubectl port-forward --namespace kube-system {0} 5000:5000 & echo $$! > {1}/port-forward.pid".format(
         self.settings.folder_user_populated, self.get_registry_pod())
     master_node = Cmd.local_run_get_out(name, cmd)
     Static.msg(name, master_node)
     Static.msg(">", cmd)
     return master_node
Ejemplo n.º 3
0
    def get_master_ip(self):
        name = "Get Master IP"
        if self.get_context() == "minikube":
            cmd = "minikube ip"
            self.settings.master_ip = Cmd.local_run_get_out(name, cmd)
        else:
            cmd = "kubectl get nodes | grep master | sed 's/ .*//'"
            master_node = Cmd.local_run_get_out(name, cmd)
            ip_list = master_node.split(
                '-'
            )  # highly dependant on hostname not being changed from amazon default. find better way fast (example: 'ip-172-32-56-155.ec2.internal')
            self.settings.master_ip = '{0}.{1}.{2}.{3}'.format(
                ip_list[1],
                ip_list[2],
                ip_list[3],
                ip_list[4].split('.')[0],
            )

        Static.msg(name, self.settings.master_ip)
        return self.settings.master_ip
Ejemplo n.º 4
0
    def initialize_new_clusterfile(self):

        clusterfile_src = os.path.join(self.folder_app_clusters,
                                       self.args.init[0])
        clusterfile_dst = os.path.join(self.folder_user_clusters,
                                       self.args.init[1])

        if os.path.isfile(clusterfile_dst):
            print "DESTINATION FILE {0} ALREADY EXISTS".format(clusterfile_dst)

        if not os.path.isfile(clusterfile_src):
            print "SOURCE FILE {0} NOT FOUND".format(clusterfile_src)

        Static.msg("Initializing New Clusterfile", clusterfile_dst)

        Cmd.local_run_get_out(
            "INITIATED CLUSTERFILE {0}".format(clusterfile_src),
            "cp {0} {1}".format(clusterfile_src, clusterfile_dst))

        self.settings.clusterfile = clusterfile_dst
        self.save_settings_file()
Ejemplo n.º 5
0
def get_version():
    try:
        return pkg_resources.get_distribution("madcore").version
    except:
        return Cmd.local_run_get_out("get version", "git describe --tags")
Ejemplo n.º 6
0
 def get_context(self):
     name = "kubectl config current-context"
     cmd = "kubectl config current-context"
     self.settings.current_context = Cmd.local_run_get_out(name, cmd)
     Static.msg(name, self.settings.current_context)
     return self.settings.current_context
Ejemplo n.º 7
0
 def get_registry_pod(self):
     name = "Get Registry Pod"
     cmd = "kubectl get pods --namespace kube-system -l k8s-app=kube-registry-upstream -o template --template '{{range .items}}{{.metadata.name}} {{.status.phase}}{{\"\\n\"}}{{end}}'"
     master_node = Cmd.local_run_get_out(name, cmd).split(' ')[0]
     Static.msg(name, master_node)
     return master_node
Ejemplo n.º 8
0
 def get_master_node(self):
     name = "Get Master Node"
     cmd = "kubectl get nodes | grep master | sed 's/ .*//'"
     master_node = Cmd.local_run_get_out(name, cmd)
     Static.msg(name, master_node)
     return master_node
Ejemplo n.º 9
0
 def get_minikube_ip(self):
     name = "Get minikube ip"
     cmd = "minikube ip"
     self.settings.master_ip = Cmd.local_run_get_out(name, cmd)
     return self.settings.master_ip