Commit 249dd7f
feat: Add support for custom pod labels, annotations, and security contexts (#777)
This commit implements support for configuring custom labels, annotations,
and security contexts for K8sGPT pods, addressing issue #776.
Changes:
- Add PodLabels field to allow custom labels for organizational tracking,
service mesh integration, and monitoring purposes
- Add PodAnnotations field for integration with monitoring systems,
service meshes, and other infrastructure components
- Add SecurityContext field for pod-level security configuration to
comply with organizational security policies and Pod Security Standards
- Add ContainerSecurityContext field for container-level security
constraints (runAsNonRoot, readOnlyRootFilesystem, capabilities, etc.)
The implementation:
- Extends the K8sGPT CRD with four new optional fields
- Updates the GetDeployment function to merge custom labels with defaults
and apply custom annotations and security contexts to pod templates
- Regenerates CRD manifests with all new field definitions
- Provides a comprehensive example configuration demonstrating secure
deployment with strict security policies
Benefits:
- Enables K8sGPT deployment in security-hardened environments with
admission policies (Kyverno, OPA Gatekeeper, Pod Security Standards)
- Allows proper integration with monitoring, logging, and service mesh
systems through custom metadata
- Supports multi-tenancy with cost allocation and resource tracking
- Maintains backward compatibility as all new fields are optional
Fixes #776
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Co-authored-by: Alex Jones <1235925+AlexsJones@users.noreply.github.com>1 parent b58dc1e commit 249dd7f
File tree
4 files changed
+541
-4
lines changed- api/v1alpha1
- config
- crd/bases
- samples
- pkg/resources
4 files changed
+541
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
177 | 189 | | |
178 | 190 | | |
179 | 191 | | |
| |||
0 commit comments