Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow migrate from HelmChart v1beta1 to v1beta2 if Helm --take-ownership is set #5046

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deploy/apko.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ contents:
- busybox
- curl
- git
- helm
- kustomize
- py3-dateutil
- py3-magic
Expand Down
19 changes: 17 additions & 2 deletions deploy/melange.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,28 @@ environment:
- go
- nodejs
- yarn
- make

pipeline:
- uses: git-checkout
with:
repository: https://github.com/helm/helm
branch: dev-v3
# https://github.com/helm/helm/commit/038321ce79301812e8303372230c8387d00e2d1c
expected-commit: 038321ce79301812e8303372230c8387d00e2d1c
destination: helm

- runs: |
set -x
export DESTDIR="${{targets.destdir}}"
mkdir -p "${DESTDIR}"
mkdir -p ${DESTDIR}/usr/local/bin/

# Build Helm that has --take-ownership flag
# TODO: remove this when latest Helm supports --take-ownership flag
cd helm
make build
mv bin/helm "${DESTDIR}/usr/local/bin/helm"
cd ..

# Scripts etc.
mv deploy/assets/backup.sh "${DESTDIR}/backup.sh"
Expand Down Expand Up @@ -59,6 +75,5 @@ pipeline:
mv bin/kotsadm "${DESTDIR}/kotsadm"
mv bin/kots "${DESTDIR}/kots"

ln -s /usr/bin/helm ${DESTDIR}/usr/local/bin/helm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll also need to remove the helm binary from the apko file: https://github.com/replicatedhq/kots/blob/main/deploy/apko.yaml.tmpl#L16

ln -s /usr/bin/kustomize ${DESTDIR}/usr/local/bin/kustomize
ln -s /usr/bin/kubectl ${DESTDIR}/usr/local/bin/kubectl
22 changes: 11 additions & 11 deletions dev/dockerfiles/kotsadm/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ FROM golang:1.23-alpine AS dlv-builder

RUN go install github.com/go-delve/delve/cmd/[email protected]

# Install helm from PR 13439 that will support --take-ownership flag
# Revert this to the latest helm release when that PR is merged
FROM golang:1.23-alpine AS helm-builder

RUN apk add --no-cache git make bash
RUN git clone --depth 1 -b dev-v3 https://github.com/helm/helm.git && \
cd helm && \
GOARCH=arm64 make && \
chmod a+x bin/helm

FROM golang:1.23-alpine

RUN apk add --no-cache ca-certificates s3cmd curl git make bash
Expand All @@ -26,20 +36,10 @@ RUN curl -fsSL -o kustomize.tar.gz "${KUSTOMIZE5_URL}" \
&& chmod a+x kustomize \
&& mv kustomize /usr/local/bin/kustomize

# Install helm v3
ENV HELM3_VERSION=3.16.2
ENV HELM3_URL=https://get.helm.sh/helm-v${HELM3_VERSION}-linux-arm64.tar.gz
ENV HELM3_SHA256SUM=1888301aeb7d08a03b6d9f4d2b73dcd09b89c41577e80e3455c113629fc657a4
RUN cd /tmp && curl -fsSL -o helm.tar.gz "${HELM3_URL}" \
&& echo "${HELM3_SHA256SUM} helm.tar.gz" | sha256sum -c - \
&& tar -xzvf helm.tar.gz \
&& chmod a+x linux-arm64/helm \
&& mv linux-arm64/helm /usr/local/bin/helm \
&& rm -rf helm.tar.gz linux-arm64

WORKDIR /replicatedhq/kots

COPY --from=dlv-builder /go/bin/dlv /dlv
COPY --from=helm-builder /go/helm/bin/helm /usr/local/bin/helm
COPY ./bin/kotsadm /kotsadm
COPY ./bin/kots /kots

Expand Down
5 changes: 3 additions & 2 deletions pkg/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"os"
"path/filepath"
"slices"

"github.com/pkg/errors"
reportingtypes "github.com/replicatedhq/kots/pkg/api/reporting/types"
Expand Down Expand Up @@ -416,8 +417,8 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
if prevChart.GetReleaseName() != newChart.GetReleaseName() {
continue
}
if !prevChart.Spec.UseHelmInstall {
return "", errors.Errorf("cannot upgrade chart release %s to v1beta2 because useHelmInstall is false", newChart.GetReleaseName())
if !prevChart.Spec.UseHelmInstall && !slices.Contains(newChart.GetUpgradeFlags(), "--take-ownership") {
return "", errors.Errorf("cannot upgrade chart release %s to v1beta2 because useHelmInstall is false and Helm --take-ownership is not set", newChart.GetReleaseName())
}
}
}
Expand Down
Loading