Skip to content
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

Add image sync workflow #5

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c332c8f
Add skopeo sync workflow
May 9, 2023
bd8d12f
Trigger workflow on push
May 9, 2023
2e4afcd
Fix filenames in test matrix
May 9, 2023
d736820
Fix filenames in test matrix
May 9, 2023
73be504
Fix manifest format
May 9, 2023
a77d8fb
Fix missing '/' separators
May 9, 2023
47d3179
Check skopeo version
May 9, 2023
6c4e798
Test docker option
May 9, 2023
5f7d688
Use containerised skopeo
May 9, 2023
c9cfd65
Fix container version
May 9, 2023
c156128
Run sync in container
May 9, 2023
3ed77fb
Fix path
May 9, 2023
50ca070
Checkout correct branch in workflow
May 9, 2023
80473c7
Debug test
May 10, 2023
f6c940a
Debug test
May 10, 2023
3021f82
Debug test
May 10, 2023
17d4d89
Fix container mount path
May 10, 2023
5d18b20
Add check for changes
May 10, 2023
e4bf910
Fix check for changes
May 10, 2023
0b93f3f
Address requested changes:
May 11, 2023
88af872
Test output capture
May 11, 2023
d9a0a0f
Fix typo
May 11, 2023
126b4df
Write to file instead
May 11, 2023
8f06178
Write stderr to file too
May 11, 2023
d33dadb
Add error checking for sync output
May 11, 2023
63982ca
Duplicate sync output with tee
May 11, 2023
d0d9f05
Also pipe stderr to tee
May 11, 2023
96705ca
Fix sha256 tag handling
May 11, 2023
91ad805
Re-enable manifest diff checking
May 11, 2023
32f5dd2
Re-enable manifest diff checking properly
May 11, 2023
520515b
Add note about notebook images
May 15, 2023
438b2e0
Add notebook images
May 15, 2023
ad6a682
Formatting
May 15, 2023
1de9be4
Shorten manifest names
May 25, 2023
0b639fd
Update file list
May 25, 2023
354de67
Comments and formatting
May 25, 2023
a2a7b1d
Be explicit about defaulting to docker.io
May 30, 2023
6222b28
Merge branch 'main' into skopeo
May 30, 2023
231f93a
Update ignores
May 30, 2023
d442ec6
Use stackhpc ghcr container images
May 30, 2023
807ac24
Formatting
May 30, 2023
d5da99e
Fix traefik image config
May 30, 2023
29b285a
Fix container image paths
May 30, 2023
c1a5f32
Fix ghcr image paths
May 30, 2023
e8c502e
Formatting
May 30, 2023
295f1ae
Comments and formatting
May 30, 2023
65f97ce
Force ghcr images as kustomization instead
May 31, 2023
0b7566a
Don't hard-code image tag
May 31, 2023
7cc3fcd
Ignore vscode dir
May 31, 2023
4900d5d
Remove explicit image tags
May 31, 2023
34aac8b
Fix python & mysql image names
May 31, 2023
724ef7e
Handle images defined in config maps
Jun 15, 2023
3d86b3f
Update comments
Jun 15, 2023
60b39ea
Fix linux sed usage
Jun 15, 2023
6aa158d
Fix linux sed usage properly
Jun 15, 2023
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
60 changes: 60 additions & 0 deletions .github/workflows/sync-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: sync images
on: push

jobs:
sync_images:
runs-on: ubuntu-latest
strategy:
matrix:
component:
- skopeo-manifest-daskhub
- skopeo-manifest-jupyterhub
- skopeo-manifest-kubeflow
steps:
- name: Check out the repository
uses: actions/checkout@v3
# TODO: Revert to main branch before merging
with:
ref: skopeo
Comment on lines +16 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sd109 We just need to do what this says :)


# Uncommment for SSH-able terminal session within runner to aid debugging
# - uses: actions/checkout@v2
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1

- name: Check component manifest for changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
manifest:
- skopeo-manifests/${{ matrix.component }}.yml

# NOTE: Need skopeo > v1.09 to avoid this issue:
# https://github.com/containers/skopeo/issues/1874
# so use containerized version

- name: Sync component images
id: image-sync
if: ${{ steps.changes.outputs.manifest == 'true' }}
run: |-
docker run --entrypoint /usr/bin/env \
-v $GITHUB_WORKSPACE:/home/skopeo/azimuth-charts \
quay.io/skopeo/stable:v1.11 \
skopeo sync \
--src yaml \
--dest docker \
--dest-creds ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \
--scoped \
--all \
/home/skopeo/azimuth-charts/skopeo-manifests/${{ matrix.component }}.yml \
ghcr.io/stackhpc/azimuth-charts \
|& tee sync-output.txt

- name: Check output for any sync errors
run: |
ERR_COUNT=$(grep "level=error" sync-output.txt | wc -l)
if [[ $ERR_COUNT -gt 0 ]]; then
echo "Found $ERR_COUNT logged error messages in output of image sync step"
exit 1
fi
68 changes: 68 additions & 0 deletions skopeo-manifests/create-skopeo-manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
This script should be fed the `FILE_PATH` output of the following kubectl command which
lists all container images currently in use on the target kubernetes cluster:

kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" \
| tr -s '[[:space:]]' '\n' | sort | uniq > FILE_PATH

The script will then generate an output file named skopeo-manifest-{FILE_PATH}.yaml which
is formatted such that it can be fed into the sync-images.yml github workflow to copy any
required images into a dedicated container registry.

NOTE: In order to capture the images used by the deployed platforms (e.g. the jupyter
notebook container) the relevant platform components should be deployed cluster before
running this script.
"""

import sys, yaml
from pathlib import Path
from functools import reduce

if len(sys.argv) != 2:
print("Path to input file must be the sole command line arg to this script")
sys.exit(1)

file_path = Path(sys.argv[1])
# Kubernetes assumes docker registry by default:
# https://kubernetes.io/docs/concepts/containers/images/#image-names
default_registry = "docker.io"


def split_image_url(url: str):
try:
parts = url.strip("\n").split("/")
registry = parts[0] if len(parts) > 1 else default_registry
# TODO: Check if skopeo copy a no-op when
# source and destination are the same
if registry == "ghcr.io":
return {}
repo_plus_version = "/".join(parts[1:]) if len(parts) > 1 else parts[0]
repo, version = repo_plus_version.split(":")
if "@sha256" in repo:
repo = repo.replace("@sha256", "")
version = "sha256:" + version
return {registry: {"images": {repo: [version]}}}
except Exception as e:
raise Exception(f"Failed to parse url: {url}\nException was:", e)


def dict_merge_recursive(d1, d2):
"""update first dict with second recursively"""
try:
for k, v in d1.items():
if k in d2:
if isinstance(v, list):
d2[k] += v
else:
d2[k] = dict_merge_recursive(v, d2[k])
d1.update(d2)
return d1
except Exception as e:
raise Exception(f"Failed to merge dicts: {d1} & {d2}\nException was:", e)


# Loop through lines in file and convert to a nested dict
with open(file_path, "r") as file:
result_dict = reduce(dict_merge_recursive, map(split_image_url, file.readlines()))
with open(f"skopeo-manifest-{file_path.stem}.yml", "w") as out_file:
yaml.safe_dump(result_dict, out_file)
34 changes: 34 additions & 0 deletions skopeo-manifests/skopeo-manifest-daskhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
docker.io:
images:
traefik:
- 2.6.3
jupyterhub:
images:
configurable-http-proxy:
- 4.5.3
k8s-hub:
- 2.0.0
k8s-singleuser-sample:
- 2.0.0
k8s.gcr.io:
images:
kube-scheduler:
- v1.23.10
pangeo:
images:
base-notebook:
- 2022.10.31
registry.k8s.io:
images:
coredns/coredns:
- v1.9.3
etcd:
- 3.5.6-0
kube-apiserver:
- v1.26.3
kube-controller-manager:
- v1.26.3
kube-proxy:
- v1.26.3
kube-scheduler:
- v1.26.3
26 changes: 26 additions & 0 deletions skopeo-manifests/skopeo-manifest-jupyterhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
jupyterhub:
images:
configurable-http-proxy:
- 4.5.3
k8s-hub:
- 2.0.0
k8s-singleuser-sample:
- 2.0.0
k8s.gcr.io:
images:
kube-scheduler:
- v1.23.10
registry.k8s.io:
images:
coredns/coredns:
- v1.9.3
etcd:
- 3.5.6-0
kube-apiserver:
- v1.26.3
kube-controller-manager:
- v1.26.3
kube-proxy:
- v1.26.3
kube-scheduler:
- v1.26.3
137 changes: 137 additions & 0 deletions skopeo-manifests/skopeo-manifest-kubeflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
docker.io:
images:
istio/pilot:
- 1.16.0
istio/proxyv2:
- 1.16.0
kubeflowkatib/katib-controller:
- v0.15.0
kubeflowkatib/katib-db-manager:
- v0.15.0
kubeflowkatib/katib-ui:
- v0.15.0
kubeflownotebookswg/centraldashboard:
- v1.7.0
kubeflownotebookswg/jupyter-web-app:
- v1.7.0
kubeflownotebookswg/kfam:
- v1.7.0
kubeflownotebookswg/notebook-controller:
- v1.7.0
kubeflownotebookswg/poddefaults-webhook:
- v1.7.0
kubeflownotebookswg/profile-controller:
- v1.7.0
kubeflownotebookswg/tensorboard-controller:
- v1.7.0
kubeflownotebookswg/tensorboards-web-app:
- v1.7.0
kubeflownotebookswg/volumes-web-app:
- v1.7.0
metacontrollerio/metacontroller:
- v2.0.4
mysql:
- 8.0.29
python:
- '3.7'
gcr.io:
images:
arrikto/kubeflow/oidc-authservice:
- e236439
knative-releases/knative.dev/eventing/cmd/controller:
- sha256:33d78536e9b38dbb2ec2952207b48ff8e05acb48e7d28c2305bd0a0f7156198f
knative-releases/knative.dev/eventing/cmd/webhook:
- sha256:d217ab7e3452a87f8cbb3b45df65c98b18b8be39551e3e960cd49ea44bb415ba
knative-releases/knative.dev/net-istio/cmd/controller:
- sha256:2b484d982ef1a5d6ff93c46d3e45f51c2605c2e3ed766e20247d1727eb5ce918
knative-releases/knative.dev/net-istio/cmd/webhook:
- sha256:59b6a46d3b55a03507c76a3afe8a4ee5f1a38f1130fd3d65c9fe57fff583fa8d
knative-releases/knative.dev/serving/cmd/activator:
- sha256:c3bbf3a96920048869dcab8e133e00f59855670b8a0bbca3d72ced2f512eb5e1
knative-releases/knative.dev/serving/cmd/autoscaler:
- sha256:caae5e34b4cb311ed8551f2778cfca566a77a924a59b775bd516fa8b5e3c1d7f
knative-releases/knative.dev/serving/cmd/controller:
- sha256:38f9557f4d61ec79cc2cdbe76da8df6c6ae5f978a50a2847c22cc61aa240da95
knative-releases/knative.dev/serving/cmd/domain-mapping:
- sha256:763d648bf1edee2b4471b0e211dbc53ba2d28f92e4dae28ccd39af7185ef2c96
knative-releases/knative.dev/serving/cmd/domain-mapping-webhook:
- sha256:a4ba0076df2efaca2eed561339e21b3a4ca9d90167befd31de882bff69639470
knative-releases/knative.dev/serving/cmd/webhook:
- sha256:bc13765ba4895c0fa318a065392d05d0adc0e20415c739e0aacb3f56140bf9ae
kubebuilder/kube-rbac-proxy:
- v0.8.0
- v0.13.1
ml-pipeline/api-server:
- 2.0.0-alpha.7
ml-pipeline/cache-server:
- 2.0.0-alpha.7
ml-pipeline/frontend:
- 2.0.0-alpha.7
ml-pipeline/metadata-envoy:
- 2.0.0-alpha.7
ml-pipeline/metadata-writer:
- 2.0.0-alpha.7
ml-pipeline/minio:
- RELEASE.2019-08-14T20-37-41Z-license-compliance
ml-pipeline/mysql:
- 8.0.26
ml-pipeline/persistenceagent:
- 2.0.0-alpha.7
ml-pipeline/scheduledworkflow:
- 2.0.0-alpha.7
ml-pipeline/viewer-crd-controller:
- 2.0.0-alpha.7
ml-pipeline/visualization-server:
- 2.0.0-alpha.7
ml-pipeline/workflow-controller:
- v3.3.8-license-compliance
tfx-oss-public/ml_metadata_store_server:
- 1.5.0
kserve:
images:
kserve-controller:
- v0.10.0
models-web-app:
- v0.10.0
kubeflow:
images:
training-operator:
- v1-5a5f92d
kubeflownotebookswg:
images:
jupyter-pytorch-cuda-full:
- v1.7.0
jupyter-pytorch-full:
- v1.7.0
jupyter-scipy:
- v1.7.0
jupyter-tensorflow-cuda-full:
- v1.7.0
jupyter-tensorflow-full:
- v1.7.0
quay.io:
images:
jetstack/cert-manager-cainjector:
- v1.10.1
jetstack/cert-manager-controller:
- v1.10.1
jetstack/cert-manager-webhook:
- v1.10.1
registry.k8s.io:
images:
coredns/coredns:
- v1.9.3
etcd:
- 3.5.6-0
kube-apiserver:
- v1.26.3
kube-controller-manager:
- v1.26.3
kube-proxy:
- v1.26.3
kube-scheduler:
- v1.26.3
tensorflow:
images:
tensorflow:
- 2.5.1