Skip to content

Commit 48ffe22

Browse files
authored
Support Helm 3 (#140)
1 parent 4d95736 commit 48ffe22

6 files changed

Lines changed: 21 additions & 11 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- name: Install pip
1717
run: |
1818
python -m pip install --upgrade pip
19+
## TODO: Bring me Back. Builds started failing cause of https://github.com/kubernetes/minikube/issues/7903
1920
# - name: minikube
2021
# env:
2122
# K8_PROVIDER: minikube
@@ -38,7 +39,7 @@ jobs:
3839
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
3940
DOCKER_USER: ${{ secrets.DOCKER_USER }}
4041
TRAVIS_REPO_SLUG: ${{ secrets.TRAVIS_REPO_SLUG }}
41-
HELM_VERSION: v2.16.11
42+
HELM_VERSION: v3.5.2
4243

4344
run: |
4445
mkdir $HOME/bin

.travis.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env bash
22

3-
TAG="${GITHUB_SHA:-${GITHUB_REF }}"
3+
REF="${GITHUB_REF:-${GITHUB_SHA}}"
4+
TAG=${REF##*/}
45
AWS_IAM_AUTHENTICATOR_VERSION="1.14.6/2019-08-22"
56
TERRAFORM_VERSION=0.12.18
67
PACKER_VERSION=1.5.1
7-
HELM_VERSION="${HELM_VERSION:-v2.16.1}"
8+
HELM_VERSION="${HELM_VERSION:-v3.5.2}"
89

910
if [ "${1}" == "install" ]; then
1011
! docker pull viderum/ckan-cloud-operator:latest && echo Failed to pull image && exit 1

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
if: (type = push AND (branch = master OR tag IS present)) OR (type != pull_request AND commit_message =~ /#azure/)
6969
env:
7070
- K8_PROVIDER=azure
71-
- HELM_VERSION=v2.16.1
71+
- HELM_VERSION=v3.5.2
7272
before_install: pip install -e .
7373
install: bash .travis.sh install-tools
7474
script:

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.0
1+
v0.7.0-rc1

ckan_cloud_operator/drivers/helm/driver.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ def init(tiller_namespace_name):
3838
}
3939
kubectl.apply(tiller_service_account)
4040
kubectl.apply(cluster_role_binding)
41+
tiller_cmd = '' if _check_helm_version() == 3 else f' --tiller-namespace {tiller_namespace_name}'
4142
subprocess.check_call(
42-
f'helm init --upgrade --service-account {tiller_namespace_name}-tiller --tiller-namespace {tiller_namespace_name} --history-max 10',
43+
f'helm init --upgrade --stable-repo-url https://charts.helm.sh/stable --service-account {tiller_namespace_name}-tiller --history-max 10' + tiller_cmd,
4344
shell=True
4445
)
4546

@@ -55,13 +56,15 @@ def deploy(tiller_namespace, chart_repo, chart_name, chart_version, release_name
5556

5657
version_args = f'--version "{chart_version}"' if chart_version else ''
5758
dry_run_args = '--dry-run --debug'
58-
cmd = f'helm --tiller-namespace {tiller_namespace} upgrade {release_name} {chart_name} ' \
59+
tiller_cmd = '' if _check_helm_version() == 3 else f' --tiller-namespace {tiller_namespace}'
60+
cmd = f'helm upgrade {release_name} {chart_name} ' \
5961
f' --install --namespace "{namespace}" -i {version_args}'
6062
if values_filename:
6163
cmd += f' -f {values_filename}'
6264
elif values:
6365
for key, value in values.items():
6466
cmd += f' --set {key}={value}'
67+
cmd += tiller_cmd
6568
logs.info('Running helm upgrade --dry-run')
6669
if logs.CKAN_CLOUD_OPERATOR_DEBUG_FILE:
6770
logs.info(f'helm dry run debug output is written to debug log file: {logs.CKAN_CLOUD_OPERATOR_DEBUG_FILE}')
@@ -75,4 +78,8 @@ def deploy(tiller_namespace, chart_repo, chart_name, chart_version, release_name
7578

7679

7780
def delete(tiller_namespace, release_name):
78-
subprocess.check_call(f'helm --tiller-namespace {tiller_namespace} delete --purge --timeout 5 {release_name}', shell=True)
81+
tiller_cmd = '' if _check_helm_version() == 3 else f' --tiller-namespace {tiller_namespace}'
82+
subprocess.check_call(f'helm delete --purge --timeout 5 {release_name}' + tiller_cmd, shell=True)
83+
84+
def _check_helm_version():
85+
return 3 if 'v3.' in str(subprocess.check_output('helm version -c', shell=True)) else 2

docker-build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
date +%Y-%m-%d\ %H:%M | tee /etc/ckan-cloud-operator-build-info
44
hostname | tee -a /etc/ckan-cloud-operator-build-info
5-
5+
HELM_VERSION="${HELM_VERSION:-v3.5.2}"
6+
echo $HELM_VERSION
67
(
78
echo == system dependencies, gcloud-sdk &&\
89
apt-get update && apt-get install -y gnupg bash-completion build-essential jq python-pip &&\
@@ -11,8 +12,8 @@ hostname | tee -a /etc/ckan-cloud-operator-build-info
1112
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
1213
apt-get update -y && apt-get install -y google-cloud-sdk kubectl postgresql nano dnsutils &&\
1314
echo == helm, tiller &&\
14-
wget -q https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz &&\
15-
tar -xzf helm-v2.17.0-linux-amd64.tar.gz &&\
15+
wget -q https://get.helm.sh/helm-$HELM_VERSION-linux-amd64.tar.gz &&\
16+
tar -xzf helm-$HELM_VERSION-linux-amd64.tar.gz &&\
1617
mv linux-amd64/helm /usr/local/bin/ && mv linux-amd64/tiller /usr/local/bin/ &&\
1718
chmod +x /usr/local/bin/helm /usr/local/bin/tiller && rm -rf linux-amd64 &&\
1819
echo == minio client &&\

0 commit comments

Comments
 (0)