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 mismatches and missing values.

Rationale

Ensures the deployed image aligns with the project version to avoid drift and confusion.

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

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 (mismatched)
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"

Configuration

This rule has no configuration.