Skip to content
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

fix: Avoid classifying K8S002 on zero-replica workloads #51

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eksup/src/k8s/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ impl checks::K8sFindings for StdResource {

match replicas {
Some(replicas) => {
if replicas < 3 {
if replicas < 3 && replicas > 0 {
let remediation = finding::Remediation::Required;
let finding = finding::Finding {
code: finding::Code::K8S002,
Expand Down
48 changes: 48 additions & 0 deletions tests/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,51 @@ spec:
- name: tmp
hostPath:
path: /tmp
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ignored-dpl
namespace: deployment
labels:
app: ignored-dpl
spec:
replicas: 0
minReadySeconds: 0
selector:
matchLabels:
app: ignored-dpl
template:
metadata:
labels:
app: ignored-dpl
spec:
topologySpreadConstraints:
- maxSkew: 1
whenUnsatisfiable: ScheduleAnyway
topologyKey: topology.kubernetes.io/zone
labelSelector:
matchLabels:
app: ignored-dpl
containers:
- name: goproxy
image: registry.k8s.io/goproxy:0.1
ports:
- containerPort: 8080
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
hostPath:
path: /tmp