Skip to content

Commit

Permalink
change kubernetes.io/ label from name to instance (#973)
Browse files Browse the repository at this point in the history
* Fix #972 change label from name to instance

* Fix tests

* more references

* fix check

* Fix example config
  • Loading branch information
sudermanjr committed Jul 13, 2023
1 parent d55cd4b commit e7eb079
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
successMessage: Label app.kubernetes.io/name matches metadata.name
failureMessage: Label app.kubernetes.io/name must match metadata.name
successMessage: Label app.kubernetes.io/instance matches metadata.name
failureMessage: Label app.kubernetes.io/instance must match metadata.name
category: Reliability
target: Controller
schema:
Expand All @@ -12,7 +12,7 @@ schema:
properties:
labels:
type: object
required: ["app.kubernetes.io/name"]
required: ["app.kubernetes.io/instance"]
properties:
app.kubernetes.io/name:
app.kubernetes.io/instance:
const: "{{ .metadata.name }}"
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ meta:

---

## Unreleased
* Change `metadataAndNameMismatched` to `metadataAndInstanceMismatched`

## 8.1.1
* Add category for `metadataAndNameMismatched`.
* Fix category for `priorityClassNotSet`.
Expand Down
4 changes: 2 additions & 2 deletions docs/checks/reliability.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ key | default | description
`priorityClassNotSet` | `warning` | Fails when a priorityClassName is not set for a pod.
`deploymentMissingReplicas` | `warning` | Fails when there is only one replica for a deployment.
`missingPodDisruptionBudget` | `warning` | Fails when PDB is missing.
`metadataAndNameMismatched` | `warning` | Fails when label `app.kubernetes.io/name` and `metadata.name` mismatch
`metadataAndInstanceMismatched` | `warning` | Fails when label `app.kubernetes.io/instance` and `metadata.name` mismatch
`topologySpreadConstraint` | `warning` | Fails when there is no topology spread constraint on the pod

## Background
Expand Down Expand Up @@ -70,4 +70,4 @@ spec:
- [Kubernetes Docs: Configure Liveness and Readiness Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/)
- [Utilizing Kubernetes Liveness and Readiness Probes to Automatically Recover From Failure](https://medium.com/spire-labs/utilizing-kubernetes-liveness-and-readiness-probes-to-automatically-recover-from-failure-2fe0314f2b2e)
- [Kubernetes Liveness and Readiness Probes: How to Avoid Shooting Yourself in the Foot](https://blog.colinbreck.com/kubernetes-liveness-and-readiness-probes-how-to-avoid-shooting-yourself-in-the-foot/)
- [Topology Spread Constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/)
- [Topology Spread Constraints](https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/)
2 changes: 1 addition & 1 deletion examples/config-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ checks:
topologySpreadConstraint: warning
pdbDisruptionsIsZero: warning
missingPodDisruptionBudget: warning
metadataAndNameMismatched: warning
metadataAndInstanceMismatched: warning

# efficiency
cpuRequestsMissing: warning
Expand Down
2 changes: 1 addition & 1 deletion examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ checks:
pullPolicyNotAlways: warning
readinessProbeMissing: warning
livenessProbeMissing: warning
metadataAndNameMismatched: warning
metadataAndInstanceMismatched: warning
pdbDisruptionsIsZero: warning
missingPodDisruptionBudget: warning
topologySpreadConstraint: warning
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
// Other checks
"tlsSettingsMissing",
"pdbDisruptionsIsZero",
"metadataAndNameMismatched",
"metadataAndInstanceMismatched",
"missingPodDisruptionBudget",
"missingNetworkPolicy",
"sensitiveConfigmapContent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Pod
metadata:
name: nginx
labels:
app.kubernetes.io/name: not-nginx
app.kubernetes.io/instance: not-nginx
spec:
containers:
- name: nginx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Pod
metadata:
name: nginx
labels:
app.kubernetes.io/name: nginx
app.kubernetes.io/instance: nginx
spec:
containers:
- name: nginx
Expand Down

0 comments on commit e7eb079

Please sign in to comment.