Skip to content

Commit a6c4a02

Browse files
Push a test CSI driver image that can be used for operator testing
1 parent d265737 commit a6c4a02

File tree

6 files changed

+72
-89
lines changed

6 files changed

+72
-89
lines changed

.github/workflows/build-test-publish-operator.yaml

+19-30
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
name: Build, Test, and Publish Operator Bundle
1+
name: "Test and Publish BeeGFS CSI Driver Operator"
22

3+
# Adapted from:
4+
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow
5+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
6+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
37
on:
48
workflow_dispatch:
5-
push:
6-
branches:
7-
- "master"
8-
tags:
9-
- "v*"
10-
pull_request:
11-
branches:
12-
- "master"
13-
9+
# This workflow should run after we've built the CSI driver container image and it is available as test package.
1410
workflow_run:
15-
workflows: ["Build, Test, and Publish Container Images"]
11+
workflows: [Test and Publish BeeGFS CSI Driver]
1612
types:
1713
- completed
1814

1915
env:
20-
# Container image registry to publish images to.
16+
# Container image registry to publish images to:
2117
REGISTRY: ghcr.io
22-
# Where to push an image of the operator that will be retained (for master builds or releases):
18+
# Where to push an image of the operator that will be retained (for master builds or releases) without a specific tag:
2319
IMAGE_NAME: ghcr.io/thinkparq/beegfs-csi-driver-operator
2420
# Where to push an image of the operator for testing without a specific tag:
2521
TEST_IMAGE_NAME: ghcr.io/thinkparq/test-beegfs-csi-driver-operator
2622
# Where to push an image of the bundle for testing without a specific tag:
2723
TEST_BUNDLE_NAME: ghcr.io/thinkparq/test-beegfs-csi-driver-bundle
2824
# What container image should be deployed by the operator for testing the BeeGFS CSI driver deployment:
29-
CSI_IMAGE_NAME: ghcr.io/thinkparq/beegfs-csi-driver
30-
# TODO: Determine what tag we want to actually use for testing (latest or potentially the github.sha).
31-
CSI_IMAGE_TAG: pr-2
25+
TEST_CSI_IMAGE_NAME: ghcr.io/thinkparq/test-beegfs-csi-driver
26+
27+
# Note for all test images the github.sha will be used as the tag.
3228

3329
jobs:
3430
build-and-unit-test:
@@ -104,7 +100,7 @@ jobs:
104100
fail-fast: true
105101
matrix:
106102
k8s-version: [1.26.3] # TODO: Expand tested versions (1.24.15, 1.25.11, 1.26.3, 1.27.3)
107-
beegfs-version: [7.3.3] # TODO: Expand tested versions
103+
beegfs-version: [7.3.4] # TODO: Expand tested versions
108104
permissions:
109105
packages: read
110106
contents: read
@@ -213,8 +209,8 @@ jobs:
213209

