Skip to content

Commit

Permalink
Add dind/pink CI test.yml scenario (requires registry)
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Dec 29, 2022
1 parent 011258b commit 0ac8ec0
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 3 deletions.
58 changes: 55 additions & 3 deletions .github/workflows/test.yml
Expand Up @@ -55,6 +55,8 @@ jobs:
- main
- auth
- helm
test-variation:
- ""
include:
# Chart.yaml contains the chart's oldest supported k8s version, we
# test against that and the oldest known supported helm cli version
Expand All @@ -70,19 +72,56 @@ jobs:
# upgrade-from represents a release channel, see: https://jupyterhub.github.io/helm-chart/info.json
upgrade-from: dev
upgrade-from-extra-args: ""
- k3s-channel: v1.25
test: helm
test-variation: dind
local-chart-extra-args: >-
--values testing/k8s-binder-k8s-hub/binderhub-chart+dind.yaml
--set config.BinderHub.image_prefix=$REGISTRY_HOST/test/
--set registry.url=http://$REGISTRY_HOST
- k3s-channel: v1.25
test: helm
test-variation: pink
local-chart-extra-args: >-
--values testing/k8s-binder-k8s-hub/binderhub-chart+pink.yaml
--set config.BinderHub.image_prefix=$REGISTRY_HOST/test/
--set registry.url=http://$REGISTRY_HOST
services:
registry:
image: docker.io/library/registry:latest
ports:
- 5000:5000

steps:
- uses: actions/checkout@v3
with:
# chartpress requires the full history
fetch-depth: 0

- name: Set registry host
if: matrix.test-variation == 'dind' || matrix.test-variation == 'pink'
run: |
REGISTRY_HOST=$(hostname -I | awk '{print $1}'):5000
echo REGISTRY_HOST="$REGISTRY_HOST" >> $GITHUB_ENV
# Allow k3s to pull from private registry
# https://docs.k3s.io/installation/private-registry
sudo mkdir -p /etc/rancher/k3s/
cat << EOF | sudo tee /etc/rancher/k3s/registries.yaml
mirrors:
"$REGISTRY_HOST":
endpoint:
- "http://$REGISTRY_HOST"
EOF
- uses: jupyterhub/action-k3s-helm@v3
with:
k3s-channel: ${{ matrix.k3s-channel }}
helm-version: ${{ matrix.helm-version }}
metrics-enabled: false
traefik-enabled: false
docker-enabled: true
docker-enabled: ${{ matrix.test-variation != 'dind' && matrix.test-variation != 'pink' }}

- name: Setup OS level dependencies
run: |
Expand Down Expand Up @@ -145,9 +184,17 @@ jobs:
run: |
export DOCKER_BUILDKIT=1
CHARTPRESS_ARGS=
if [ "${{ matrix.test-variation }}" = "dind" -o "${{ matrix.test-variation }}" = "pink" ]; then
CHARTPRESS_ARGS="--image-prefix localhost:5000/binderhub- --push"
# Allow the pods to push to the non-https GitHub workflow registry
envsubst < testing/k8s-binder-k8s-hub/cm-insecure-registries-${{ matrix.test-variation }}.yaml | kubectl apply -f -
fi
# Use chartpress to create the helm chart and build its images
helm dependency update ./helm-chart/binderhub
(cd helm-chart && chartpress)
(cd helm-chart && chartpress $CHARTPRESS_ARGS)
git --no-pager diff --color=always
- name: Generate values.schema.json from schema.yaml
Expand Down Expand Up @@ -286,7 +333,12 @@ jobs:
uses: jupyterhub/action-k8s-namespace-report@v1
if: always()
with:
important-workloads: deploy/binder deploy/hub deploy/proxy
important-workloads: >
deploy/binder
deploy/hub
deploy/proxy
daemonset/binderhub-test-dind
daemonset/binderhub-test-pink
# GitHub action reference: https://github.com/codecov/codecov-action
- name: Upload coverage stats
Expand Down
21 changes: 21 additions & 0 deletions testing/k8s-binder-k8s-hub/binderhub-chart+dind.yaml
@@ -0,0 +1,21 @@
# Additional configuration for testing dind
# You must create configmap/insecure-registries-dind first to allow testing with an
# insecure http registry
# https://docs.docker.com/registry/insecure/

config:
BinderHub:
use_registry: true

imageBuilderType: dind

dind:
daemonset:
extraVolumeMounts:
- name: insecure-registries-dind
mountPath: /etc/docker/daemon.json
subPath: daemon.json
extraVolumes:
- name: insecure-registries-dind
configMap:
name: insecure-registries-dind
22 changes: 22 additions & 0 deletions testing/k8s-binder-k8s-hub/binderhub-chart+pink.yaml
@@ -0,0 +1,22 @@
# Additional configuration for testing podman
# You must create configmap/insecure-registries-pink first to allow testing with an
# insecure http registry

config:
BinderHub:
use_registry: true

imageBuilderType: pink

pink:
daemonset:
extraArgs:
- --log-level=debug
extraVolumeMounts:
- name: insecure-registries-pink
mountPath: /etc/containers/registries.conf.d/100-insecure-registries-pink.conf
subPath: 100-insecure-registries-pink.conf
extraVolumes:
- name: insecure-registries-pink
configMap:
name: insecure-registries-pink
11 changes: 11 additions & 0 deletions testing/k8s-binder-k8s-hub/cm-insecure-registries-dind.yaml
@@ -0,0 +1,11 @@
# REGISTRY_HOST='HOST:PORT' envsubst < cm-insecure-registries-dind.yaml | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: insecure-registries-dind
data:
daemon.json: |
{
"insecure-registries": ["$REGISTRY_HOST"],
"debug": true
}
12 changes: 12 additions & 0 deletions testing/k8s-binder-k8s-hub/cm-insecure-registries-pink.yaml
@@ -0,0 +1,12 @@
# REGISTRY_HOST='HOST:PORT' envsubst < cm-insecure-registries-pink.yaml | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
name: insecure-registries-pink
data:
100-insecure-registries-pink.conf: |
# https://www.redhat.com/sysadmin/manage-container-registries
unqualified-search-registries = ["docker.io"]
[[registry]]
location="$REGISTRY_HOST"
insecure=true

0 comments on commit 0ac8ec0

Please sign in to comment.