-
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
Changes from 14 commits
11d0ee0
ddfae35
835aa47
891d769
a286eb6
b7f7a94
bda0331
c5d2bfe
b3c34e2
b6c0168
ab7d961
1f893ac
06b3d09
31c0f1f
a07c94d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,99 @@ | ||
| # 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? | ||
|
|
||
| To safely and automatically manage orphaned namespaces, reduce security risk, and maintain cluster cleanliness without manual intervention. | ||
|
|
||
| --- | ||
|
|
||
| #### Development Status | ||
|
|
||
|  | ||
|
|
||
| ## Overview | ||
| --- | ||
|
|
||
| #### 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). | ||
|
|
||
| --- | ||
|
|
||
| ## System Overview | ||
|
|
||
| ### Phase 1: New Namespace Evaluation (English) | ||
|
|
||
| ### Phase 1: New Namespace Evaluation | ||
| ```mermaid | ||
| flowchart TD | ||
| A[Start] --> B{Mode} | ||
|
|
@@ -28,7 +108,24 @@ flowchart TD | |
| G2 -->|Exists| J[No Action] | ||
| ``` | ||
|
|
||
| ### Phase 2: Expired Namespace Cleanup | ||
| ### 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: Expired Namespace Cleanup (English) | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| K[Start] --> L[Check Labeled Namespaces] | ||
|
|
@@ -39,39 +136,78 @@ flowchart TD | |
| N -->|No| Q[Remove Label] | ||
| ``` | ||
|
|
||
| ## 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 | ||
| ### 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] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Key Features | ||
|
|
||
| * ✅ **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 | ||
|
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. Shouldn't this section be above with the rest of the english section? Sorry for all the comments lol |
||
|
|
||
| --- | ||
|
|
||
| ## 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 | ||
|
|
||
| --- | ||
|
|
||
| ## Quick Start / Démarrage rapide | ||
|
|
||
| ## Quick Start | ||
| ```bash | ||
| # Clone & Setup | ||
| # Clone & Setup / Clonage et configuration | ||
| 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 / Construire l'image Docker | ||
| make image | ||
|
|
||
| # Run unit tests | ||
| # Run unit tests / Exécuter les tests unitaires | ||
| make test-unit | ||
|
|
||
| # Perform a dry-run on a real cluster | ||
| # Perform a dry-run (no real deletion) / Lancer une simulation sans suppression réelle | ||
| make dry-run | ||
|
|
||
| # Deploy to production | ||
| # Deploy in production / Déployer en 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 | ||
| --- | ||
|
|
||
| ## CI/CD Integration / Intégration CI/CD | ||
|
|
||
| Our GitHub Actions pipeline includes: | ||
| Notre pipeline GitHub Actions comprend : | ||
|
|
||
| * ✅ Unit testing and dry-run validation | ||
| ✅ Tests unitaires et validation en mode simulation | ||
| * 🔒 Trivy-based container image vulnerability scanning | ||
| 🔒 Analyse de vulnérabilités des images avec Trivy | ||
| * 📦 Docker builds on push | ||
| 📦 Construction des images Docker lors des *push* | ||
| * 📈 Live test coverage badge generation | ||
| 📈 Génération d'un badge de couverture de test en temps réel | ||
|
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. Shouldn't the english and french be separated? |
||
|
|
||
| --- | ||
|
|
||
| ## Configuration | ||
|
|
||
| ```yaml | ||
| # configmap.yaml | ||
| --- | ||
|
|
@@ -82,24 +218,20 @@ 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 | ||
| --- | ||
|
|
||
| ## Monitoring & Troubleshooting / Surveillance et dépannage | ||
|
|
||
| ```bash | ||
| # View logs | ||
| # View job logs / Voir les journaux du job | ||
| kubectl logs -l job-name=namespace-cleaner | ||
|
|
||
| # Check cronjob status | ||
| # View cronjob status / Voir le statut du CronJob | ||
| kubectl get cronjob namespace-cleaner -o wide | ||
|
|
||
| # Full system reset | ||
| # Reset everything / Réinitialiser tous les composants | ||
| 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 | ||
| 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` |
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’.