Skip to content

Commit

Permalink
release v0.5.0; ensure "latest" Docker tag is pushed; use versioned D…
Browse files Browse the repository at this point in the history
…ocker tag in the Chart (#96)

- Bump the version to v0.5.0 for a release.
- Change the chart values to use the matching
  "docker.elastic.co/observability/apm-attacher:v$VERSION" tagged Docker
  image instead of using the "latest".
- Add a lint step to ensure those versions are in sync.
- Drop the "publish" CI workflow that would tag/push a new Docker image
  for every commit to main. These aren't used or needed.
- Bump the version of some "actions/..." in CI workflows.
- Also added a RELEASING.md to document the release process.

Fixes: #42
Fixes: #95
Co-authored-by: jackshirazi <[email protected]>
  • Loading branch information
trentm and jackshirazi authored Jan 15, 2024
1 parent 35df17d commit 8092842
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 99 deletions.
31 changes: 0 additions & 31 deletions .ci/docker-package-push.sh

This file was deleted.

19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
Expand All @@ -36,12 +36,13 @@ jobs:
gofmt -l . | read && echo "Code differs from gofmt's style. Run 'gofmt -w .'" 1>&2 && exit 1 || true
- name: Go vet
run: go vet
- run: ./scripts/lint-versions.sh
notice:
name: NOTICE.txt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
Expand All @@ -55,8 +56,8 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
Expand All @@ -68,8 +69,8 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
Expand All @@ -89,6 +90,6 @@ jobs:
name: Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Package
run: make .webhook
16 changes: 9 additions & 7 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ jobs:
with:
version: v3.11.2

- name: Install webhook
run:
cd charts;
helm install webhook-chart apm-attacher/ --namespace=elastic-apm --create-namespace --values ../test/mock/test_values.yaml;
sleep 5;
export CHART_SERVICE=`kubectl get pods -A | grep 'webhook-chart' | awk -F ' ' '{print $2}'` ;
sh ../test/mock/wait_for_container_start.sh $CHART_SERVICE elastic-apm;
- name: Build and install webhook
run: |
make .webhook # builds "apm/apm-attacher:latest" Docker image
docker tag apm/apm-attacher:latest localhost:5001/apm-attacher:latest
docker push localhost:5001/apm-attacher:latest
helm install webhook-chart ./charts/apm-attacher/ --namespace=elastic-apm --create-namespace --values test/mock/test_values.yaml
sleep 5
export POD_NAME=`kubectl get pods -A | grep 'webhook-chart' | awk -F ' ' '{print $2}'`
sh test/mock/wait_for_container_start.sh $POD_NAME
- name: Start Test Images
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/opentelemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_run:
workflows:
- ci
- publish
- release
types: [completed]

jobs:
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/publish.yml

This file was deleted.

16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ jobs:
env:
DOCKER_REGISTRY: docker.elastic.co
DOCKER_SECRET: secret/observability-team/ci/docker-registry/prod
DOCKER_IMAGE_NAME: apm-attacher
DOCKER_IMAGE_NAME: observability/apm-attacher
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: elastic/apm-pipeline-library/.github/actions/docker-login@current
with:
registry: ${{ env.DOCKER_REGISTRY }}
secret: ${{ env.DOCKER_SECRET }}
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
- name: Package & Publish
- name: Docker build, tag, and push
run: |
./.ci/docker-package-push.sh ${DOCKER_REGISTRY}/observability ${DOCKER_IMAGE_NAME} ${{ github.ref_name }}
make .webhook REPO=${DOCKER_REGISTRY} NAME=${DOCKER_IMAGE_NAME} TAG=${{ github.ref_name }}
docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${{ github.ref_name }}
docker tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:${{ github.ref_name }} ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:latest
docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE_NAME}:latest
release-helm-charts:
name: Release Helm Charts
Expand All @@ -52,12 +55,11 @@ jobs:
# Needed to create the release notes
contents: write
steps:
- uses: actions/checkout@v3
- name: make release-notes
- uses: actions/checkout@v4
- run: make -C .ci release-notes
env:
BRANCH_NAME: ${{ github.ref_name }}
GH_TOKEN: ${{ github.token }}
run: make -C .ci release-notes

status:
if: always()
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ update-licenses:
lint:
go run $(GO_CI_LINT) version
go run $(GO_CI_LINT) run
./scripts/lint-versions.sh

.webhook: *.go Dockerfile
docker build --build-arg GO_VERSION=$(shell cat .go-version) -t $(REPO)/$(NAME):$(TAG) .
Expand Down
28 changes: 28 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to release apm-k8s-attacher