214210
- name: Deploy a BeeGFSDriver object
215211
run: |
216-
export CSI_IMAGE_NAME=$(echo ${{ env.CSI_IMAGE_NAME }})
217-
export CSI_IMAGE_TAG=$(echo ${{ env.CSI_IMAGE_TAG }})
212+
export CSI_IMAGE_NAME=$(echo ${{ env.TEST_CSI_IMAGE_NAME }})
213+
export CSI_IMAGE_TAG=$(echo ${{ github.sha }})
218214
export BEEGFS_SECRET=$(echo ${{ secrets.CONN_AUTH_SECRET }})
219215
export BEEGFS_MGMTD=$(kubectl get nodes -o=jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
220216
envsubst < test/env/beegfs-ubuntu/csi-beegfs-cr.yaml | kubectl apply -f -
@@ -268,25 +264,21 @@ jobs:
268264
runs-on: ubuntu-22.04
269265
timeout-minutes: 5
270266
needs: e2e-tests
271-
# TODO: Consider if we want to continue publishing images on pull requests.
272-
# if: github.event_name != 'pull_request'
267+
if: github.event_name != 'pull_request'
273268
permissions:
274269
packages: write
275270
contents: read
276271
steps:
277272
- uses: actions/checkout@v3
278273

279-
- name: Set up Docker Buildx
280-
uses: docker/setup-buildx-action@v2
281-
282274
- name: Install Cosign
283275
uses: sigstore/[email protected]
284276
with:
285277
cosign-release: "v2.1.1"
286278

287279
- name: Pull tested operator image from ghcr.io
288280
run: |
289-
docker tag ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
281+
docker pull ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
290282
291283
- name: Log into the GitHub Container Registry
292284
uses: docker/login-action@v2
@@ -308,6 +300,7 @@ jobs:
308300
type=semver,pattern={{version}},prefix=v
309301
type=semver,pattern={{major}}.{{minor}},prefix=v
310302
303+
# TODO: Consider adding labels available as steps.meta.output.labels.
311304
- name: Tag and push the operator image to GitHub Container Registry
312305
run: |
313306
tags=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ')
@@ -333,16 +326,12 @@ jobs:
333326
env:
334327
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
335328
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
336-
# Test commands:
337-
# make -e IMG=ghcr.io/thinkparq/test-beegfs-csi-driver-operator:master build docker-build docker-push
338-
# make -e IMG=ghcr.io/thinkparq/test-beegfs-csi-driver-operator:master BUNDLE_IMG=ghcr.io/thinkparq/test-beegfs-csi-driver-bundle:master bundle bundle-build bundle-push
339-
# operator-sdk run bundle ghcr.io/thinkparq/test-beegfs-csi-driver-bundle:master
340329

341330
# We'll keep around a few old test packages to (a) avoid deleting image for workflows running in parallel,
342331
# and (b) it may be useful to pull a package to troubleshoot workflow failures.
343332
cleanup-test-images:
344333
runs-on: ubuntu-22.04
345-
timeout-minutes: 5
334+
timeout-minutes: 3
346335
needs: publish-images
347336
if: always()
348337
steps:

.github/workflows/build-test-publish.yaml

+45-54
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build, Test, and Publish Container Images
1+
name: "Test and Publish BeeGFS CSI Driver"
22

33
on:
44
workflow_dispatch:
@@ -12,10 +12,14 @@ on:
1212
- "master"
1313

1414
env:
15-
# Container image registry to publish images to.
15+
# Container image registry to publish images to:
1616
REGISTRY: ghcr.io
17-
# The name of the image without a specific tag.
17+
# Where to push an image of the CSI driver that will be retained (for master builds or releases) without a specific tag:
1818
IMAGE_NAME: ghcr.io/thinkparq/beegfs-csi-driver
19+
# Where to push an image of the CSI driver for testing (including the operator) without a specific tag:
20+
TEST_IMAGE_NAME: ghcr.io/thinkparq/test-beegfs-csi-driver
21+
22+
# Note for all test images the github.sha will be used as the tag.
1923

2024
jobs:
2125
build-and-unit-test:
@@ -57,35 +61,19 @@ jobs:
5761
# TODO: Can we cache anything here? test-vendor downloads a lot of stuff.
5862
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go#caching-dependencies
5963

60-
- name: Set up Docker Buildx
61-
uses: docker/setup-buildx-action@v2
62-
63-
# For now just tag with the commit ID to ensure subsequent jobs in this workflow run use the correct image.
64-
- name: Extract metadata for container image ${{ env.IMAGE_NAME }}
65-
id: meta
66-
uses: docker/metadata-action@v4
67-
with:
68-
images: |
69-
${{ env.IMAGE_NAME }}
70-
tags: |
71-
type=sha,prefix=,format=long
72-
73-
# We already built the image but this allows us to easily apply the appropriate labels and export the image.
74-
# It'll end up just reusing the local cache so it will complete very fast anyway.
75-
- name: Build and export image ${{ env.IMAGE_NAME }}
76-
uses: docker/build-push-action@v4
64+
- name: Log into the GitHub Container Registry
65+
uses: docker/login-action@v2
7766
with:
78-
context: .
79-
push: false
80-
tags: ${{ steps.meta.outputs.tags }}
81-
labels: ${{ steps.meta.outputs.labels }}
82-
outputs: type=docker,dest=/tmp/beegfs-csi-driver.tar
67+
registry: ${{ env.REGISTRY }}
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
8370

84-
- name: Upload the exported container image as an artifact for reuse in subsequent jobs
85-
uses: actions/upload-artifact@v3
86-
with:
87-
name: beegfs-csi-driver-image
88-
path: /tmp/beegfs-csi-driver.tar
71+
# Push the image for reuse in subsequent steps, jobs, and workflows.
72+
# For now just tag with the commit ID to ensure subsequent jobs in this workflow run use the correct image.
73+
- name: Tag and push the CSI driver as a test package
74+
run: |
75+
docker tag beegfs-csi-driver:latest ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
76+
docker push ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
8977
9078
e2e-tests:
9179
runs-on: ubuntu-22.04
@@ -95,7 +83,7 @@ jobs:
9583
fail-fast: true
9684
matrix:
9785
k8s-version: [1.24.15, 1.25.11, 1.26.3, 1.27.3]
98-
beegfs-version: [7.3.3] # TODO: Expand tested versions
86+
beegfs-version: [7.3.4]
9987
permissions:
10088
packages: read
10189
contents: read
@@ -105,17 +93,6 @@ jobs:
10593
- name: Set up Docker Buildx
10694
uses: docker/setup-buildx-action@v2
10795

108-
- name: Download the container image artifact built in the previous job
109-
uses: actions/download-artifact@v3
110-
with:
111-
name: beegfs-csi-driver-image
112-
path: /tmp
113-
114-
- name: Load the downloaded container image into the local Docker cache
115-
run: |
116-
docker load --input /tmp/beegfs-csi-driver.tar
117-
docker image ls -a
118-
11996
- name: Deploy Kubernetes ${{ matrix.k8s-version }} using Minikube
12097
uses: medyagh/setup-minikube@latest
12198
with:
@@ -145,7 +122,7 @@ jobs:
145122
envsubst < test/env/beegfs-ubuntu/csi-beegfs-connauth.yaml > deploy/k8s/overlays/default/csi-beegfs-connauth.yaml
146123
# TODO: Enable once the K8s versions in the matrix are added to versions/
147124
# sed -i 's?/versions/latest?/versions/v${{ matrix.k8s-version }}?g' deploy/k8s/overlays/default/kustomization.yaml
148-
echo -e "\nimages:\n - name: ${{ env.IMAGE_NAME }}\n newTag: ${{ github.sha }}" >> deploy/k8s/overlays/default/kustomization.yaml
125+
echo -e "\nimages:\n - name: ${{ env.IMAGE_NAME }}\n newName: ${{ env.TEST_IMAGE_NAME }}\n newTag: ${{ github.sha }}" >> deploy/k8s/overlays/default/kustomization.yaml
149126
kubectl apply -k deploy/k8s/overlays/default
150127
151128
# TODO (BCSI-7): Actually run e2e tests using Ginko with an appropriate timeout.
@@ -197,7 +174,6 @@ jobs:
197174
runs-on: ubuntu-22.04
198175
timeout-minutes: 5
199176
needs: e2e-tests
200-
# TODO: Consider if we want to continue publishing images on pull requests.
201177
if: github.event_name != 'pull_request'
202178
permissions:
203179
packages: write
@@ -213,16 +189,9 @@ jobs:
213189
with:
214190
cosign-release: "v2.1.1"
215191

216-
- name: Download BeeGFS CSI driver image artifact
217-
uses: actions/download-artifact@v3
218-
with:
219-
name: beegfs-csi-driver-image
220-
path: /tmp
221-
222-
- name: Load image
192+
- name: Pull tested CSI driver image from ghcr.io
223193
run: |
224-
docker load --input /tmp/beegfs-csi-driver.tar
225-
docker image ls -a
194+
docker pull ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }}
226195
227196
- name: Log in to the GitHub Container Registry
228197
uses: docker/login-action@v2
@@ -244,11 +213,12 @@ jobs:
244213
type=semver,pattern={{version}},prefix=v
245214
type=semver,pattern={{major}}.{{minor}},prefix=v
246215
216+
# TODO: Consider adding labels available as steps.meta.output.labels.
247217
- name: Tag and push the image to GitHub Container Registry
248218
run: |
249219
tags=$(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ')
250220
for tag in $tags; do
251-
docker tag ${{ env.IMAGE_NAME }}:${{ github.sha }} $tag
221+
docker tag ${{ env.TEST_IMAGE_NAME }}:${{ github.sha }} $tag
252222
docker push $tag
253223
done
254224
@@ -269,3 +239,24 @@ jobs:
269239
env:
270240
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
271241
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
242+
243+
# We'll keep around a few old test packages to (a) avoid deleting image for workflows running in parallel,
244+
# and (b) it may be useful to pull a package to troubleshoot workflow failures.
245+
cleanup-test-images:
246+
runs-on: ubuntu-22.04
247+
timeout-minutes: 3
248+
needs: publish-images
249+
if: always()
250+
steps:
251+
- name: Extract package names
252+
run: |
253+
test_image_name="${{ env.TEST_IMAGE_NAME }}"
254+
test_image_pkg=${test_image_name##*/}
255+
echo "TEST_IMAGE_PKG=$test_image_pkg" >> $GITHUB_ENV
256+
257+
- name: Cleanup old ${{ env.TEST_IMAGE_PKG }} packages
258+
uses: actions/delete-package-versions@v4
259+
with:
260+
package-name: "${{ env.TEST_IMAGE_PKG }}"
261+
package-type: "container"
262+
min-versions-to-keep: 5

.github/workflows/codeql.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# the `language` matrix defined below to confirm you have the correct set of
1010
# supported CodeQL languages.
1111
#
12-
name: "CodeQL"
12+
name: "Code scanning using CodeQL"
1313

1414
on:
1515
push:

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ FROM gcr.io/distroless/static:latest
77

88
LABEL maintainers="ThinkParQ"
99
LABEL description="BeeGFS CSI Driver"
10+
LABEL org.opencontainers.image.description="BeeGFS CSI Driver"
11+
LABEL org.opencontainers.image.source="https://github.com/ThinkParQ/beegfs-csi-driver"
12+
LABEL org.opencontainers.image.licenses="Apache-2.0"
1013

1114
# Copy all built binaries to netapp/ directory.
1215
COPY bin/beegfs-csi-driver bin/chwrap netapp/

operator/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# Use distroless as minimal base image to package the manager binary. Refer to
88
# https://github.com/GoogleContainerTools/distroless for more details.
99
FROM gcr.io/distroless/static:nonroot
10+
LABEL org.opencontainers.image.description="BeeGFS CSI Driver Operator"
11+
LABEL org.opencontainers.image.source="https://github.com/ThinkParQ/beegfs-csi-driver/operator"
12+
LABEL org.opencontainers.image.licenses="Apache-2.0"
1013
WORKDIR /
1114
COPY bin/manager .
1215
USER 65532:65532

operator/docs/developer-docs.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,7 @@ Steps:
323323

324324
1. In a terminal, navigate to the *operator/* directory.
325325
2. Set the IMAGE_TAG_BASE environment variable so that it refers to a
326-
container registry namespace you have access to. For example, ThinkParQ
327-
developers should execute `export
328-
IMAGE_TAG_BASE=ghcr.io/thinkparq/test-beegfs-csi-driver-operator`.
329-
External developers might execute `export
326+
container registry namespace you have access to. For example, `export
330327
IMAGE_TAG_BASE=ghcr.io/thinkparq/test-beegfs-csi-driver-operator`.
331328
3. Set the VERSION environment variable. For example, execute
332329
`export VERSION=1.5.0`. The version MUST be semantic (e.g. 0.1.0) and

0 commit comments

Comments
 (0)