Skip to content

Commit

Permalink
Allow system charts to be installed into other namespaces too
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Nov 18, 2023
1 parent 9fecbb4 commit c027bf6
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 35 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ jobs:
- name: "Stage 1: Install and setup helm ${{ env.HELM_VERSION }}"
run: |
curl -sf https://raw.githubusercontent.com/helm/helm/HEAD/scripts/get-helm-3 | DESIRED_VERSION=${HELM_VERSION} bash
helm dependency update ./mybinder
helm dependency update ./mybinder-kube-system
for d in ./mybinder/ ./system-charts/*/; do
helm dependency update "$d"
done
# Action Repo: https://github.com/sliteteam/github-action-git-crypt-unlock
- name: "Stage 2: Unlock git-crypt secrets"
Expand Down Expand Up @@ -309,8 +310,9 @@ jobs:
- name: "Stage 1: Install and setup helm ${{ env.HELM_VERSION }}"
run: |
curl -sf https://raw.githubusercontent.com/helm/helm/HEAD/scripts/get-helm-3 | DESIRED_VERSION=${HELM_VERSION} bash
helm dependency update ./mybinder
helm dependency update ./mybinder-kube-system
for d in ./mybinder/ ./system-charts/*/; do
helm dependency update "$d"
done
- name: "Stage 2: Unlock git-crypt secrets"
uses: sliteteam/github-action-git-crypt-unlock@8b1fa3ccc81e322c5c45fbab261eee46513fd3f8
Expand Down
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ __pycache__
config/common/datacenter-*.yaml
secrets/banned_hosts.txt
secrets/config/common/bans.yaml
mybinder*/charts
mybinder*/requirements.lock
mybinder*/Chart.lock
system-charts/*/charts
system-charts/*/requirements.lock
system-charts/*/Chart.lock
mybinder/charts
mybinder/requirements.lock
mybinder/Chart.lock

.ipynb_checkpoints

Expand Down
64 changes: 36 additions & 28 deletions deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,39 +329,47 @@ def patch_coredns(dry_run=False):
)


def deploy_kube_system_charts(release, name=None, dry_run=False):
def deploy_system_charts(release, name=None, dry_run=False):
"""
Some charts must be deployed into the kube-system namespace
Some charts must be deployed into other namespaces
"""
if not name:
name = release
log_name = f"mybinder-kube-system {release}"

config_files = get_config_files(release, config_dir="config-kube-system")
if not config_files:
print(BOLD + GREEN + f"No config files found for {log_name}" + NC, flush=True)
return
charts = glob.glob("system-charts/*/Chart.yaml")
namespaces = [c.split("/")[1] for c in charts]

print(BOLD + GREEN + f"Starting helm upgrade for {log_name}" + NC, flush=True)
helm = [
"helm",
"upgrade",
"--install",
"--cleanup-on-fail",
"--namespace=kube-system",
name,
"mybinder-kube-system",
]
for config_file in config_files:
helm.extend(["-f", config_file])
for ns in namespaces:
log_name = f"mybinder-{ns} {release}"

check_call(helm, dry_run)
print(
BOLD + GREEN + f"SUCCESS: Helm upgrade for {log_name} completed" + NC,
flush=True,
)
config_files = get_config_files(release, config_dir=f"system-config/{ns}")
if not config_files:
print(
BOLD + GREEN + f"No config files found for {log_name}" + NC, flush=True
)
return

print(BOLD + GREEN + f"Starting helm upgrade for {log_name}" + NC, flush=True)
helm = [
"helm",
"upgrade",
"--install",
"--cleanup-on-fail",
f"--namespace={ns}",
"--create-namespace",
name,
f"system-charts/{ns}",
]
for config_file in config_files:
helm.extend(["-f", config_file])

check_call(helm, dry_run)
print(
BOLD + GREEN + f"SUCCESS: Helm upgrade for {log_name} completed" + NC,
flush=True,
)

wait_for_deployments_daemonsets("kube-system", dry_run)
wait_for_deployments_daemonsets(ns, dry_run)


def main():
Expand Down Expand Up @@ -398,7 +406,7 @@ def main():
action="store_true",
help="Print commands, but don't run them",
)
stages = ["all", "auth", "networkban", "kubesystem", "certmanager", "mybinder"]
stages = ["all", "auth", "networkban", "system", "certmanager", "mybinder"]
argparser.add_argument(
"--stage",
choices=stages,
Expand Down Expand Up @@ -454,8 +462,8 @@ def main():

if args.stage in ("all", "networkban"):
update_networkbans(cluster, args.dry_run)
if args.stage in ("all", "kubesystem"):
deploy_kube_system_charts(args.release, args.name, args.dry_run)
if args.stage in ("all", "system"):
deploy_system_charts(args.release, args.name, args.dry_run)
if args.stage in ("all", "certmanager"):
setup_certmanager(args.dry_run)
if args.stage in ("all", "mybinder"):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c027bf6

Please sign in to comment.