diff --git a/helm-chart/kube-hpa-scale-to-zero/templates/rbac.yaml b/helm-chart/kube-hpa-scale-to-zero/templates/rbac.yaml index b96f8ab..e006cb6 100644 --- a/helm-chart/kube-hpa-scale-to-zero/templates/rbac.yaml +++ b/helm-chart/kube-hpa-scale-to-zero/templates/rbac.yaml @@ -29,6 +29,7 @@ metadata: subjects: - kind: ServiceAccount name: {{ include "kube-hpa-scale-to-zero.serviceAccountName" . }} + # namespace: {{ .Release.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role diff --git a/tests/e2e_test.py b/tests/e2e_test.py index 250b635..46e60b4 100644 --- a/tests/e2e_test.py +++ b/tests/e2e_test.py @@ -9,6 +9,7 @@ TESTS_PATH = Path(__file__).parent MANIFESTS_PATH = TESTS_PATH / "manifests" +TEST_NS = "test-ns" TIMEOUT = SYNC_INTERVAL * 3 @@ -26,6 +27,7 @@ def run(*, command: list[str], **kw_args) -> str: @pytest.fixture(scope="session") def setup(): try: + run(command=["kubectl", "create", "namespace", TEST_NS]) run( command=[ "helm", @@ -75,18 +77,19 @@ def setup(): ] ) run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/metrics-generator.yaml"]) + run(command=["kubectl", "delete", "namespace", TEST_NS]) def deploy_target(manifest: str): - run(command=["kubectl", "apply", "-f", f"{MANIFESTS_PATH}/{manifest}"]) + run(command=["kubectl", "apply", "-f", f"{MANIFESTS_PATH}/{manifest}", "--namespace", TEST_NS]) def delete_target(manifest: str): - run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/{manifest}"]) + run(command=["kubectl", "delete", "-f", f"{MANIFESTS_PATH}/{manifest}", "--namespace", TEST_NS]) def run_scaler(): - return subprocess.Popen(["python", f"{TESTS_PATH.parent}/main.py"]) + return subprocess.Popen(["python", f"{TESTS_PATH.parent}/main.py", "--hpa-namespace", TEST_NS]) def set_foo_metric_value(value: int): @@ -111,6 +114,8 @@ def wait_deployment_scale(*, name: str, replicas: int): f"--for=jsonpath={{.spec.replicas}}={replicas}", "deployment", name, + "--namespace", + TEST_NS, f"--timeout={TIMEOUT}s", ] )