Deployment and Service Image Versions Match POM (SL007)
Validates kubernetes/base deployment.yaml image tag and service.yaml build.version match the POM version, and each other.
Description
Reads kubernetes/base/service.yaml and deployment.yaml to extract build.version and image tag, and compares both with the POM version (without -SNAPSHOT). Reports ERROR violations for mismatches and missing values.
Findings
-
ERROR
-
deployment.yaml image version does not match service.yaml build.version
-
service.yaml build.version does not match POM version
-
deployment.yaml image version does not match POM version
-
service.yaml or deployment.yaml not found
-
Could not find version in POM file
-
Could not find build.version in service.yaml
-
Could not find image version in deployment.yaml
-
Error checking kubernetes files
-
Noncompliant
Mismatched image and build.version
# deployment.yaml (mismatched)
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-service
spec:
template:
spec:
containers:
- name: my-service
image: nexus/mapsandbox/my-service:1.2.0
---
# service.yaml version mismatch and also service.yaml not found
#apiVersion: v1
#kind: Service
#metadata:
# name: my-service
# annotations:
# build.version: "1.3.0"
Compliant
Matching image, build.version, and POM
# deployment.yaml (matching)
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-service
spec:
template:
spec:
containers:
- name: my-service
image: nexus/mapsandbox/my-service:1.3.0
---
# service.yaml (matching)
apiVersion: v1
kind: Service
metadata:
name: my-service
annotations:
build.version: "1.3.0"