Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[K8s] Parametrize tox task #8531

Merged
merged 6 commits into from
Mar 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 21 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ commands =
description = Start local Kubernetes registry & cluster with k3d
changedir = {toxinidir}
passenv=*
setenv =
CLUSTER_NAME = {env:CLUSTER_NAME:syft-dev}
NODE_PORT = {env:NODE_PORT:8080}
allowlist_externals =
bash
sleep
Expand All @@ -968,7 +971,7 @@ commands =
tox -e dev.k8s.registry

; for NodePort to work add the following --> -p "NodePort:NodePort@loadbalancer"
bash -c 'k3d cluster create syft-dev -p "8080:80@loadbalancer" --registry-use k3d-registry.localhost:5800; \
bash -c 'k3d cluster create ${CLUSTER_NAME} -p "${NODE_PORT}:80@loadbalancer" --registry-use k3d-registry.localhost:5800; \
kubectl create namespace syft || true'

; patch coredns
Expand All @@ -981,23 +984,29 @@ commands =
description = Deploy Syft to a local Kubernetes cluster with Devspace
changedir = {toxinidir}/packages/grid
passenv=HOME, USER
setenv=
KUBE_CONTEXT = {env:KUBE_CONTEXT:k3d-syft-dev}
DEVSPACE_PROFILE = {env:DEVSPACE_PROFILE:}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For launching gateway it could be like

CLUSTER_NAME="syft-gateway" NODE_PORT=9081 tox -e dev.k8s.start
KUBE_CONTEXT="k3d-syft-gateway" DEVSPACE_PROFILE="-p gateway" tox -e dev.k8s.hotreload

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since kubecontext is basically k3d-$CLUSTER_NAME, it's redundant. I'll push an update for this.

allowlist_externals =
tox
bash
commands =
; deploy syft helm charts
bash -c 'devspace deploy -b --kube-context k3d-syft-dev --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800'
bash -c 'devspace deploy -b --kube-context ${KUBE_CONTEXT} ${DEVSPACE_PROFILE} --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800'

[testenv:dev.k8s.hotreload]
description = Start development with hot-reload in Kubernetes
changedir = {toxinidir}/packages/grid
passenv=HOME, USER
setenv=
KUBE_CONTEXT = {env:KUBE_CONTEXT:k3d-syft-dev}
DEVSPACE_PROFILE = {env:DEVSPACE_PROFILE:}
allowlist_externals =
bash
tox
commands =
; deploy syft helm charts with hot-reload
bash -c 'devspace dev --kube-context k3d-syft-dev --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800'
bash -c 'devspace dev --kube-context ${KUBE_CONTEXT} ${DEVSPACE_PROFILE} --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800'

[testenv:dev.k8s.info]
description = Gather info about the localKubernetes cluster
Expand All @@ -1017,12 +1026,14 @@ commands =
description = Cleanup Syft deployment and associated resources, but keep the cluster running
changedir = {toxinidir}/packages/grid
passenv=HOME, USER
setenv=
KUBE_CONTEXT = {env:KUBE_CONTEXT:k3d-syft-dev}
allowlist_externals =
bash
commands =
bash -c 'devspace purge --force-purge --kube-context k3d-syft-dev --namespace syft; sleep 3'
bash -c 'devspace cleanup images --kube-context k3d-syft-dev --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800 || true'
bash -c 'kubectl config use-context k3d-syft-dev'
bash -c 'devspace purge --force-purge --kube-context ${KUBE_CONTEXT} --namespace syft; sleep 3'
bash -c 'devspace cleanup images --kube-context ${KUBE_CONTEXT} --namespace syft --var CONTAINER_REGISTRY=k3d-registry.localhost:5800 || true'
bash -c 'kubectl config use-context ${KUBE_CONTEXT}'
bash -c 'kubectl delete all --all --namespace syft || true'
bash -c 'kubectl delete pvc --all --namespace syft || true'
bash -c 'kubectl delete secret --all --namespace syft || true'
Expand All @@ -1033,6 +1044,8 @@ commands =
description = Destroy local Kubernetes cluster
changedir = {toxinidir}/packages/grid
passenv=HOME, USER
setenv=
KUBE_CONTEXT = {env:KUBE_CONTEXT:k3d-syft-dev}
allowlist_externals =
tox
bash
Expand All @@ -1050,6 +1063,8 @@ commands =
description = Destroy both local Kubernetes cluster and registry
changedir = {toxinidir}
passenv=HOME, USER
setenv=
KUBE_CONTEXT = {env:KUBE_CONTEXT:k3d-syft-dev}
ignore_errors=True
allowlist_externals =
bash
Expand Down