{"id":35797942,"url":"https://github.com/canonical/namespace-node-affinity-operator","last_synced_at":"2026-03-10T13:06:35.963Z","repository":{"id":65492872,"uuid":"585952349","full_name":"canonical/namespace-node-affinity-operator","owner":"canonical","description":"Juju Charm for the Namespace Node Affinity tool","archived":false,"fork":false,"pushed_at":"2026-03-04T22:29:35.000Z","size":140,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-03-05T04:16:26.978Z","etag":null,"topics":["charm","charmed-kubeflow","single-charm"],"latest_commit_sha":null,"homepage":"https://github.com/canonical/namespace-node-affinity-operator","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/canonical.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-06T14:37:32.000Z","updated_at":"2026-02-26T10:06:33.000Z","dependencies_parsed_at":"2026-01-07T13:02:58.936Z","dependency_job_id":null,"html_url":"https://github.com/canonical/namespace-node-affinity-operator","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/canonical/namespace-node-affinity-operator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fnamespace-node-affinity-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fnamespace-node-affinity-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fnamespace-node-affinity-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fnamespace-node-affinity-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canonical","download_url":"https://codeload.github.com/canonical/namespace-node-affinity-operator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fnamespace-node-affinity-operator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30334412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T12:41:07.687Z","status":"ssl_error","status_checked_at":"2026-03-10T12:41:06.728Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charm","charmed-kubeflow","single-charm"],"created_at":"2026-01-07T10:20:14.856Z","updated_at":"2026-03-10T13:06:35.957Z","avatar_url":"https://github.com/canonical.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Namespace Node Affinity Operator\n\nThis Charm deploys a modified version of the [Namespace Node Affinity](https://github.com/idgenchev/namespace-node-affinity) Kubernetes MutatingWebhook. \n\nThe Namespace Node Affinity webhook allows a user to add a given set of node affinities and/or tolerations to all pods deployed in a namespace.  This is useful for example in a case where you have a cluster that has some nodes with specific labels (eg: nodes labeled `control-plane`) and you want all workloads in a Kubernetes namespace to be deployed only on those nodes and not any others in the cluster.  More descriptions of the tool are given in the [upstream README.md](https://github.com/idgenchev/namespace-node-affinity).\n\n## Usage\n\nThis charm is deployed using the Juju command line tool as follows:\n\n```bash\njuju deploy namespace-node-affinity --trust\n```\n\nBy default, the webhook is not configured to modify pods in any namespace.  To add namespaces to its scope, the user must:\n* provide a `settings_yaml` config file\n* label any namespace we want to work on with the label `namespace-node-affinity=enabled`\n\nThese configurations can be modified during charm runtime, and the webhook always uses the most up to date value.  \n\n### Defining `settings_yaml`\n\nWe must provide the `settings_yaml` config, which is a YAML string as described [upstream](https://github.com/idgenchev/namespace-node-affinity/blob/42674ec6863d38cbc1009e2f83243a5782aa608a/examples/sample_configmap.yaml#L8).  For example, we can configure the tool to apply:\n\n* apply a node affinity for pods in `testing-ns-a` to look for pods with the label `control-plane=true`, but only to pods that do not have the label `ignoreme: ignored`\n* apply a node affinity for pods in `testing-ns-b` to look for pods with the label `other-key: other-value`\n\nby setting the charm config:\n\n```bash\ncat \u003c\u003cEOF \u003e settings.yaml\n\ntesting-ns-a: |\n  nodeSelectorTerms:\n    - matchExpressions:\n      - key: control-plane\n        operator: In\n        values:\n        - true\n  excludedLabels:\n    ignoreme: ignored\ntesting-ns-b: |\n  nodeSelectorTerms:\n    - matchExpressions:\n      - key: other-key\n        operator: In\n        values:\n        - other-value\nEOF\nSETTINGS_YAML=$(cat settings.yaml)\njuju config namespace-node-affinity settings_yaml=\"$SETTINGS_YAML\"\n```\n\n### Setting the namespace labels\n\nWe must apply the label `namespace-node-affinity=enabled` to all namespaces being acted on by this tool (this is a requirement by the tool itself, not the chaming application.  We might change this in future as it feels like a redundant setting).  For example, you can do:\n\n```bash\nkubectl label ns testing-ns-a namespace-node-affinity=enabled\nkubectl label ns testing-ns-b namespace-node-affinity=enabled\n```\n\n## Development\n\nWhen debugging this charm, it is sometimes useful to send `AdmissionReview` JSON payloads to the webhook pod in the same format as what the Kubernetes API would send in order to check if the webhook pods are working properly.  To facilitate that, [this tool](https://github.com/ca-scribner/kubernetes-webhook-testers/tree/main/namespace-node-affinity-tester) was used during charm development and might be useful.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanonical%2Fnamespace-node-affinity-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanonical%2Fnamespace-node-affinity-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanonical%2Fnamespace-node-affinity-operator/lists"}