From 6ad6ec628ca3f0a847d34d6944c6d25ec1bee18b Mon Sep 17 00:00:00 2001 From: Prateek Baheti Date: Tue, 22 Dec 2020 15:25:13 +0400 Subject: [PATCH 1/3] Change default value of helm to 2.1.1 Change the default value of stable_repo_url since the old one is invalid now. Changes in the original repo have not been made yet https://github.com/hashicorp/terraform-provider-helm/issues/649 --- Dockerfile | 2 +- README.md | 16 ++++++++++++++++ main.go | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6352dd3..d32fe64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ COPY --from=builder /go/src/github.com/ipedrazas/drone-helm/drone-helm /bin/ # Helm version: can be passed at build time ARG VERSION -ENV VERSION ${VERSION:-v2.14.1} +ENV VERSION ${VERSION:-v2.11.0} ENV FILENAME helm-${VERSION}-linux-amd64.tar.gz ARG KUBECTL diff --git a/README.md b/README.md index aa30c7c..fc24592 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ +# Drone helm MoneySmart +This is a forked repository from https://github.com/ipedrazas/drone-helm +The image built is used in drone tasks to deploy helm charts to EKS. + +Two changes have been introduced to the base repo +1. The Helm version has been hardcoded to use version 2.11 +2. The stable repo url default value has been set to "https://charts.helm.sh/stable" since helm version needs updating for the [actual fix](https://github.com/hashicorp/terraform-provider-helm/issues/649) for this. + +Image has been built and pushed to [dockerhub](https://hub.docker.com/repository/docker/moneysmartco/drone-helm) manually. + +To build and upload image run +``` +docker build -t moneysmartco/drone-helm:tag-name +docker push moneysmartco/drone-helm:tag-name +``` + # Helm (Kubernetes) plugin for drone.io [![Build Status](https://cloud.drone.io/api/badges/ipedrazas/drone-helm/status.svg)](https://cloud.drone.io/ipedrazas/drone-helm) diff --git a/main.go b/main.go index 3d62049..1be8b81 100644 --- a/main.go +++ b/main.go @@ -160,7 +160,8 @@ func main() { }, cli.StringFlag{ Name: "stable_repo_url", - Usage: "URL for stable repository (default 'https://kubernetes-charts.storage.googleapis.com')", + Usage: "URL for stable repository (default 'https://charts.helm.sh/stable')", + Value: "https://charts.helm.sh/stable", EnvVar: "PLUGIN_STABLE_REPO_URL,STABLE_REPO_URL", }, } From 475f06760f9f374cffb7d7aa6fe271b820e63dc9 Mon Sep 17 00:00:00 2001 From: apoorvshrivastava-ms Date: Fri, 23 Apr 2021 09:24:57 +0530 Subject: [PATCH 2/3] helm upgrade to v3 --- Dockerfile | 7 +++---- README.md | 4 ++-- plugin/plugin.go | 14 +++++++------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index d32fe64..d838f6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,21 +19,20 @@ RUN go build # ------ Drone-Helm plugin image ------ # FROM alpine:3.9 as final -MAINTAINER Ivan Pedrazas COPY --from=builder /go/src/github.com/ipedrazas/drone-helm/drone-helm /bin/ # Helm version: can be passed at build time ARG VERSION -ENV VERSION ${VERSION:-v2.11.0} +ENV VERSION ${VERSION:-v3.4.2} ENV FILENAME helm-${VERSION}-linux-amd64.tar.gz ARG KUBECTL -ENV KUBECTL ${KUBECTL:-v1.14.3} +ENV KUBECTL ${KUBECTL:-v1.21.0} RUN set -ex \ && apk add --no-cache curl ca-certificates \ - && curl -o /tmp/${FILENAME} http://storage.googleapis.com/kubernetes-helm/${FILENAME} \ + && curl -o /tmp/${FILENAME} https://get.helm.sh/${FILENAME} \ && curl -o /tmp/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL}/bin/linux/amd64/kubectl \ && curl -o /tmp/aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator \ && tar -zxvf /tmp/${FILENAME} -C /tmp \ diff --git a/README.md b/README.md index fc24592..2631dcb 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ docker push moneysmartco/drone-helm:tag-name This plugin allows to deploy a [Helm](https://github.com/kubernetes/helm) chart into a [Kubernetes](https://github.com/kubernetes/kubernetes) cluster. -* Current `helm` version: 2.14.1 -* Current `kubectl` version: 1.14.3 +* Current `helm` version: 3.4.2 +* Current `kubectl` version: 1.21.0 ## Drone Pipeline Usage diff --git a/plugin/plugin.go b/plugin/plugin.go index c83c964..aa4cdf0 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -292,11 +292,11 @@ func (p *Plugin) Exec() error { p.debug() } - init := doHelmInit(p) - err := runCommand(init) - if err != nil { - return fmt.Errorf("Error running helm command: " + strings.Join(init[:], " ")) - } + // init := doHelmInit(p) + // err := runCommand(init) + // if err != nil { + // return fmt.Errorf("Error running helm command: " + strings.Join(init[:], " ")) + // } if len(p.Config.HelmRepos) > 0 { for _, repo := range p.Config.HelmRepos { @@ -316,7 +316,7 @@ func (p *Plugin) Exec() error { } if p.Config.UpdateDependencies { - if err = runCommand(doDependencyUpdate(p.Config.Chart)); err != nil { + if err := runCommand(doDependencyUpdate(p.Config.Chart)); err != nil { return fmt.Errorf("Error updating dependencies: " + err.Error()) } } @@ -327,7 +327,7 @@ func (p *Plugin) Exec() error { log.Println("helm command: " + strings.Join(p.command, " ")) } - err = runCommand(p.command) + var err = runCommand(p.command) if err != nil { return fmt.Errorf("Error running helm command: " + strings.Join(p.command[:], " ")) } From 86c4cf154e81451d06393f7def10e8825710ad5e Mon Sep 17 00:00:00 2001 From: apoorvshrivastava-ms Date: Fri, 23 Apr 2021 10:52:39 +0530 Subject: [PATCH 3/3] adding create namespace --- plugin/plugin.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/plugin.go b/plugin/plugin.go index aa4cdf0..f64b645 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -111,6 +111,7 @@ func setUpgradeCommand(p *Plugin) { if p.Config.Namespace != "" { upgrade = append(upgrade, "--namespace") upgrade = append(upgrade, p.Config.Namespace) + upgrade = append(upgrade, "--create-namespace") } if p.Config.TillerNs != "" { upgrade = append(upgrade, "--tiller-namespace")