Skip to content
Open
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
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.27-alpine@sha256:70bd7ddea8b6cbe5d6943cde279d6b67feb10cc924fb9100d1d8757c1575b280 AS builder

COPY . /app/
WORKDIR /app/
Expand All @@ -9,11 +9,13 @@ ARG TARGETOS TARGETARCH
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o ./bin/version-checker ./cmd/.


FROM alpine:3.24
FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
LABEL description="Kubernetes utility for exposing used image versions compared to the latest version, as metrics."

RUN apk --no-cache upgrade && apk --no-cache add ca-certificates

COPY --from=builder /app/bin/version-checker /usr/bin/version-checker

USER 65534:65534

ENTRYPOINT ["/usr/bin/version-checker"]
9 changes: 6 additions & 3 deletions deploy/charts/version-checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ A Helm chart for version-checker
| docker.token | string | `nil` | Token to authenticate with docker registry. Cannot be used with `docker.username` / `docker.password`. |
| docker.username | string | `nil` | Username to authenticate with docker registry |
| ecr.accessKeyID | string | `nil` | ECR access key ID for read access to private registries |
| ecr.allowCrossAccount | bool | `false` | Allow lookups in ECR registries owned by other AWS accounts than the one version-checker authenticates as. Off by default. |
| ecr.iamRoleArn | string | `nil` | Provide AWS EKS Iam Role ARN following: [Specify A ServiceAccount Role](https://docs.aws.amazon.com/eks/latest/userguide/specify-service-account-role.html) |
| ecr.secretAccessKey | string | `nil` | ECR secret access key for read access to private registries |
| ecr.sessionToken | string | `nil` | ECR session token for read access to private registries |
Expand All @@ -50,6 +51,9 @@ A Helm chart for version-checker
| livenessProbe.initialDelaySeconds | int | `3` | Number of seconds after the container has started before liveness probes are initiated. |
| livenessProbe.periodSeconds | int | `3` | How often (in seconds) to perform the livenessProbe. |
| nameOverride | string | `""` | Override the Chart Name |
| networkPolicy | object | `{"enabled":false,"ingressFrom":[]}` | Restrict ingress to the metrics port with a NetworkPolicy (the metrics endpoint is unauthenticated) |
| networkPolicy.enabled | bool | `false` | Create a NetworkPolicy |
| networkPolicy.ingressFrom | list | `[]` | Peers (NetworkPolicyPeer list) allowed to reach the metrics port, e.g. your Prometheus. Empty allows no ingress. |
| nodeSelector | object | `{}` | Configure nodeSelector |
| podSecurityContext | object | `{}` | Set pod-level security context |
| prometheus.enabled | bool | `false` | Deploy a Prometheus-Operator Prometheus Object to collect version-checker metrics |
Expand All @@ -62,7 +66,7 @@ A Helm chart for version-checker
| readinessProbe.initialDelaySeconds | int | `3` | Number of seconds after the container has started before readiness probes are initiated. |
| readinessProbe.periodSeconds | int | `3` | How often (in seconds) to perform the readinessProbe. |
| replicaCount | int | `1` | Replica Count for version-checker |
| resources | object | `{}` | Setup version-checkers resource requests/limits |
| resources | object | `{"limits":{"memory":"512Mi"},"requests":{"cpu":"100m","memory":"128Mi"}}` | Setup version-checkers resource requests/limits. Raise the memory limit for clusters with many thousands of pods (they are all cached). |
| securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":65534,"seccompProfile":{"type":"RuntimeDefault"}}` | Set container-level security context |
| securityContext.allowPrivilegeEscalation | bool | `false` | Prevent the container from PrivilegeEscalation |
| securityContext.capabilities | object | `{"drop":["ALL"]}` | Ensure that we run with the capabilities we explicitly need to run |
Expand All @@ -78,10 +82,9 @@ A Helm chart for version-checker
| serviceMonitor.enabled | bool | `true` | Disable/Enable ServiceMonitor Object |
| tolerations | list | `[]` | Configure tolerations |
| topologySpreadConstraints | list | `[]` | Set topologySpreadConstraints |
| versionChecker.fallbackAllowPrivateHosts | bool | `false` | Allow anonymous lookups against registries on loopback, private or link-local addresses (e.g. an in-cluster registry). Off by default so pod annotations and image hosts cannot make version-checker call internal services. |
| versionChecker.imageCacheTimeout | string | `"30m"` | How long to hold on to image tags and their versions |
| versionChecker.logLevel | string | `"info"` | Configure version-checkers logging, valid options are: debug, info, warn, error, fatal, panic |
| versionChecker.metricsServingAddress | string | `"0.0.0.0:8080"` | Port/interface to which version-checker should bind too |
| versionChecker.testAllContainers | bool | `true` | Enable/Disable the requirement for an enable.version-checker.io annotation on pods. |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
20 changes: 20 additions & 0 deletions deploy/charts/version-checker/templates/_pod_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
- "--log-level={{.Values.versionChecker.logLevel}}"
- "--metrics-serving-address={{.Values.versionChecker.metricsServingAddress}}"
- "--test-all-containers={{.Values.versionChecker.testAllContainers}}"
{{- if .Values.versionChecker.fallbackAllowPrivateHosts }}
- "--fallback-allow-private-hosts=true"
{{- end }}
{{- if .Values.ecr.allowCrossAccount }}
- "--ecr-allow-cross-account=true"
{{- end }}
{{- end -}}

{{- define "version-checker.pod.envs.selfhosted" -}}
Expand Down Expand Up @@ -37,6 +43,13 @@
name: {{ $chartname }}
key: selfhosted.{{ $element.name }}.token
{{- end -}}
{{- if and (hasKey $element "token_path") $element.token_path }}
- name: VERSION_CHECKER_SELFHOSTED_TOKEN_PATH_{{ $element.name }}
valueFrom:
secretKeyRef:
name: {{ $chartname }}
key: selfhosted.{{ $element.name }}.token_path
{{- end -}}
{{- if and (hasKey $element "ca_path") $element.ca_path }}
- name: VERSION_CHECKER_SELFHOSTED_CA_PATH_{{ $element.name }}
valueFrom:
Expand Down Expand Up @@ -153,6 +166,13 @@
secretKeyRef:
name: {{ $chartname }}
key: ghcr.token
{{- end }}
{{- if .Values.ghcr.hostname }}
- name: VERSION_CHECKER_GHCR_HOSTNAME
valueFrom:
secretKeyRef:
name: {{ $chartname }}
key: ghcr.hostname
{{- end -}}
{{- end -}}

Expand Down
24 changes: 24 additions & 0 deletions deploy/charts/version-checker/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "version-checker.name" . }}
labels:
{{- include "version-checker.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{- include "version-checker.selector" . | nindent 6 }}
policyTypes:
- Ingress
ingress:
{{- with .Values.networkPolicy.ingressFrom }}
- from:
{{- toYaml . | nindent 8 }}
ports:
- port: {{ splitList ":" $.Values.versionChecker.metricsServingAddress | last }}
protocol: TCP
{{- else }}
[]
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion deploy/charts/version-checker/templates/prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ metadata:
spec:
replicas: {{ .Values.prometheus.replicas }}
serviceAccountName: {{ .Values.prometheus.serviceAccountName }}
version: v2.20.1
version: v2.55.1
serviceMonitorSelector:
matchLabels:
app: {{ include "version-checker.name" . }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/version-checker/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ data:
{{- end }}
{{- if and (hasKey $element "insecure") $element.insecure }}
selfhosted.{{ $element.name }}.insecure: {{ $element.insecure | b64enc }}
{{- end }}
{{- if and (hasKey $element "token_path") $element.token_path }}
selfhosted.{{ $element.name }}.token_path: {{ $element.token_path | b64enc }}
{{- end }}
{{- if and (hasKey $element "ca_path") $element.ca_path }}
selfhosted.{{ $element.name }}.ca_path: {{ $element.ca_path | b64enc }}
Expand Down
50 changes: 47 additions & 3 deletions deploy/charts/version-checker/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ tests:
value: quay.io/jetstack/version-checker:latest
- equal:
path: spec.template.spec.containers[0].resources
value: {}
value:
limits:
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
- equal:
path: spec.template.metadata.labels["app.kubernetes.io/name"]
value: version-checker
Expand Down Expand Up @@ -105,6 +110,30 @@ tests:
count: 1
content: "--test-all-containers=false"

- it: fallbackAllowPrivateHosts is off by default
asserts:
- notContains:
path: spec.template.spec.containers[0].args
content: "--fallback-allow-private-hosts=true"

- it: fallbackAllowPrivateHosts
set:
versionChecker.fallbackAllowPrivateHosts: true
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--fallback-allow-private-hosts=true"

- it: ecr.allowCrossAccount
set:
ecr.allowCrossAccount: true
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--ecr-allow-cross-account=true"

# ACR
- it: ACR should work
set:
Expand Down Expand Up @@ -247,6 +276,20 @@ tests:
key: ghcr.token
name: version-checker

- it: GHCR hostname
set:
ghcr.hostname: ghcr.example.com
asserts:
- contains:
path: spec.template.spec.containers[0].env
count: 1
content:
name: VERSION_CHECKER_GHCR_HOSTNAME
valueFrom:
secretKeyRef:
key: ghcr.hostname
name: version-checker

# Quay
- it: Quay should work
set:
Expand Down Expand Up @@ -488,14 +531,15 @@ tests:
resources:
limits:
cpu: 100m
memory: 512Mi
memory: 1Gi
requests: null
asserts:
- equal:
path: spec.template.spec.containers[0].resources
value:
limits:
cpu: 100m
memory: 512Mi
memory: 1Gi

- it: Custom Labels to Pod
set:
Expand Down
34 changes: 34 additions & 0 deletions deploy/charts/version-checker/tests/networkpolicy_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
suite: test networkpolicy
templates:
- networkpolicy.yaml
tests:
- it: is not created by default
asserts:
- hasDocuments:
count: 0

- it: denies all ingress when no peers are given
set:
networkPolicy.enabled: true
asserts:
- isKind:
of: NetworkPolicy
- equal:
path: spec.ingress
value: []

- it: allows the configured peers on the metrics port
set:
networkPolicy.enabled: true
versionChecker.metricsServingAddress: 0.0.0.0:9999
networkPolicy.ingressFrom:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: monitoring
asserts:
- equal:
path: spec.ingress[0].ports[0].port
value: 9999
- equal:
path: spec.ingress[0].from[0].namespaceSelector.matchLabels["kubernetes.io/metadata.name"]
value: monitoring
2 changes: 1 addition & 1 deletion deploy/charts/version-checker/tests/prometheus_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ tests:
- documentIndex: 3
equal:
path: spec.version
value: v2.20.1
value: v2.55.1
- documentIndex: 3
equal:
path: spec.serviceMonitorSelector.matchLabels
Expand Down
27 changes: 18 additions & 9 deletions deploy/charts/version-checker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ versionChecker:
metricsServingAddress: 0.0.0.0:8080
# -- Enable/Disable the requirement for an enable.version-checker.io annotation on pods.
testAllContainers: true
# -- Allow anonymous lookups against registries on loopback, private or link-local addresses (e.g. an in-cluster registry). Off by default so pod annotations and image hosts cannot make version-checker call internal services.
fallbackAllowPrivateHosts: false

# Azure Container Registry Credentials Configuration
acr:
Expand Down Expand Up @@ -78,6 +80,8 @@ ecr:
secretAccessKey:
# -- (string) ECR session token for read access to private registries
sessionToken:
# -- Allow lookups in ECR registries owned by other AWS accounts than the one version-checker authenticates as. Off by default.
allowCrossAccount: false

# Google Container Registry Credentials Configuration
gcr:
Expand Down Expand Up @@ -110,6 +114,7 @@ selfhosted:
# username:
# password:
# token:
# token_path: /v2/token
#- name: EXAMPLE
# host: https://artifactory.example.com
# username: foo
Expand All @@ -121,16 +126,20 @@ selfhosted:
# -- Provide an existing Secret within the cluster to use for authentication and configuration of version-checker
existingSecret: ""

# -- Setup version-checkers resource requests/limits
# -- Setup version-checkers resource requests/limits. Raise the memory limit for clusters with many thousands of pods (they are all cached).
resources:
{}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
#
limits:
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi

# -- Restrict ingress to the metrics port with a NetworkPolicy (the metrics endpoint is unauthenticated)
networkPolicy:
# -- Create a NetworkPolicy
enabled: false
# -- Peers (NetworkPolicyPeer list) allowed to reach the metrics port, e.g. your Prometheus. Empty allows no ingress.
ingressFrom: []

# -- Set container-level security context
securityContext:
Expand Down
17 changes: 16 additions & 1 deletion deploy/yaml/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ spec:
serviceAccountName: version-checker
containers:
- image: quay.io/jetstack/version-checker:v0.11.0
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 65534
seccompProfile:
type: RuntimeDefault
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 512Mi
ports:
- containerPort: 8080
name: version-checker
Expand Down
9 changes: 9 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ of the container in the pod.

However, by passing the following flag,`-a, --test-all-containers` version-checker will test all containers within the cluster.

### Registry access restrictions
Image hosts and the `override-url.version-checker.io` annotation come from pod specs, so version-checker restricts where it will connect:

- Anonymous lookups (images whose registry is not one of the configured ones) refuse loopback, private, link-local and CGNAT addresses, including redirects to them. An in-cluster registry that needs this can either be configured as a `selfhosted` registry or allowed with `--fallback-allow-private-hosts` (`versionChecker.fallbackAllowPrivateHosts` in the Helm chart).
- ECR lookups only target the AWS account version-checker authenticates as. Registries in other accounts need `--ecr-allow-cross-account` (`ecr.allowCrossAccount`).
- Selfhosted registry `host` values must be full URLs, e.g. `https://registry.example.com`.

The metrics endpoint is unauthenticated. Set `networkPolicy.enabled=true` and `networkPolicy.ingressFrom` in the Helm chart to limit who can reach it.

### Supported Annotations

`version-checker` supports the following annotations to enrich version checking on image tags:
Expand Down