Skip to content

Commit

Permalink
chore: update YQ everywhere and deploy-renku wants split values files.
Browse files Browse the repository at this point in the history
- deploy-renku now expects two files for the values of the Helm chart to deploy:
one is the secrets that are stored in GH organization, the other is a file passed
to the action, meant to be in the Renku repository itself.

- YQ has been updated to version 4.x everywhere and the commands fixed according
to the need of the new version

- The base Docker image have also been updated

- YQ is now installed in all actions through the Alpine package directly
  • Loading branch information
aledegano committed Aug 10, 2023
1 parent 91ce49c commit 63d4ef0
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
6 changes: 2 additions & 4 deletions deploy-renku/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
FROM alpine/k8s:1.21.12
FROM alpine/k8s:1.24.16

# install dependencies
RUN apk add python3 docker jq && \
wget -O /usr/bin/yq "https://github.com/mikefarah/yq/releases/download/3.1.1/yq_linux_amd64" && \
chmod a+x /usr/bin/yq && \
RUN apk add python3 docker jq yq && \
pip3 install -U pip \
chartpress==1.0.0 \
kubernetes \
Expand Down
18 changes: 12 additions & 6 deletions deploy-renku/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
# set up kube context and values file
echo "$RENKUBOT_KUBECONFIG" > "$KUBECONFIG" && chmod 400 "$KUBECONFIG"

# set up the values file
printf "%s" "$RENKU_VALUES" | sed "s/<replace>/${RENKU_RELEASE}/" > $RENKU_VALUES_FILE
export RENKU_VALUES_FILE="/renku-values.yaml"

# merge the secret and clear value files
printf "%s" "$RENKU_SECRET_VALUES" > $RENKU_VALUES_FILE
yq eval-all --inplace '. as $item ireduce ({}; . * $item )' $RENKU_VALUES_FILE $RENKU_CLEAR_VALUES_FILE

# replace the release name
sed --in-place "s/<replace>/${RENKU_RELEASE}/" $RENKU_VALUES_FILE

# register the GitLab app
if test -n "$GITLAB_TOKEN" ; then
Expand All @@ -22,12 +28,12 @@ if test -n "$GITLAB_TOKEN" ; then
--data "name=${RENKU_RELEASE}" \
--data "redirect_uri=https://${RENKU_RELEASE}.dev.renku.ch/auth/realms/Renku/broker/dev-renku/endpoint https://${RENKU_RELEASE}.dev.renku.ch/api/auth/gitlab/token" \
--data "scopes=api read_user read_repository read_registry openid")
APP_ID=$(echo $gitlab_app | jq -r '.application_id')
APP_SECRET=$(echo $gitlab_app | jq -r '.secret')
export APP_ID=$(echo $gitlab_app | jq -r '.application_id')
export APP_SECRET=$(echo $gitlab_app | jq -r '.secret')

# gateway gitlab app/secret
yq w -i $RENKU_VALUES_FILE "gateway.gitlabClientId" "$APP_ID"
yq w -i $RENKU_VALUES_FILE "gateway.gitlabClientSecret" "$APP_SECRET"
yq eval --inplace '.gateway.gitlabClientId = strenv(APP_ID)' $RENKU_VALUES_FILE
yq eval --inplace '.gateway.gitlabClientSecret = strenv(APP_SECRET)' $RENKU_VALUES_FILE
fi

# create namespace and ignore error in case it already exists
Expand Down
9 changes: 3 additions & 6 deletions rollout-renku-version/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM python:3.7-alpine3.10
FROM alpine:3.18

# install dependencies
RUN apk add --no-cache git bash && \
apk add --no-cache --virtual .build-deps gcc g++ make && \
wget -O /usr/bin/yq "https://github.com/mikefarah/yq/releases/download/v4.27.5/yq_linux_amd64" && \
chmod a+x /usr/bin/yq && \
apk del .build-deps
RUN apk update && \
apk add --no-cache git bash yq

