Skip to content

feat: image fixes and ci #953

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

Merged
merged 17 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
21 changes: 21 additions & 0 deletions .github/workflows/lint-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint images

on:
push:
branches:
- main
pull_request:

jobs:
lint-images:
name: Lint images
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run image check script
run: bash ./image_check.sh
working-directory: ./scripts

2 changes: 1 addition & 1 deletion charts/testkube/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
repository: https://charts.bitnami.com/bitnami
- name: nats
condition: testkube-api.nats.enabled
version: 1.1.7
version: 1.2.6
repository: https://nats-io.github.io/k8s/helm/charts/
- name: testkube-api
version: 2.1.48
Expand Down
16 changes: 16 additions & 0 deletions charts/testkube/templates/_helpers_nats.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/*
Override the nats.image template to use .global.imageRegistry instead of their
.global.image.registry.

TODO(emil): do the same for global.imagePullSecrets
*/}}
{{- define "nats.image" }}
{{- $image := printf "%s:%s" .repository .tag }}
{{- if or .registry .global.imageRegistry }}
{{- $image = printf "%s/%s" (.registry | default .global.imageRegistry) $image }}
{{- end -}}
image: {{ $image }}
{{- if or .pullPolicy .global.image.pullPolicy }}
imagePullPolicy: {{ .pullPolicy | default .global.image.pullPolicy }}
{{- end }}
{{- end }}
6 changes: 3 additions & 3 deletions charts/testkube/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ nats:
# container:
# image:
# repository: nats
# tag: 2.10.9-alpine
# tag: 2.10.22-alpine
# pullPolicy:
# registry:
# NATS Box container settings
Expand All @@ -161,7 +161,7 @@ nats:
# container:
# image:
# repository: natsio/nats-box
# tag: 0.14.1
# tag: 0.14.5
# pullPolicy:
# registry:
# -- NATS Box tolerations settings. Uncomment to schedule a multi-arch image to any available architecture type in a GCP Standard cluster.
Expand All @@ -186,7 +186,7 @@ nats:
# -- Uncomment to override the NATS Server Config Reloader image options
# image:
# repository: natsio/nats-server-config-reloader
# tag: 0.14.1
# tag: 0.16.0
# pullPolicy:
# registry:

Expand Down
31 changes: 31 additions & 0 deletions scripts/image_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

REPO=myownrepo.com/prefix
AGENT_IMAGES=images.txt

# Build the dependencies
helm dependency build ../charts/testkube

# Get images for the agent chart
helm template test ../charts/testkube --skip-crds --set global.imageRegistry="$REPO" --set mongodb.enabled=false --set testkube-api.minio.enabled=false --set testkube-dashboard.enabled=false --set global.testWorkflows.createOfficialTemplates=false | grep "image:" | grep -v "{" | sed 's/"//g' | sed 's/docker.io\///g' | awk '{ print $2 }' | awk 'NF && !seen[$0]++' | sort > "$AGENT_IMAGES"

# Get the images for the workflows
helm template test ../charts/testkube --skip-crds --set global.imageRegistry="$REPO" --set mongodb.enabled=false --set testkube-api.minio.enabled=false --set testkube-dashboard.enabled=false --set global.testWorkflows.createOfficialTemplates=false | grep "testkube-tw" | sed 's/"//g' | sed 's/docker.io\///g' | awk '{ print $2 }' | awk 'NF && !seen[$0]++' | sort >> "$AGENT_IMAGES"

# Sort these agent images
sort -o "$AGENT_IMAGES" "$AGENT_IMAGES"

# Check for images that do not start with the image registry
failure=false
while IFS= read -r line; do
if [[ ! "$line" =~ ^"$REPO" ]]; then
echo "Failure: Line '$line' does not start with '$REPO'."
failure=true
fi
done < "$AGENT_IMAGES"

if [ "$failure" = true ]; then
exit 1
fi

echo "All lines start with '$REPO'."
9 changes: 9 additions & 0 deletions scripts/images.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
myownrepo.com/prefix/brancz/kube-rbac-proxy:v0.18.1
myownrepo.com/prefix/kubeshop/kube-webhook-certgen:0.0.4
myownrepo.com/prefix/kubeshop/testkube-api-server:2.1.48
myownrepo.com/prefix/kubeshop/testkube-operator:2.1.20
myownrepo.com/prefix/kubeshop/testkube-tw-init:2.1.48
myownrepo.com/prefix/kubeshop/testkube-tw-toolkit:2.1.48
myownrepo.com/prefix/rancher/kubectl:v1.23.7
nats:2.10.22-alpine
natsio/nats-server-config-reloader:0.16.0
Loading