Skip to content

Commit 2732a65

Browse files
feat(repo): apply GC OSS Repo Template
2 parents 543ba3b + a07c94d commit 2732a65

File tree

5 files changed

+196
-32
lines changed

5 files changed

+196
-32
lines changed

CODE_OF_CONDUCT.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
([Français](#code-de-conduite))
2+
3+
## Code of Conduct
4+
5+
Statistics Canada follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).
6+
7+
Please review before contributing issues, pull requests, or joining the GitHub organization.
8+
9+
______________________
10+
11+
## Code de conduite
12+
13+
Statistique Canada suit le [Code de conduite de la CNCF](https://github.com/cncf/foundation/blob/main/code-of-conduct-languages/fr.md).
14+
15+
Veuillez passer en revue avant de contribuer à des problèmes, des demandes d'extraction ou de rejoindre l'organisation GitHub.

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Contributing
2+
3+
([Français](#comment-contribuer))
4+
5+
## How to Contribute
6+
7+
When contributing, post comments and discuss changes you wish to make via Issues.
8+
9+
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.
10+
11+
If this is your first time contributing on GitHub, don't worry! Let us know if you have any questions.
12+
13+
### Security
14+
15+
**Do not post any security issues on the public repository!** See [SECURITY.md](SECURITY.md)
16+
17+
______________________
18+
19+
## Comment contribuer
20+
21+
Lorsque vous contribuez, veuillez également publier des commentaires et discuter des modifications que vous souhaitez apporter par l'entremise des enjeux (Issues).
22+
23+
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).
24+
25+
Si c'est la première fois que vous contribuez à GitHub, ne vous en faites pas! Faites-nous part de vos questions.
26+
27+
### Sécurité
28+
29+
**Ne publiez aucun problème de sécurité sur le dépôt publique!** Voir [SECURITY.md](SECURITY.md)
File renamed without changes.

README.md

Lines changed: 141 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
# Kubernetes Namespace Cleaner
22

3-
<p align="center">
4-
<img src="https://github.com/user-attachments/assets/7f10d356-9312-4483-aea0-33aeef6880d9" alt="Namespace Cleaner Logo" width="400"/>
5-
</p>
3+
[(Français)](#nettoyeur-de-namespaces-kubernetes)
64

5+
## Kubernetes Namespace Cleaner
76

8-
A Kubernetes CronJob that automatically identifies and cleans up namespaces tied to deprovisioned Azure Entra ID (formerly Azure AD) users.
7+
A Kubernetes CronJob that automatically detects and deletes namespaces associated with deprovisioned Azure Entra ID (formerly Azure AD) users.
98

10-
## Development Status
9+
### What is this project?
1110

12-
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/StatCan/namespace-cleaner)
11+
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.
12+
13+
### How does it work?
14+
15+
It runs in two phases:
16+
17+
1. **Evaluation**: Identifies new namespaces and checks if the associated user is valid.
18+
2. **Cleanup**: Deletes namespaces labeled for removal after a grace period, if the user is still missing.
19+
20+
It supports mock, dry-run, and production modes.
21+
22+
### Who will use this project?
23+
24+
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.
25+
26+
### What is the goal of this project?
1327

14-
## Overview
28+
To safely and automatically manage orphaned namespaces, reduce security risk, and maintain cluster cleanliness without manual intervention.
29+
30+
## System Overview
31+
32+
### Phase 1: New Namespace Evaluation (English)
1533

16-
### Phase 1: New Namespace Evaluation
1734
```mermaid
1835
flowchart TD
1936
A[Start] --> B{Mode}
@@ -27,8 +44,8 @@ flowchart TD
2744
G2 -->|Missing| I[Label for Deletion]
2845
G2 -->|Exists| J[No Action]
2946
```
47+
### Phase 2: Expired Namespace Cleanup (English)
3048

31-
### Phase 2: Expired Namespace Cleanup
3249
```mermaid
3350
flowchart TD
3451
K[Start] --> L[Check Labeled Namespaces]
@@ -38,40 +55,45 @@ flowchart TD
3855
N -->|Yes| P[Delete Namespace]
3956
N -->|No| Q[Remove Label]
4057
```
58+
## Key Features
4159

42-
## Features
43-
-**Automated Lifecycle Management**: Label-based namespace management
44-
- 🔒 **Security First**: Azure Entra ID integration with domain allowlisting
45-
- 🧪 **Testing Friendly**: Local testing mode with mock data
46-
- ☁️ **Safe Operations**: Dry-run capability for pre-deployment validation
60+
***Automated Lifecycle Management** – Label-based namespace retention system
61+
* 🔒 **Security First** – Azure Entra ID user verification with domain allowlist
62+
* 🧪 **Testing Friendly** – Mock and dry-run support
63+
* ☁️ **Safe Operations** – Prevent accidental deletion through preview-only mode
4764

4865
## Quick Start
66+
4967
```bash
5068
# Clone & Setup
5169
git clone https://github.com/StatCan/namespace-cleaner.git
5270
cd namespace-cleaner
5371

54-
# Build the Docker image (required for all other operations)
72+
# Build the Docker image
5573
make image
5674

5775
# Run unit tests
5876
make test-unit
5977

60-
# Perform a dry-run on a real cluster
78+
# Perform a dry-run (no real deletion)
6179
make dry-run
6280

63-
# Deploy to production
81+
# Deploy in production
6482
make run
6583
```
6684

6785
## CI/CD Integration
68-
Our GitHub Actions workflow provides:
69-
- ✅ Automatic test coverage tracking
70-
- 🔒 Security scanning with Trivy
71-
- 📦 Docker image builds on push
72-
- 📈 Live coverage badge updates
86+
87+
Our GitHub Actions pipeline includes:
88+
89+
* ✅ Unit testing and dry-run validation
90+
* 🔒 Trivy-based container image vulnerability scanning
91+
* 📦 Docker builds on push
92+
* 📈 Live test coverage badge generation
93+
7394

7495
## Configuration
96+
7597
```yaml
7698
# configmap.yaml
7799
---
@@ -82,24 +104,111 @@ metadata:
82104
namespace: das
83105
data:
84106
ALLOWED_DOMAINS: "statcan.gc.ca,cloud.statcan.ca"
85-
GRACE_PERIOD: "90d" # Format: <number><unit> (h=hours, d=days)
107+
GRACE_PERIOD: "90d" # e.g. "24h", "30d"
86108
```
87109
88110
## Monitoring & Troubleshooting
111+
89112
```bash
90-
# View logs
113+
# View job logs
91114
kubectl logs -l job-name=namespace-cleaner
92115

93-
# Check cronjob status
116+
# View cronjob status
94117
kubectl get cronjob namespace-cleaner -o wide
95118

96-
# Full system reset
119+
# Reset everything
97120
make stop && make clean && make run
98121
```
99122

100-
## Contributing
101-
1. Fork the repository
102-
2. Create feature branch (`git checkout -b feature/your-feature`)
103-
3. Commit changes with tests (`make test`)
104-
4. Push to branch (`git push origin feature/your-feature`)
105-
5. Open PR with coverage badge verification
123+
### Development Status
124+
125+
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/StatCan/namespace-cleaner)
126+
127+
### How to Contribute
128+
129+
See [CONTRIBUTING.md](CONTRIBUTING.md)
130+
131+
### License
132+
133+
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).
134+
135+
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).
136+
137+
---
138+
139+
## Nettoyeur de Namespaces Kubernetes
140+
141+
[(English)](#kubernetes-namespace-cleaner)
142+
143+
### Quel est ce projet?
144+
145+
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.
146+
147+
### Comment ça marche?
148+
149+
Le CronJob fonctionne en deux phases :
150+
151+
1. **Évaluation** : identifie les nouveaux espaces de noms et vérifie si l'utilisateur associé est valide.
152+
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.
153+
154+
Trois modes sont disponibles : test, simulation (dry-run) et production.
155+
156+
### Qui utilisera ce projet?
157+
158+
Les administrateurs de clusters Kubernetes dans des environnements partagés (tel que Kubeflow), intégrés avec Entra ID.
159+
160+
### Quel est le but de ce projet?
161+
162+
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.
163+
164+
---
165+
166+
#### Comment contribuer
167+
168+
Voir [CONTRIBUTING.md](CONTRIBUTING.md)
169+
170+
---
171+
172+
#### Licence
173+
174+
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).
175+
176+
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).
177+
178+
---
179+
180+
### Phase 1: Évaluation des nouveaux namespaces (Français)
181+
182+
```mermaid
183+
flowchart TD
184+
A[Début] --> B{Mode}
185+
B -->|Test| C[Utiliser des données simulées]
186+
B -->|Simulation| D[Afficher les actions]
187+
B -->|Production| E[Authentification Azure réelle]
188+
C & D & E --> F[Analyser les nouveaux espaces de noms]
189+
F --> G1{Domaine valide ?}
190+
G1 -->|Oui| G2{Utilisateur existant ?}
191+
G1 -->|Non| H[Consigner et ignorer]
192+
G2 -->|Inexistant| I[Étiqueter pour suppression]
193+
G2 -->|Existant| J[Aucune action]
194+
```
195+
196+
### Phase 2 : Nettoyage des espaces de noms expirés (Français)
197+
198+
```mermaid
199+
flowchart TD
200+
K[Début] --> L[Analyser les espaces de noms étiquetés]
201+
L --> M{Délai de grâce expiré ?}
202+
M -->|Oui| N{Utilisateur toujours inexistant ?}
203+
M -->|Non| O[Garder l'espace de noms]
204+
N -->|Oui| P[Supprimer l'espace de noms]
205+
N -->|Non| Q[Retirer l'étiquette]
206+
```
207+
208+
## Fonctionnalités principales
209+
210+
***Gestion automatisée du cycle de vie** – Système de conservation basé sur des étiquettes
211+
* 🔒 **Sécurité avant tout** – Vérification des utilisateurs avec Entra ID et liste de domaines autorisés
212+
* 🧪 **Tests facilités** – Prise en charge des modes test et simulation
213+
* ☁️ **Sécurité des opérations** – Empêche les suppressions accidentelles grâce au mode aperçu
214+

SECURITY.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
([Français](#sécurité))
2+
3+
# Security
4+
5+
**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`
6+
7+
______________________
8+
9+
## Sécurité
10+
11+
**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`

0 commit comments

Comments
 (0)