COPY rollout-renku-deployment.sh /
RUN chmod +x /rollout-renku-deployment.sh
Expand Down
2 changes: 1 addition & 1 deletion rollout-renku-version/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Action for updating component version

This is a docker action that will update the Renku version (rollout) in the deployments managed by terraform.
This is a docker action that will update the Renku version (rollout) in the deployments managed by Terraform.

## Sample usage

Expand Down
4 changes: 2 additions & 2 deletions rollout-renku-version/rollout-renku-deployment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -xe
set -e

if [ -z "$GITHUB_TOKEN" ]
then
Expand Down Expand Up @@ -47,7 +47,7 @@ do
# update renku version and push
git checkout -b auto-update/${CHART_NAME}-${CHART_VERSION}-${cluster} ${UPSTREAM_BRANCH}

yq -i '.spec.chart.spec.version = strenv(CHART_VERSION)' $cluster_dir/main/charts/renku.yaml
yq eval --inplace '.spec.chart.spec.version = strenv(CHART_VERSION)' $cluster_dir/main/charts/renku.yaml
sed -i "/Renku version/c\ ### Renku version $CHART_VERSION ($DATE)" $cluster_dir/main/charts/renku.yaml
sed -i "/Release Notes/c\ See the [Release Notes](https://github.com/${GITHUB_REPOSITORY}/releases/tag/$CHART_VERSION)" $cluster_dir/main/charts/renku.yaml

Expand Down
13 changes: 6 additions & 7 deletions update-component-version/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM python:3.7-alpine3.10
FROM python:3.9-alpine3.18

# install dependencies
RUN apk add --no-cache git bash && \
apk add --no-cache --virtual .build-deps gcc g++ make && \
wget -O /usr/bin/yq "https://github.com/mikefarah/yq/releases/download/3.1.1/yq_linux_amd64" && \
chmod a+x /usr/bin/yq && \
pip install -U pip chartpress==0.3.2 six==1.16.0 && \
apk del .build-deps
RUN apk add --no-cache git bash yq && \
pip install -U pip \
chartpress==1.0.0 \
'ruamel.yaml<0.17.10' \
'ruamel.yaml.clib<0.2.4'

COPY update-upstream.sh /
ENTRYPOINT [ "/update-upstream.sh" ]
6 changes: 3 additions & 3 deletions update-component-version/update-upstream.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -xe
set -e

if [ -z "$GITHUB_TOKEN" ]
then
Expand All @@ -21,7 +21,7 @@ CHART_NAME=${CHART_NAME:=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)}

# build this chart to get the version
chartpress --skip-build $CHART_TAG
CHART_VERSION=$(yq r helm-chart/${CHART_NAME}/Chart.yaml version)
CHART_VERSION=$(yq eval '.version' helm-chart/${CHART_NAME}/Chart.yaml)

git clone --depth=1 --branch=${UPSTREAM_BRANCH} https://${GITHUB_TOKEN}@github.com/${UPSTREAM_REPO} upstream-repo

Expand All @@ -34,7 +34,7 @@ git config --global user.name "$GIT_USER"

# update the chart requirements and push
git checkout -b auto-update/${CHART_NAME}-${CHART_VERSION} ${UPSTREAM_BRANCH}
yq w -i helm-chart/renku/requirements.yaml "dependencies.(name==${CHART_NAME}).version" $CHART_VERSION
yq eval --inplace '.dependencies.[] |= select (.name == env(CHART_NAME)).version=strenv(CHART_VERSION)' helm-chart/renku/requirements.yaml

git add helm-chart/renku/requirements.yaml
git commit -m "chore: updating ${CHART_NAME} version to ${CHART_VERSION}"
Expand Down
2 changes: 1 addition & 1 deletion update-renku-actions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.15
FROM alpine:3.18

RUN apk add --no-cache yq
COPY entrypoint.sh /
Expand Down

0 comments on commit 63d4ef0

Please sign in to comment.