def exists(self) -> bool: try: run(f"helm ls | grep {self.namespaced_name}") except CommandError: return False else: return True
def deploy(self) -> None: super().deploy() run("helm repo add codecentric https://codecentric.github.io/helm-charts" ) self.helm_release = self.li.namespace.helm(self.se.name) self.helm_release.install("codecentric/keycloak", "7.2.0") self.seed()
def install(self) -> None: super().install() if self.exists(): return run(f""" cd /tmp curl -Lso hostess https://github.com/cbednarski/hostess/releases/download/v{self.se.version}/hostess_linux_386 chmod u+x hostess mv hostess {self.se.deps_dir}/{self.name} """)
def install(self) -> None: super().install() if self.exists(): return run(f""" cd /tmp curl -Lso kind \\ "https://github.com/kubernetes-sigs/kind/releases/download/v{self.se.version}/kind-$(uname)-amd64" chmod +x kind mv kind {str(self.bin_file)} """)
def install(self) -> None: super().install() if self.exists(): return run(f""" cd /tmp curl -Lso skaffold \\ "https://storage.googleapis.com/skaffold/releases/v{self.se.version}/skaffold-linux-amd64" chmod +x skaffold mv skaffold {str(self.bin_file)} """)
def install(self) -> None: super().install() if self.exists(): return release_name = f"helm-v{self.se.version}-linux-386" run(f""" cd /tmp curl -Lso helm.tar.gz https://get.helm.sh/{release_name}.tar.gz tar -zxf helm.tar.gz mv linux-386/helm {str(self.bin_file)} """)
def install(self) -> None: super().install() if self.exists(): return run(f""" cd /tmp curl -Lso kubectl \\ "https://storage.googleapis.com/kubernetes-release/release/v{self.se.version}/bin/linux/amd64/kubectl" chmod +x kubectl mv kubectl {str(self.bin_file)} """)
def list(cls) -> List[str]: raw = run("kubectl get namespaces")[0].splitlines()[1:] # skip header ret = [] for r in list(raw): ret.append(r.split()[0]) return ret
def deploy(self) -> None: logger.info(f'Deploying to "{self.env.stage}" 🚀') run("helm repo update") if not self.dns_server.is_running(): self.dns_server.start() for n in self.namespaces.values(): n.create() a: App for a in self.get_apps().values(): a.deploy() self.add_hosts() logger.info(f"All done 👌")
def install( self, chart: str, values: Path, version: Optional[str] = None, upgrade: bool = True, repo: str = "", ) -> None: """ :param repo: :param stage: :param chart: chart repository name :param version: install default if None :param upgrade: Try to upgrade when True. Delete and install when False. """ if not upgrade: try: run(f"""helm delete --purge {self.namespaced_name}""") except RuntimeError: pass if repo: run(f"helm repo add {repo}") run( f"""helm {"upgrade --install" if upgrade else "install"} \ {"" if upgrade else "--name"} {self.namespaced_name} \ --namespace={self.li.namespace.name} \ --set fullnameOverride={self.release_name} \ -f {str(values)} \ {"--force" if upgrade else ""} --wait=true \ --timeout=250000s \ "{chart}" \ {f"--version='{version}'"} \ """ )
def delete(self) -> None: logger.info(f"Deleting {self.namespaced_name}") run(f"helm delete --purge {self.namespaced_name}")
def create(cls, name: str) -> None: run(f"kubectl create namespace {name}")
def is_all_ready(cls) -> bool: status = run("kubectl get nodes")[0] return "NotReady" not in status
def kubectl(self, command: str, print_output: bool = False) -> List[str]: return run(f"kubectl -n {self.name} {command}", print_output=print_output)
def delete(self) -> None: logger.info(f"Deleting namespace {self.name}") run(f"kubectl delete namespace {self.name}")
def deploy(self) -> None: super().deploy() run("helm repo add gitlab https://charts.gitlab.io") self.runner.install(chart="gitlab/gitlab-runner", version="0.12.0")