From c8689dc5f9b3548ada6df65f968435f6e19c70b5 Mon Sep 17 00:00:00 2001 From: Andrey Velichkevich Date: Thu, 15 Aug 2024 16:23:20 +0100 Subject: [PATCH] KEP-2170: Add directories for the V2 APIs Signed-off-by: Andrey Velichkevich --- .../workflows/build-and-publish-images.yaml | 6 ++++++ .github/workflows/publish-core-images.yaml | 5 +++++ .../template-publish-image/action.yaml | 5 ++++- cmd/training-operator.v2alpha1/Dockerfile | 13 ++++++++++++ cmd/training-operator.v2alpha1/main.go | 21 +++++++++++++++++++ .../v2alpha1/trainingruntime_types.go | 17 +++++++++++++++ .../kubeflow.org/v2alpha1/trainjob_types.go | 17 +++++++++++++++ pkg/controller.v2/trainjob_controller.go | 17 +++++++++++++++ pkg/webhook.v2/trainjob_webhook.go | 17 +++++++++++++++ 9 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 cmd/training-operator.v2alpha1/Dockerfile create mode 100644 cmd/training-operator.v2alpha1/main.go create mode 100644 pkg/apis/kubeflow.org/v2alpha1/trainingruntime_types.go create mode 100644 pkg/apis/kubeflow.org/v2alpha1/trainjob_types.go create mode 100644 pkg/controller.v2/trainjob_controller.go create mode 100644 pkg/webhook.v2/trainjob_webhook.go diff --git a/.github/workflows/build-and-publish-images.yaml b/.github/workflows/build-and-publish-images.yaml index 9d551a1ecb..dbb8ce37a9 100644 --- a/.github/workflows/build-and-publish-images.yaml +++ b/.github/workflows/build-and-publish-images.yaml @@ -17,6 +17,10 @@ on: required: false type: string default: . + prefix: + required: true + type: string + default: v1 secrets: DOCKERHUB_USERNAME: required: false @@ -57,6 +61,7 @@ jobs: platforms: ${{ inputs.platforms }} context: ${{ inputs.context }} push: true + prefix: ${{ inputs.prefix }} - name: Test Build For Component ${{ inputs.component-name }} if: steps.publish.outcome == 'skipped' @@ -67,3 +72,4 @@ jobs: platforms: ${{ inputs.platforms }} context: ${{ inputs.context }} push: false + prefix: ${{ inputs.prefix }} diff --git a/.github/workflows/publish-core-images.yaml b/.github/workflows/publish-core-images.yaml index 3068f901a4..f232d54815 100644 --- a/.github/workflows/publish-core-images.yaml +++ b/.github/workflows/publish-core-images.yaml @@ -13,6 +13,7 @@ jobs: platforms: ${{ matrix.platforms }} dockerfile: ${{ matrix.dockerfile }} context: ${{ matrix.context }} + prefix: ${{matrix.prefix}} secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} @@ -24,6 +25,10 @@ jobs: - component-name: training-operator dockerfile: build/images/training-operator/Dockerfile platforms: linux/amd64,linux/arm64,linux/ppc64le + - component-name: training-operator + dockerfile: cmd/training-operator.v2alpha1/Dockerfile + platforms: linux/amd64,linux/arm64,linux/ppc64le + prefix: v2alpha1 - component-name: kubectl-delivery dockerfile: build/images/kubectl-delivery/Dockerfile platforms: linux/amd64,linux/arm64,linux/ppc64le diff --git a/.github/workflows/template-publish-image/action.yaml b/.github/workflows/template-publish-image/action.yaml index bbde5d1b76..8f73fb30e2 100644 --- a/.github/workflows/template-publish-image/action.yaml +++ b/.github/workflows/template-publish-image/action.yaml @@ -19,6 +19,9 @@ inputs: push: required: true description: whether to push container images or not + prefix: + required: true + description: Prefix for image tag, e.g. v1 or v2alpha1 runs: using: composite @@ -38,7 +41,7 @@ runs: images: ${{ inputs.image }} tags: | type=raw,latest - type=sha,prefix=v1- + type=sha,prefix=${{ inputs.prefix }}- - name: Build and Push uses: docker/build-push-action@v5 diff --git a/cmd/training-operator.v2alpha1/Dockerfile b/cmd/training-operator.v2alpha1/Dockerfile new file mode 100644 index 0000000000..898cff8bf2 --- /dev/null +++ b/cmd/training-operator.v2alpha1/Dockerfile @@ -0,0 +1,13 @@ +# Build the manager binary +FROM golang:1.22 as builder + +WORKDIR /workspace +# Build +RUN --mount=type=bind,target=. CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager cmd/training-operator.v2alpha1/main.go + +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:nonroot +WORKDIR / +COPY --from=builder /workspace/manager . +ENTRYPOINT ["/manager"] diff --git a/cmd/training-operator.v2alpha1/main.go b/cmd/training-operator.v2alpha1/main.go new file mode 100644 index 0000000000..da96f6f2c2 --- /dev/null +++ b/cmd/training-operator.v2alpha1/main.go @@ -0,0 +1,21 @@ +/* +Copyright 2024 The Kubeflow Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +func main() { + +} diff --git a/pkg/apis/kubeflow.org/v2alpha1/trainingruntime_types.go b/pkg/apis/kubeflow.org/v2alpha1/trainingruntime_types.go new file mode 100644 index 0000000000..ab0377d028 --- /dev/null +++ b/pkg/apis/kubeflow.org/v2alpha1/trainingruntime_types.go @@ -0,0 +1,17 @@ +/* +Copyright 2024 The Kubeflow Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v2alpha1 diff --git a/pkg/apis/kubeflow.org/v2alpha1/trainjob_types.go b/pkg/apis/kubeflow.org/v2alpha1/trainjob_types.go new file mode 100644 index 0000000000..ab0377d028 --- /dev/null +++ b/pkg/apis/kubeflow.org/v2alpha1/trainjob_types.go @@ -0,0 +1,17 @@ +/* +Copyright 2024 The Kubeflow Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v2alpha1 diff --git a/pkg/controller.v2/trainjob_controller.go b/pkg/controller.v2/trainjob_controller.go new file mode 100644 index 0000000000..d10f548225 --- /dev/null +++ b/pkg/controller.v2/trainjob_controller.go @@ -0,0 +1,17 @@ +/* +Copyright 2024 The Kubeflow Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package controllerv2 diff --git a/pkg/webhook.v2/trainjob_webhook.go b/pkg/webhook.v2/trainjob_webhook.go new file mode 100644 index 0000000000..f228441857 --- /dev/null +++ b/pkg/webhook.v2/trainjob_webhook.go @@ -0,0 +1,17 @@ +/* +Copyright 2024 The Kubeflow Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package webhookv2