0. Make sure everything is working by testing "main". (TODO: Clarify a manual testing procedure if one is required beyond automated tests.)
1. Create a PR for the release (named "release N.M.P" or whatever):
- Update the `version:` at "./charts/apm-attacher/Chart.yaml", e.g. "1.2.3".
- Update the `image.tag:` at "./charts/apm-attacher/values.yaml", e.g. "v1.2.3".
Note that this file includes a "v" prefix in the version.
Get the PR approved and merged.
2. Working in a clone of the actual repo (not a fork), lightweight tag the repo:
```
git tag vN.M.P
git push origin vN.M.P
```
3. Sanity check that the release worked:
- The release CI should trigger on the pushed tag. Check https://github.com/elastic/apm-k8s-attacher/actions/workflows/release.yml
- https://github.com/elastic/apm-k8s-attacher/releases should show the new release.
- The Elastic Docker registry should show the new `docker.elastic.co/observability/apm-attacher:vN.M.P` version
and the "latest" tag should pull the same digest
```
docker pull docker.elastic.co/observability/apm-attacher:vN.M.P
docker pull docker.elastic.co/observability/apm-attacher:latest # same digest?
```
- The Elastic Helm repository should show the new release, though it may take a while (an hour?) to show up:
```
helm repo add elastic https://helm.elastic.co
helm repo update elastic
helm search repo -l elastic/apm-attacher
```
2 changes: 1 addition & 1 deletion charts/apm-attacher/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: apm-attacher
type: application
version: "0.4.0"
version: "0.5.0"
description: A Helm chart installing the Elastic APM Kubernetes Attacher.
sources:
- https://github.com/elastic/apm-k8s-attacher
4 changes: 2 additions & 2 deletions charts/apm-attacher/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image:
repository: docker.elastic.co/observability/apm-attacher
tag: latest
tag: "v0.5.0"
pullPolicy: Always
pullSecrets: []

Expand Down Expand Up @@ -41,6 +41,6 @@ webhookConfig:
environment:
CORECLR_ENABLE_PROFILING: "1"
CORECLR_PROFILER: "{FA65FE15-F085-4681-9B20-95E04F6C03CC}"
CORECLR_PROFILER_PATH: "/usr/agent/apm-dotnet-agent/libelastic_apm_profiler.so"
CORECLR_PROFILER_PATH: "/usr/agent/apm-dotnet-agent/libelastic_apm_profiler.so"
ELASTIC_APM_PROFILER_HOME: "/usr/agent/apm-dotnet-agent"
ELASTIC_APM_PROFILER_INTEGRATIONS: "/usr/agent/apm-dotnet-agent/integrations.yml"
44 changes: 44 additions & 0 deletions scripts/lint-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# Copyright 2022 Elasticsearch BV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Doing a release involves updating the version in two places. This script
# ensures those versions match.

if [ "$TRACE" != "" ]; then
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace
fi
set -o errexit
set -o pipefail

TOP=$(unset CDPATH; cd $(dirname $0)/../; pwd)

function fatal {
echo "$(basename $0): error: $*"
exit 1
}

CHART_PATH=charts/apm-attacher/Chart.yaml
CHART_VER=$(grep "^version:" "$TOP/$CHART_PATH" | cut -d'"' -f2)
VALUES_PATH=charts/apm-attacher/values.yaml
VALUES_VER=$(grep "tag:" "$TOP/$VALUES_PATH" | cut -d'"' -f2)

if [[ "${VALUES_VER:0:1}" != "v" ]]; then
fatal "tag value in $VALUES_PATH, '$VALUES_VER', does not start with a 'v'"
fi
if [[ "v$CHART_VER" != "$VALUES_VER" ]]; then
fatal "version in $CHART_PATH, '$CHART_VER', does not match tag in $VALUES_PATH, '$VALUES_VER'"
fi
9 changes: 6 additions & 3 deletions test/mock/test_values.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
image:
repository: localhost:5001/apm-attacher
tag: "latest"
apm:
secret_token: YOUR_SECRET_TOKEN
namespaces:
namespaces:
- default
webhookConfig:
agents:
java:
java:
environment:
ELASTIC_APM_SERVER_URL: "http://mock-apm-server-service:8027"
ELASTIC_APM_ENVIRONMENT: "test"
ELASTIC_APM_LOG_LEVEL: "DEBUG"
nodejs:
nodejs:
environment:
ELASTIC_APM_SERVER_URL: "http://mock-apm-server-service:8027"
ELASTIC_APM_ENVIRONMENT: "test"
Expand Down
9 changes: 8 additions & 1 deletion test/mock/wait_for_container_start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

MAX_WAIT_SECONDS=60
POD_NAME=$1
echo "Waiting up to $MAX_WAIT_SECONDS seconds for pod $1 to start"

echo "Waiting up to $MAX_WAIT_SECONDS seconds for pod $POD_NAME to start"
count=0
while [ $count -lt $MAX_WAIT_SECONDS ]
do
Expand All @@ -13,4 +15,9 @@ do
fi
sleep 1
done

echo "error: pod matching '$POD_NAME' failed to start within $MAX_WAIT_SECONDS seconds"
echo "-- pod info:"
kubectl get pod -A
echo "--"
exit 1

0 comments on commit 8092842

Please sign in to comment.