-
Notifications
You must be signed in to change notification settings - Fork 0
feat(repo): apply GC OSS Repo Template #55
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
11d0ee0
feat(repo): apply GC OSS Repo Template
bryanpaget ddfae35
feat(repo): apply GC OSS Repo Template
bryanpaget 835aa47
feat(i18n): update French translation
bryanpaget 891d769
Update SECURITY.md
bryanpaget a286eb6
Update README.md
bryanpaget b7f7a94
Update LICENSE.md
bryanpaget bda0331
Update LICENSE.md
bryanpaget c5d2bfe
Update README.md
bryanpaget b3c34e2
Update README.md
bryanpaget b6c0168
Update README.md
bryanpaget ab7d961
Update and rename LICENSE.md to LICENSE
bryanpaget 1f893ac
Update README.md
bryanpaget 06b3d09
feat(repo): apply GC OSS Repo Template
bryanpaget 31c0f1f
feat(README.md): update language (delete vs remove)
bryanpaget a07c94d
fix(readme): separate fr/en
Souheil-Yazji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ([Français](#code-de-conduite)) | ||
|
|
||
| ## Code of Conduct | ||
|
|
||
| Statistics Canada follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md). | ||
|
|
||
| Please review before contributing issues, pull requests, or joining the GitHub organization. | ||
|
|
||
| ______________________ | ||
|
|
||
| ## Code de conduite | ||
|
|
||
| Statistique Canada suit le [Code de conduite de la CNCF](https://github.com/cncf/foundation/blob/main/code-of-conduct-languages/fr.md). | ||
|
|
||
| Veuillez passer en revue avant de contribuer à des problèmes, des demandes d'extraction ou de rejoindre l'organisation GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Contributing | ||
|
|
||
| ([Français](#comment-contribuer)) | ||
|
|
||
| ## How to Contribute | ||
|
|
||
| When contributing, post comments and discuss changes you wish to make via Issues. | ||
|
|
||
| Feel free to propose changes by creating Pull Requests. If you don't have write access, editing a file will create a Fork of this project for you to save your proposed changes to. Submitting a change to a file will write it to a new Branch in your Fork, so you can send a Pull Request. | ||
|
|
||
| If this is your first time contributing on GitHub, don't worry! Let us know if you have any questions. | ||
|
|
||
| ### Security | ||
|
|
||
| **Do not post any security issues on the public repository!** See [SECURITY.md](SECURITY.md) | ||
|
|
||
| ______________________ | ||
|
|
||
| ## Comment contribuer | ||
|
|
||
| Lorsque vous contribuez, veuillez également publier des commentaires et discuter des modifications que vous souhaitez apporter par l'entremise des enjeux (Issues). | ||
|
|
||
| N'hésitez pas à proposer des modifications en créant des demandes de tirage (Pull Requests). Si vous n'avez pas accès au mode de rédaction, la modification d'un fichier créera une copie (Fork) de ce projet afin que vous puissiez enregistrer les modifications que vous proposez. Le fait de proposer une modification à un fichier l'écrira dans une nouvelle branche dans votre copie (Fork), de sorte que vous puissiez envoyer une demande de tirage (Pull Request). | ||
|
|
||
| Si c'est la première fois que vous contribuez à GitHub, ne vous en faites pas! Faites-nous part de vos questions. | ||
|
|
||
| ### Sécurité | ||
|
|
||
| **Ne publiez aucun problème de sécurité sur le dépôt publique!** Voir [SECURITY.md](SECURITY.md) | ||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,36 @@ | ||
| # Kubernetes Namespace Cleaner | ||
|
|
||
| <p align="center"> | ||
| <img src="https://github.com/user-attachments/assets/7f10d356-9312-4483-aea0-33aeef6880d9" alt="Namespace Cleaner Logo" width="400"/> | ||
| </p> | ||
| [(Français)](#nettoyeur-de-namespaces-kubernetes) | ||
|
|
||
| ## Kubernetes Namespace Cleaner | ||
|
|
||
| A Kubernetes CronJob that automatically identifies and cleans up namespaces tied to deprovisioned Azure Entra ID (formerly Azure AD) users. | ||
| A Kubernetes CronJob that automatically detects and deletes namespaces associated with deprovisioned Azure Entra ID (formerly Azure AD) users. | ||
|
|
||
| ## Development Status | ||
| ### What is this project? | ||
|
|
||
|  | ||
| A lifecycle automation tool for Kubernetes namespaces. It identifies user-created namespaces, verifies user status through Azure Entra ID, and labels or deletes expired ones. | ||
|
|
||
| ### How does it work? | ||
|
|
||
| It runs in two phases: | ||
|
|
||
| 1. **Evaluation**: Identifies new namespaces and checks if the associated user is valid. | ||
| 2. **Cleanup**: Deletes namespaces labeled for removal after a grace period, if the user is still missing. | ||
|
|
||
| It supports mock, dry-run, and production modes. | ||
|
|
||
| ### Who will use this project? | ||
|
|
||
| Cluster administrators who need to enforce namespace hygiene and lifecycle policies in environments integrated with Entra ID, especially in multi-tenant Kubernetes platforms like Kubeflow. | ||
|
|
||
| ### What is the goal of this project? | ||
|
|
||
| ## Overview | ||
| To safely and automatically manage orphaned namespaces, reduce security risk, and maintain cluster cleanliness without manual intervention. | ||
|
|
||
| ## System Overview | ||
|
|
||
| ### Phase 1: New Namespace Evaluation (English) | ||
|
|
||
| ### Phase 1: New Namespace Evaluation | ||
| ```mermaid | ||
| flowchart TD | ||
| A[Start] --> B{Mode} | ||
|
|
@@ -27,8 +44,8 @@ flowchart TD | |
| G2 -->|Missing| I[Label for Deletion] | ||
| G2 -->|Exists| J[No Action] | ||
| ``` | ||
| ### Phase 2: Expired Namespace Cleanup (English) | ||
|
|
||
| ### Phase 2: Expired Namespace Cleanup | ||
| ```mermaid | ||
| flowchart TD | ||
| K[Start] --> L[Check Labeled Namespaces] | ||
|
|
@@ -38,40 +55,45 @@ flowchart TD | |
| N -->|Yes| P[Delete Namespace] | ||
| N -->|No| Q[Remove Label] | ||
| ``` | ||
| ## Key Features | ||
|
|
||
| ## Features | ||
| - ✅ **Automated Lifecycle Management**: Label-based namespace management | ||
| - 🔒 **Security First**: Azure Entra ID integration with domain allowlisting | ||
| - 🧪 **Testing Friendly**: Local testing mode with mock data | ||
| - ☁️ **Safe Operations**: Dry-run capability for pre-deployment validation | ||
| * ✅ **Automated Lifecycle Management** – Label-based namespace retention system | ||
| * 🔒 **Security First** – Azure Entra ID user verification with domain allowlist | ||
| * 🧪 **Testing Friendly** – Mock and dry-run support | ||
| * ☁️ **Safe Operations** – Prevent accidental deletion through preview-only mode | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| # Clone & Setup | ||
| git clone https://github.com/StatCan/namespace-cleaner.git | ||
| cd namespace-cleaner | ||
|
|
||
| # Build the Docker image (required for all other operations) | ||
| # Build the Docker image | ||
| make image | ||
|
|
||
| # Run unit tests | ||
| make test-unit | ||
|
|
||
| # Perform a dry-run on a real cluster | ||
| # Perform a dry-run (no real deletion) | ||
| make dry-run | ||
|
|
||
| # Deploy to production | ||
| # Deploy in production | ||
| make run | ||
| ``` | ||
|
|
||
| ## CI/CD Integration | ||
| Our GitHub Actions workflow provides: | ||
| - ✅ Automatic test coverage tracking | ||
| - 🔒 Security scanning with Trivy | ||
| - 📦 Docker image builds on push | ||
| - 📈 Live coverage badge updates | ||
|
|
||
| Our GitHub Actions pipeline includes: | ||
|
|
||
| * ✅ Unit testing and dry-run validation | ||
| * 🔒 Trivy-based container image vulnerability scanning | ||
| * 📦 Docker builds on push | ||
| * 📈 Live test coverage badge generation | ||
|
|
||
|
|
||
| ## Configuration | ||
|
|
||
| ```yaml | ||
| # configmap.yaml | ||
| --- | ||
|
|
@@ -82,24 +104,111 @@ metadata: | |
| namespace: das | ||
| data: | ||
| ALLOWED_DOMAINS: "statcan.gc.ca,cloud.statcan.ca" | ||
| GRACE_PERIOD: "90d" # Format: <number><unit> (h=hours, d=days) | ||
| GRACE_PERIOD: "90d" # e.g. "24h", "30d" | ||
| ``` | ||
|
|
||
| ## Monitoring & Troubleshooting | ||
|
|
||
| ```bash | ||
| # View logs | ||
| # View job logs | ||
| kubectl logs -l job-name=namespace-cleaner | ||
|
|
||
| # Check cronjob status | ||
| # View cronjob status | ||
| kubectl get cronjob namespace-cleaner -o wide | ||
|
|
||
| # Full system reset | ||
| # Reset everything | ||
| make stop && make clean && make run | ||
| ``` | ||
|
|
||
| ## Contributing | ||
| 1. Fork the repository | ||
| 2. Create feature branch (`git checkout -b feature/your-feature`) | ||
| 3. Commit changes with tests (`make test`) | ||
| 4. Push to branch (`git push origin feature/your-feature`) | ||
| 5. Open PR with coverage badge verification | ||
| ### Development Status | ||
|
|
||
|  | ||
|
|
||
| ### How to Contribute | ||
|
|
||
| See [CONTRIBUTING.md](CONTRIBUTING.md) | ||
|
|
||
| ### License | ||
|
|
||
| Unless otherwise noted, the source code of this project is covered under Crown Copyright, Government of Canada, and is distributed under the [GNU Affero General Public License](LICENSE). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this, no suggestion, just a happy comment :) |
||
|
|
||
| The Canada wordmark and related graphics associated with this distribution are protected under trademark law and copyright law. No permission is granted to use them outside the parameters of the Government of Canada's corporate identity program. For more information, see [Federal identity requirements](https://www.canada.ca/en/treasury-board-secretariat/topics/government-communications/federal-identity-requirements.html). | ||
|
|
||
| --- | ||
|
|
||
| ## Nettoyeur de Namespaces Kubernetes | ||
|
|
||
| [(English)](#kubernetes-namespace-cleaner) | ||
|
|
||
| ### Quel est ce projet? | ||
|
|
||
| Un CronJob Kubernetes qui détecte et supprime automatiquement les espaces de noms associés aux utilisateurs Azure Entra ID (anciennement Azure AD) déprovisionnés. | ||
|
|
||
| ### Comment ça marche? | ||
|
|
||
| Le CronJob fonctionne en deux phases : | ||
|
|
||
| 1. **Évaluation** : identifie les nouveaux espaces de noms et vérifie si l'utilisateur associé est valide. | ||
| 2. **Nettoyage** : supprime les espaces de noms étiquetés pour suppression après un délai de grâce, si l'utilisateur est toujours inexistant. | ||
|
|
||
| Trois modes sont disponibles : test, simulation (dry-run) et production. | ||
|
|
||
| ### Qui utilisera ce projet? | ||
|
|
||
| Les administrateurs de clusters Kubernetes dans des environnements partagés (tel que Kubeflow), intégrés avec Entra ID. | ||
|
|
||
| ### Quel est le but de ce projet? | ||
|
|
||
| Réduire les risques de sécurité et garder un cluster propre grâce à la gestion automatique du cycle de vie des espaces de noms. | ||
|
|
||
| --- | ||
|
|
||
| #### Comment contribuer | ||
|
|
||
| Voir [CONTRIBUTING.md](CONTRIBUTING.md) | ||
|
|
||
| --- | ||
|
|
||
| #### Licence | ||
|
|
||
| Sauf indication contraire, le code source de ce projet est protégé par le droit d'auteur de la Couronne du gouvernement du Canada et distribué sous la [licence publique générale affero GNU](LICENSE). | ||
|
|
||
| Le mot-symbole « Canada » et les éléments graphiques connexes liés à cette distribution sont protégés en vertu des lois portant sur les marques de commerce et le droit d'auteur. Aucune autorisation n'est accordée pour leur utilisation à l'extérieur des paramètres du programme de coordination de l'image de marque du gouvernement du Canada. Pour obtenir davantage de renseignements à ce sujet, veuillez consulter les [Exigences pour l'image de marque](https://www.canada.ca/fr/secretariat-conseil-tresor/sujets/communications-gouvernementales/exigences-image-marque.html). | ||
|
|
||
| --- | ||
|
|
||
| ### Phase 1: Évaluation des nouveaux namespaces (Français) | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| A[Début] --> B{Mode} | ||
| B -->|Test| C[Utiliser des données simulées] | ||
| B -->|Simulation| D[Afficher les actions] | ||
| B -->|Production| E[Authentification Azure réelle] | ||
| C & D & E --> F[Analyser les nouveaux espaces de noms] | ||
| F --> G1{Domaine valide ?} | ||
| G1 -->|Oui| G2{Utilisateur existant ?} | ||
| G1 -->|Non| H[Consigner et ignorer] | ||
| G2 -->|Inexistant| I[Étiqueter pour suppression] | ||
| G2 -->|Existant| J[Aucune action] | ||
| ``` | ||
|
|
||
| ### Phase 2 : Nettoyage des espaces de noms expirés (Français) | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| K[Début] --> L[Analyser les espaces de noms étiquetés] | ||
| L --> M{Délai de grâce expiré ?} | ||
| M -->|Oui| N{Utilisateur toujours inexistant ?} | ||
| M -->|Non| O[Garder l'espace de noms] | ||
| N -->|Oui| P[Supprimer l'espace de noms] | ||
| N -->|Non| Q[Retirer l'étiquette] | ||
| ``` | ||
|
|
||
| ## Fonctionnalités principales | ||
|
|
||
| * ✅ **Gestion automatisée du cycle de vie** – Système de conservation basé sur des étiquettes | ||
| * 🔒 **Sécurité avant tout** – Vérification des utilisateurs avec Entra ID et liste de domaines autorisés | ||
| * 🧪 **Tests facilités** – Prise en charge des modes test et simulation | ||
| * ☁️ **Sécurité des opérations** – Empêche les suppressions accidentelles grâce au mode aperçu | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| ([Français](#sécurité)) | ||||||
|
|
||||||
| # Security | ||||||
|
|
||||||
| **Do not post any security issues on the public repository!** Security vulnerabilities must be reported by email to `statcan.cybersecurity-cybersecurite.statcan@statcan.gc.ca` | ||||||
|
|
||||||
| ______________________ | ||||||
|
|
||||||
| ## Sécurité | ||||||
|
|
||||||
| **Ne publiez aucun problème de sécurité sur le dépôt publique!** Les vulnérabilités de sécurité doivent être signalées par courriel à `statcan.cybersecurity-cybersecurite.statcan@statcan.gc.ca` | ||||||
|
||||||
| **Ne publiez aucun problème de sécurité sur le dépôt publique!** Les vulnérabilités de sécurité doivent être signalées par courriel à `statcan.cybersecurity-cybersecurite.statcan@statcan.gc.ca` | |
| **Ne publiez aucun problème de sécurité sur le dépôt public!** Les vulnérabilités de sécurité doivent être signalées par courriel à `statcan.cybersecurity-cybersecurite.statcan@statcan.gc.ca` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply the same correction here: use ‘dépôt public’ instead of ‘dépôt publique’.