From ee3c75c14b573e23c0e343da5f1a1564fbec3f8d Mon Sep 17 00:00:00 2001 From: Karan Kumar Date: Mon, 15 Jul 2024 00:28:29 +0530 Subject: [PATCH] add script for storage version migartion of crds --- README.md | 43 ++++++++-------- deploy/200-role.yaml | 12 +++-- hack/storage-version-migration.sh | 85 +++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 24 deletions(-) create mode 100755 hack/storage-version-migration.sh diff --git a/README.md b/README.md index d8f6417824..4bc2894375 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,9 @@ Shipwright supports any tool that can build container images in Kubernetes clust - Install the Shipwright deployment. To install the latest version, run: ```bash - kubectl apply --filename https://github.com/shipwright-io/build/releases/download/v0.12.0/release.yaml --server-side - curl --silent --location https://raw.githubusercontent.com/shipwright-io/build/v0.12.0/hack/setup-webhook-cert.sh | bash + kubectl apply --filename https://github.com/shipwright-io/build/releases/download/v0.13.0/release.yaml --server-side + curl --silent --location https://raw.githubusercontent.com/shipwright-io/build/v0.13.0/hack/setup-webhook-cert.sh | bash + curl --silent --location https://raw.githubusercontent.com/shipwright-io/build/main/hack/storage-version-migration.sh | bash ``` To install the latest nightly release, run: @@ -56,12 +57,13 @@ Shipwright supports any tool that can build container images in Kubernetes clust ```bash kubectl apply --filename "https://github.com/shipwright-io/build/releases/download/nightly/nightly-$(curl --silent --location https://github.com/shipwright-io/build/releases/download/nightly/latest.txt).yaml" --server-side curl --silent --location https://raw.githubusercontent.com/shipwright-io/build/main/hack/setup-webhook-cert.sh | bash + curl --silent --location https://raw.githubusercontent.com/shipwright-io/build/main/hack/storage-version-migration.sh | bash ``` - Install the Shipwright strategies. To install the latest version, run: ```bash - kubectl apply --filename https://github.com/shipwright-io/build/releases/download/v0.12.0/sample-strategies.yaml --server-side + kubectl apply --filename https://github.com/shipwright-io/build/releases/download/v0.13.0/sample-strategies.yaml --server-side ``` To install the latest nightly release, run: @@ -166,23 +168,24 @@ To find out more on what's the best strategy or what else can Shipwright do for ### Read the Docs -| Version | Docs | Examples | -|------------------------------------------------------------------------|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------| -| HEAD | [Docs @ HEAD](docs/README.md) | [Examples @ HEAD](samples) | -| [v0.12.0](https://github.com/shipwright-io/build/releases/tag/v0.12.0) | [Docs @ v0.12.0](https://github.com/shipwright-io/build/tree/v0.12.0/docs) | [Examples @ v0.12.0](https://github.com/shipwright-io/build/tree/v0.12.0/samples) | -| [v0.11.0](https://github.com/shipwright-io/build/releases/tag/v0.11.0) | [Docs @ v0.11.0](https://github.com/shipwright-io/build/tree/v0.11.0/docs) | [Examples @ v0.11.0](https://github.com/shipwright-io/build/tree/v0.11.0/samples) | -| [v0.10.0](https://github.com/shipwright-io/build/releases/tag/v0.10.0) | [Docs @ v0.10.0](https://github.com/shipwright-io/build/tree/v0.10.0/docs) | [Examples @ v0.10.0](https://github.com/shipwright-io/build/tree/v0.10.0/samples) | -| [v0.9.0](https://github.com/shipwright-io/build/releases/tag/v0.9.0) | [Docs @ v0.9.0](https://github.com/shipwright-io/build/tree/v0.9.0/docs) | [Examples @ v0.9.0](https://github.com/shipwright-io/build/tree/v0.9.0/samples) | -| [v0.8.0](https://github.com/shipwright-io/build/releases/tag/v0.8.0) | [Docs @ v0.8.0](https://github.com/shipwright-io/build/tree/v0.8.0/docs) | [Examples @ v0.8.0](https://github.com/shipwright-io/build/tree/v0.8.0/samples) | -| [v0.7.0](https://github.com/shipwright-io/build/releases/tag/v0.7.0) | [Docs @ v0.7.0](https://github.com/shipwright-io/build/tree/v0.7.0/docs) | [Examples @ v0.7.0](https://github.com/shipwright-io/build/tree/v0.7.0/samples) | -| [v0.6.0](https://github.com/shipwright-io/build/releases/tag/v0.6.0) | [Docs @ v0.6.0](https://github.com/shipwright-io/build/tree/v0.6.0/docs) | [Examples @ v0.6.0](https://github.com/shipwright-io/build/tree/v0.6.0/samples) | -| [v0.5.1](https://github.com/shipwright-io/build/releases/tag/v0.5.1) | [Docs @ v0.5.1](https://github.com/shipwright-io/build/tree/v0.5.1/docs) | [Examples @ v0.5.1](https://github.com/shipwright-io/build/tree/v0.5.1/samples) | -| [v0.5.0](https://github.com/shipwright-io/build/releases/tag/v0.5.0) | [Docs @ v0.5.0](https://github.com/shipwright-io/build/tree/v0.5.0/docs) | [Examples @ v0.5.0](https://github.com/shipwright-io/build/tree/v0.5.0/samples) | -| [v0.4.0](https://github.com/shipwright-io/build/releases/tag/v0.4.0) | [Docs @ v0.4.0](https://github.com/shipwright-io/build/tree/v0.4.0/docs) | [Examples @ v0.4.0](https://github.com/shipwright-io/build/tree/v0.4.0/samples) | -| [v0.3.0](https://github.com/shipwright-io/build/releases/tag/v0.3.0) | [Docs @ v0.3.0](https://github.com/shipwright-io/build/tree/v0.3.0/docs) | [Examples @ v0.3.0](https://github.com/shipwright-io/build/tree/v0.3.0/samples) | -| [v0.2.0](https://github.com/shipwright-io/build/releases/tag/v0.2.0) | [Docs @ v0.2.0](https://github.com/shipwright-io/build/tree/v0.2.0/docs) | [Examples @ v0.2.0](https://github.com/shipwright-io/build/tree/v0.2.0/samples) | -| [v0.1.1](https://github.com/shipwright-io/build/releases/tag/v0.1.1) | [Docs @ v0.1.1](https://github.com/shipwright-io/build/tree/v0.1.1/docs) | [Examples @ v0.1.1](https://github.com/shipwright-io/build/tree/v0.1.1/samples) | -| [v0.1.0](https://github.com/shipwright-io/build/releases/tag/v0.1.0) | [Docs @ v0.1.0](https://github.com/shipwright-io/build/tree/v0.1.0/docs) | [Examples @ v0.1.0](https://github.com/shipwright-io/build/tree/v0.1.0/samples) | +| Version | Docs | Examples | +| ------- | ------------------------------ | --------------------------- | +| HEAD | [Docs @ HEAD](docs/README.md) | [Examples @ HEAD](samples) | +| [v0.13.0](https://github.com/shipwright-io/build/releases/tag/v0.13.0) | [Docs @ v0.13.0](https://github.com/shipwright-io/build/tree/v0.13.0/docs) | [Examples @ v0.13.0](https://github.com/shipwright-io/build/tree/v0.13.0/samples) | +| [v0.12.0](https://github.com/shipwright-io/build/releases/tag/v0.12.0) | [Docs @ v0.12.0](https://github.com/shipwright-io/build/tree/v0.12.0/docs) | [Examples @ v0.12.0](https://github.com/shipwright-io/build/tree/v0.12.0/samples) | +| [v0.11.0](https://github.com/shipwright-io/build/releases/tag/v0.11.0) | [Docs @ v0.11.0](https://github.com/shipwright-io/build/tree/v0.11.0/docs) | [Examples @ v0.11.0](https://github.com/shipwright-io/build/tree/v0.11.0/samples) | +| [v0.10.0](https://github.com/shipwright-io/build/releases/tag/v0.10.0) | [Docs @ v0.10.0](https://github.com/shipwright-io/build/tree/v0.10.0/docs) | [Examples @ v0.10.0](https://github.com/shipwright-io/build/tree/v0.10.0/samples) | +| [v0.9.0](https://github.com/shipwright-io/build/releases/tag/v0.9.0) | [Docs @ v0.9.0](https://github.com/shipwright-io/build/tree/v0.9.0/docs) | [Examples @ v0.9.0](https://github.com/shipwright-io/build/tree/v0.9.0/samples) | +| [v0.8.0](https://github.com/shipwright-io/build/releases/tag/v0.8.0) | [Docs @ v0.8.0](https://github.com/shipwright-io/build/tree/v0.8.0/docs) | [Examples @ v0.8.0](https://github.com/shipwright-io/build/tree/v0.8.0/samples) | +| [v0.7.0](https://github.com/shipwright-io/build/releases/tag/v0.7.0) | [Docs @ v0.7.0](https://github.com/shipwright-io/build/tree/v0.7.0/docs) | [Examples @ v0.7.0](https://github.com/shipwright-io/build/tree/v0.7.0/samples) | +| [v0.6.0](https://github.com/shipwright-io/build/releases/tag/v0.6.0) | [Docs @ v0.6.0](https://github.com/shipwright-io/build/tree/v0.6.0/docs) | [Examples @ v0.6.0](https://github.com/shipwright-io/build/tree/v0.6.0/samples) | +| [v0.5.1](https://github.com/shipwright-io/build/releases/tag/v0.5.1) | [Docs @ v0.5.1](https://github.com/shipwright-io/build/tree/v0.5.1/docs) | [Examples @ v0.5.1](https://github.com/shipwright-io/build/tree/v0.5.1/samples) | +| [v0.5.0](https://github.com/shipwright-io/build/releases/tag/v0.5.0) | [Docs @ v0.5.0](https://github.com/shipwright-io/build/tree/v0.5.0/docs) | [Examples @ v0.5.0](https://github.com/shipwright-io/build/tree/v0.5.0/samples) | +| [v0.4.0](https://github.com/shipwright-io/build/releases/tag/v0.4.0) | [Docs @ v0.4.0](https://github.com/shipwright-io/build/tree/v0.4.0/docs) | [Examples @ v0.4.0](https://github.com/shipwright-io/build/tree/v0.4.0/samples) | +| [v0.3.0](https://github.com/shipwright-io/build/releases/tag/v0.3.0) | [Docs @ v0.3.0](https://github.com/shipwright-io/build/tree/v0.3.0/docs) | [Examples @ v0.3.0](https://github.com/shipwright-io/build/tree/v0.3.0/samples) | +| [v0.2.0](https://github.com/shipwright-io/build/releases/tag/v0.2.0) | [Docs @ v0.2.0](https://github.com/shipwright-io/build/tree/v0.2.0/docs) | [Examples @ v0.2.0](https://github.com/shipwright-io/build/tree/v0.2.0/samples) | +| [v0.1.1](https://github.com/shipwright-io/build/releases/tag/v0.1.1) | [Docs @ v0.1.1](https://github.com/shipwright-io/build/tree/v0.1.1/docs) | [Examples @ v0.1.1](https://github.com/shipwright-io/build/tree/v0.1.1/samples) | +| [v0.1.0](https://github.com/shipwright-io/build/releases/tag/v0.1.0) | [Docs @ v0.1.0](https://github.com/shipwright-io/build/tree/v0.1.0/docs) | [Examples @ v0.1.0](https://github.com/shipwright-io/build/tree/v0.1.0/samples) | ### Dependencies diff --git a/deploy/200-role.yaml b/deploy/200-role.yaml index e605556317..ef773bde5d 100644 --- a/deploy/200-role.yaml +++ b/deploy/200-role.yaml @@ -27,7 +27,7 @@ rules: resources: ['buildruns'] # The build-run-deletion annotation sets an owner ref on BuildRun objects. # With the OwnerReferencesPermissionEnforcement admission controller enabled, controllers need the "delete" permission on objects that they set owner references on. - verbs: ['get', 'list', 'watch', 'update', 'delete'] + verbs: ['get', 'list', 'watch', 'update', 'delete', 'patch'] - apiGroups: ['shipwright.io'] # BuildRuns are set as the owners of Tekton TaskRuns. @@ -41,7 +41,7 @@ rules: - apiGroups: ['shipwright.io'] resources: ['builds'] - verbs: ['get', 'list', 'watch'] + verbs: ['get', 'list', 'watch', 'patch'] - apiGroups: ['shipwright.io'] # The build-run-deletion annotation makes Builds an owner of BuildRun objects. @@ -55,11 +55,11 @@ rules: - apiGroups: ['shipwright.io'] resources: ['buildstrategies'] - verbs: ['get', 'list', 'watch'] + verbs: ['get', 'list', 'watch', 'patch'] - apiGroups: ['shipwright.io'] resources: ['clusterbuildstrategies'] - verbs: ['get', 'list', 'watch'] + verbs: ['get', 'list', 'watch', 'patch'] - apiGroups: ['tekton.dev'] resources: ['taskruns'] @@ -82,3 +82,7 @@ rules: - apiGroups: [''] resources: ['serviceaccounts'] verbs: ['get', 'list', 'watch', 'create', 'update', 'delete'] + +- apiGroups: ['apiextensions.k8s.io'] + resources: ['customresourcedefinitions', 'customresourcedefinitions/status'] + verbs: ['get', 'list', 'watch', 'create', 'update', 'delete' 'patch'] diff --git a/hack/storage-version-migration.sh b/hack/storage-version-migration.sh new file mode 100755 index 0000000000..a64fb29936 --- /dev/null +++ b/hack/storage-version-migration.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# Copyright The Shipwright Contributors +# +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +if ! hash jq >/dev/null 2>&1 ; then + echo "[ERROR] jq is not installed" + exit 1 +fi + +# Delete old job for storage version migration +kubectl -n shipwright-build delete job --selector app=storage-version-migration-shipwright --wait=true + +# create new job for storage version migration +cat <