Skip to content
Snippets Groups Projects
Commit ea3ea0f6 authored by mohammad's avatar mohammad
Browse files

refactor agent process and clean functionality

parent dc733c21
Branches
Tags v0.2.8
No related merge requests found
Pipeline #89 passed
......@@ -80,19 +80,19 @@ class Commands(RunCommand):
def flux_install(self, name):
self.run(['flux', 'install', '--components=source-controller,kustomize-controller,helm-controller',
'--namespace=flux-system'])
return True
def cluster_info(self, name):
self.run(['kubectl', 'cluster-info'])
return True
def kubectl_apply(self, name):
# we should change these commands
ps = run(['echo', self.data],
check=True, capture_output=True)
processNames = run(['kubectl', 'apply', '-f', '-'],
input=ps.stdout, capture_output=True)
logger.info(processNames.stdout.decode('utf-8').strip())
return ps.returncode
def install_k3s_server(self, name):
ps_mkdir = self.run(
......@@ -164,18 +164,19 @@ class Commands(RunCommand):
token = f.readline().strip()
with open("/etc/rancher/rke2/rke2.yaml", "r") as stream:
try:
kubeconfig = yaml.safe_load(stream)
kube_config = yaml.safe_load(stream)
except yaml.YAMLError as exc:
kubeconfig = None
kube_config = None
return {
'kubeconfig': 'test',
'token': 'test'
'kubeconfig': kube_config,
'token': token
}
def install_rke2_worker(self, name):
# please check these commands too
ps_mkdir = self.run(
['mkdir', '-p', '/var/lib/rancher/k3s/agent/images/'])
with cd("/var/lib/rancher/k3s/agent/images/"):
......@@ -191,10 +192,12 @@ class Commands(RunCommand):
ps_chmod_install_sh = self.run(['chmod', '+x', './install.sh'])
ps_cp_k3s = self.run(['cp', './k3s', '/usr/local/bin/k3s'])
ps_run_sh = self.run(
['''export INSTALL_K3S_SKIP_DOWNLOAD=true
&& export K3S_URL=https://myserver:6443
&& export K3S_TOKEN=mynodetoken
&& ./install.sh'''], shell=True)
[("export INSTALL_K3S_SKIP_DOWNLOAD=true"
f" && export rke2_URL={self.cluster['access_url']}"
f" && export rke2_TOKEN={self.cluster['token']}"
" && ./install.sh")], shell=True)
hash_commands = {
'flux-install': 'flux_install',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment