Skip to content

Commit 3f19e1d

Browse files
authored
Add support for DaemonSet, StatefulSet, Job, and CronJob workloads (#72)
Extend the controller to track pods owned by all standard Kubernetes workload types, not just Deployments. Includes short-lived Job detection via terminal phase handling, CronJob name resolution through Job ownership chain, and RBAC/docs updates.
1 parent c6bb7f8 commit 3f19e1d

File tree

8 files changed

+1398
-48
lines changed

8 files changed

+1398
-48
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ Two modes of authentication are supported:
8080

8181
The `DN_TEMPLATE` supports the following placeholders:
8282
- `{{namespace}}` - Pod namespace
83-
- `{{deploymentName}}` - Name of the owning Deployment
83+
- `{{deploymentName}}` - Name of the owning workload (Deployment, DaemonSet, StatefulSet, CronJob, or Job)
8484
- `{{containerName}}` - Container name
8585

8686
## Annotations
87-
Runtime risks and custom tags can be added to deployment records using annotations. Annotations will be aggregated from the pod and its owner reference objects (e.g. Deployment, ReplicaSet) so they can be added at any level of the ownership hierarchy.
87+
Runtime risks and custom tags can be added to deployment records using annotations. Annotations will be aggregated from the pod and its owner reference objects (e.g. Deployment, ReplicaSet, DaemonSet, StatefulSet, CronJob, Job) so they can be added at any level of the ownership hierarchy.
8888

8989
### Runtime Risks
9090

@@ -110,7 +110,7 @@ which includes:
110110

111111
- **Namespace**: `deployment-tracker`
112112
- **ServiceAccount**: Identity for the controller pod
113-
- **ClusterRole**: Minimal permissions (`get`, `list`, `watch` on pods and deployments; `get` on other supported objects)
113+
- **ClusterRole**: Minimal permissions (`get`, `list`, `watch` on pods, deployments, daemonsets, statefulsets, jobs, and cronjobs; `get` on replicasets)
114114
- **ClusterRoleBinding**: Binds the ServiceAccount to the ClusterRole
115115
- **Deployment**: Runs the controller with security hardening
116116

@@ -142,6 +142,10 @@ The controller requires the following minimum permissions:
142142
| `""` (core) | `pods` | `get`, `list`, `watch` |
143143
| `apps` | `deployments` | `get`, `list`, `watch` |
144144
| `apps` | `replicasets` | `get` |
145+
| `apps` | `daemonsets` | `get`, `list`, `watch` |
146+
| `apps` | `statefulsets` | `get`, `list`, `watch` |
147+
| `batch` | `jobs` | `get`, `list`, `watch` |
148+
| `batch` | `cronjobs` | `get`, `list`, `watch` |
145149

146150
If you only need to monitor a single namespace, you can modify the manifest to use a `Role` and `RoleBinding` instead of `ClusterRole` and `ClusterRoleBinding` for more restricted permissions.
147151

deploy/charts/deployment-tracker/templates/clusterrole.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,28 @@ rules:
2727
- replicasets
2828
verbs:
2929
- get
30+
- apiGroups:
31+
- apps
32+
resources:
33+
- daemonsets
34+
verbs:
35+
- get
36+
- list
37+
- watch
38+
- apiGroups:
39+
- apps
40+
resources:
41+
- statefulsets
42+
verbs:
43+
- get
44+
- list
45+
- watch
46+
- apiGroups:
47+
- batch
48+
resources:
49+
- jobs
50+
- cronjobs
51+
verbs:
52+
- get
53+
- list
54+
- watch

deploy/manifest.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ rules:
2323
- apiGroups: ["apps"]
2424
resources: ["replicasets"]
2525
verbs: ["get"]
26+
- apiGroups: ["apps"]
27+
resources: ["daemonsets"]
28+
verbs: ["get", "list", "watch"]
29+
- apiGroups: ["apps"]
30+
resources: ["statefulsets"]
31+
verbs: ["get", "list", "watch"]
32+
- apiGroups: ["batch"]
33+
resources: ["jobs", "cronjobs"]
34+
verbs: ["get", "list", "watch"]
2635
---
2736
apiVersion: rbac.authorization.k8s.io/v1
2837
kind: ClusterRoleBinding

0 commit comments

Comments
 (0)