Skip to content

Commit

Permalink
Update CSI (kubeflow#154)
Browse files Browse the repository at this point in the history
* Update model registry CSI

Signed-off-by: Andrea Lamparelli <[email protected]>

* Add CSI build, tag and push workflow

Signed-off-by: Andrea Lamparelli <[email protected]>

---------

Signed-off-by: Andrea Lamparelli <[email protected]>
  • Loading branch information
lampajr authored Jul 25, 2024
1 parent 531becb commit d1aae5b
Show file tree
Hide file tree
Showing 17 changed files with 754 additions and 275 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/csi-build-and-push-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CSI container image build and tag
on:
push:
branches:
- 'main'
tags:
- 'v*'
paths-ignore:
- 'LICENSE*'
- '**.gitignore'
- '**.md'
- '**.txt'
- '.github/ISSUE_TEMPLATE/**'
- '.github/dependabot.yml'
- 'docs/**'
env:
IMG_ORG: kubeflow
IMG_REPO: model-registry-storage-initializer
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PWD: ${{ secrets.DOCKERHUB_TOKEN }}
PUSH_IMAGE: true
jobs:
build-csi-image:
runs-on: ubuntu-latest
steps:
# Assign context variable for various action contexts (tag, main, CI)
- name: Assigning tag context
if: github.head_ref == '' && startsWith(github.ref, 'refs/tags/v')
run: echo "BUILD_CONTEXT=tag" >> $GITHUB_ENV
- name: Assigning main context
if: github.head_ref == '' && github.ref == 'refs/heads/main'
run: echo "BUILD_CONTEXT=main" >> $GITHUB_ENV
# checkout branch
- uses: actions/checkout@v4
# set image version
- name: Set main-branch environment
if: env.BUILD_CONTEXT == 'main'
run: |
commit_sha=${{ github.event.after }}
tag=main-${commit_sha:0:7}
echo "VERSION=${tag}" >> $GITHUB_ENV
- name: Set tag environment
if: env.BUILD_CONTEXT == 'tag'
run: |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
# docker login
- name: Docker login
shell: bash
run: make docker/login
# build & push
- name: Build CSI Image
working-directory: ./csi
shell: bash
env:
IMG_ORG: ${{ env.IMG_ORG }}
IMG_REPO: ${{ env.IMG_REPO }}
IMG_VERSION: ${{ env.VERSION }}
run: |
make docker-build-dev
- name: Push CSI Image
if: env.PUSH_IMAGE == 'true'
shell: bash
env:
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }}
run: IMG=${{ env.IMG }} IMG_VERSION=${{ env.VERSION }} make image/push
# Tag latest and main
- name: Tag Latest
if: env.BUILD_CONTEXT == 'main' && env.PUSH_IMAGE == 'true'
shell: bash
env:
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }}
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:latest
IMG=${{ env.IMG }} IMG_VERSION=latest make image/push
- name: Tag Main
if: env.BUILD_CONTEXT == 'main' && env.PUSH_IMAGE == 'true'
shell: bash
env:
IMG: ${{ env.IMG_ORG }}/${{ env.IMG_REPO }}
run: |
docker tag ${{ env.IMG }}:$VERSION ${{ env.IMG }}:main
IMG=${{ env.IMG }} IMG_VERSION=main make image/push
74 changes: 74 additions & 0 deletions .github/workflows/csi-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Test CSI
on:
push:
branches:
- "main"
paths-ignore:
- 'LICENSE*'
- '**.gitignore'
- '**.md'
- '**.txt'
- '.github/ISSUE_TEMPLATE/**'
- '.github/dependabot.yml'
- 'docs/**'
pull_request:
paths:
- "csi/**"
- "internal/server/openapi/api_model_registry_service*"
- "pkg/openapi/**"

env:
IMG_ORG: kubeflow
MODEL_REGISTRY_IMG: model-registry
MODEL_REGISTRY_CSI_IMG: model-registry-storage-initializer
PUSH_IMAGE: false
BRANCH: ${{ github.base_ref }}
jobs:
build-and-test-csi-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Generate tag
shell: bash
id: tags
run: |
commit_sha=${{ github.event.after }}
tag=main-${commit_sha:0:7}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Install network tools
run: sudo apt-get update && sudo apt-get install -y netcat

- name: Build local model registry image
shell: bash
env:
IMG_REPO: ${{ env.MODEL_REGISTRY_IMG }}
VERSION: ${{ steps.tags.outputs.tag }}
PUSH_IMAGE: false
run: ./scripts/build_deploy.sh

- name: Build local custom storage initializer
working-directory: ./csi
shell: bash
env:
IMG_REPO: ${{ env.MODEL_REGISTRY_CSI_IMG }}
IMG_VERSION: ${{ steps.tags.outputs.tag }}
run: make docker-build-dev

- name: Start KinD cluster
uses: helm/[email protected]
with:
node_image: "kindest/node:v1.27.11"

- name: Install kustomize
run: ./csi/scripts/install_kustomize.sh

- name: Run tests
working-directory: ./csi
shell: bash
env:
MR_IMG: "${{ env.IMG_ORG }}/${{ env.MODEL_REGISTRY_IMG }}:${{ steps.tags.outputs.tag }}"
MR_CSI_IMG: "${{ env.IMG_ORG }}/${{ env.MODEL_REGISTRY_CSI_IMG }}:${{ steps.tags.outputs.tag }}"
CLUSTER: chart-testing
run: ./test/e2e_test.sh
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the model-registry binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.odh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the model-registry binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
3 changes: 3 additions & 0 deletions csi/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ bin/

# Go workspace file
go.work

# KServe manifests
istio-*
9 changes: 6 additions & 3 deletions csi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Build the model-registry binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder
# This Dockerfile MUST be used if using a fixed version of model-registry dependency
# This assumes the root is the csi/ folder

# Build the model-registry-storage-initializer binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -14,7 +17,7 @@ USER root
COPY ["Makefile", "main.go", "./"]

# Copy rest of the source
COPY bin/ bin/
# COPY bin/ bin/
COPY pkg/ pkg/

# Build
Expand Down
45 changes: 45 additions & 0 deletions csi/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Build the model-registry-storage-initializer binary
# This assumes the root is the model-registry repository
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 AS builder

WORKDIR /modelregistry
# Copy the model-registry Go Modules manifests and sources
COPY go.mod go.mod
COPY go.sum go.sum
COPY cmd/ cmd/
COPY api/ api/
COPY internal/ internal/
COPY scripts/ scripts/
COPY pkg/ pkg/
COPY patches/ patches/
COPY templates/ templates/

USER root

WORKDIR /modelregistry/csi
# Copy the Go Modules manifests
COPY csi/go.mod go.mod
COPY csi/go.sum go.sum
RUN echo "replace github.com/kubeflow/model-registry => ../" >> go.mod
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy rest of the source
COPY csi/Makefile Makefile
COPY csi/main.go main.go
COPY csi/pkg/ pkg/

# Build
USER root
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make build

# Use distroless as minimal base image to package the model-registry storage initializer binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
WORKDIR /
# copy the storage initializer binary
COPY --from=builder /modelregistry/csi/bin/mr-storage-initializer .
USER 65532:65532

ENTRYPOINT ["/mr-storage-initializer"]
Loading

0 comments on commit d1aae5b

Please sign in to comment.