Skip to content

feat: the kubernetes autodiscovery plugin should detect initcontainers update #4569

@luilegeant

Description

@luilegeant

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

TL;DR: In an k8s deployment manifest file, the initContainers section is ignored.

In the following manifest file (describes 1 pod deployment with some init containers), running the autodiscovery only find the spec.containers[*].image and ignores/skips the spec.initContainers[*].image.

---
# nextcloud pod
apiVersion: apps/v1
kind: Deployment
spec:
  selector:
    matchLabels:
      app: nextcloud
  template:
    metadata:
      labels:
        app: nextcloud
    spec:
      initContainers:
      - name: pre-sync-files
        image: nextcloud:30.0.6-apache
      - name: mariadb-isalive
        image: docker-registry1.mariadb.com/library/mariadb:11.4.3
      containers:
      - name: nextcloud
        image: nextcloud:30.0.8-apache

Expected Behavior

All container images should have a proposed update when running updatecli diff:

  • containers[0].image
  • initContainers[0].image (notice the image tag in the sample yaml is different between this and the above, i would love to fix my mistake using updatecli)
  • initContainers[1].image

Steps To Reproduce

  • Create a file test.yml with the above sample yaml (it's a lightweight version, but behaviour is the same if more complete)
  • use the latest (0.96.0 as of this writing) version of updatecli: updatecli diff

Results: only the spec.containers[0].image is suggested as a change, the initContainers section is completely ignored.

$> updatecli diff


+++++++++++
+ PREPARE +
+++++++++++


SCM repository retrieved: 0


++++++++++++++++++
+ AUTO DISCOVERY +
++++++++++++++++++



+++++++++++++++++++++++
+ LOCAL AUTODISCOVERY +
+++++++++++++++++++++++

WARNING: No platforms specified, we fallback to linux_amd64, linux_arm64, darwin_amd64, darwin_arm64


FLUX
=====
Manifest detected: 0


KUBERNETES
===========
Manifest detected: 1


KUBERNETES
===========
Manifest detected: 0


RANCHER FLEET
==============
Manifest detected: 0


TERRAGRUNT
===========
0 manifests identified
Manifest detected: 0


UPDATECLI
==========
Manifest detected: 0


ARGOCD
=======
Manifest detected: 0


DOCKER COMPOSE
===============
Manifest detected: 0


GITHUB ACTION
==============
Manifest detected: 0


HELMFILE
=========
Manifest detected: 0


MAVEN
======
Manifest detected: 0


NPM
====
0 manifests identified
Manifest detected: 0


TERRAFORM
==========
0 manifests identified
Manifest detected: 0


CARGO
======
Manifest detected: 0


HELM
=====
Manifest detected: 0


KO
===
Manifest detected: 0


DOCKERFILE
===========
Manifest detected: 0


GOLANG
=======
0 manifests identified
Manifest detected: 0


PRECOMMIT
==========
0 manifests identified
Manifest detected: 0


---

=> Total manifest detected: 1



++++++++++++
+ PIPELINE +
++++++++++++



#######################
# LOCAL AUTODISCOVERY #
#######################


##########################################
# DEPS: BUMP CONTAINER IMAGE "NEXTCLOUD" #
##########################################

source: source#nextcloud
----------------

Searching for version matching pattern ">=30.0.8-apache"
✔ Docker Image Tag "31.0.2-apache" found matching pattern ">=30.0.8-apache"

source: source#nextcloud-digest
-----------------------
✔ Docker Image Tag nextcloud:31.0.2-apache resolved to digest index.docker.io/library/nextcloud:31.0.2-apache@sha256:090040f97aa1cd6dbfe4c2a3483df41ca95e0abd1d63342e29d973c88a833a52

target: target#nextcloud
----------------
[transformers]
✔ Result correctly transformed from "31.0.2-apache@sha256:090040f97aa1cd6dbfe4c2a3483df41ca95e0abd1d63342e29d973c88a833a52" to "nextcloud:31.0.2-apache@sha256:090040f97aa1cd6dbfe4c2a3483df41ca95e0abd1d63342e29d973c88a833a52"

**Dry Run enabled**

⚠ - change detected:
	* key "$.spec.template.spec.containers[0].image" should be updated from "nextcloud:30.0.8-apache" to "nextcloud:31.0.2-apache@sha256:090040f97aa1cd6dbfe4c2a3483df41ca95e0abd1d63342e29d973c88a833a52", in file "data-light.yaml"


ACTIONS
========


=============================

SUMMARY:



✔ Local AutoDiscovery:

⚠ deps: bump container image "nextcloud":
	Source:
		✔ [nextcloud] get latest container image tag for "nextcloud"
		✔ [nextcloud-digest] get latest container image digest for "nextcloud:30.0.8-apache"
	Target:
		⚠ [nextcloud] deps: bump container image digest for "nextcloud:31.0.2-apache"


Run Summary
===========
Pipeline(s) run:
  * Changed:	1
  * Failed:	0
  * Skipped:	0
  * Succeeded:	1
  * Total:	2

Environment

- OS: ubuntu 22.04 lts
- updatecli: 0.96.0 (installed via deb from this very repository)

Pipeline Graph

No response

Anything else?

Could be a feature request or a bug, depending on how you see it ;-)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions