Skip to content

Commit

Permalink
chore(deps): bump Envoy from 1.22.2 to 1.22.7 (backport #5982) (#5986)
Browse files Browse the repository at this point in the history
chore(deps): bump Envoy from 1.22.2 to 1.22.7

Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
Co-authored-by: Charly Molter <charly.molter@konghq.com>
  • Loading branch information
2 people authored and jakubdyszkiewicz committed Feb 10, 2023
1 parent bc91cd5 commit 4c1ed8f
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 104 deletions.
13 changes: 6 additions & 7 deletions mk/build.mk
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
BUILD_INFO_GIT_TAG ?= $(shell git describe --tags 2>/dev/null || echo unknown)
BUILD_INFO_GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
BUILD_INFO_BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" || echo unknown)
BUILD_INFO_VERSION ?= $(shell $(TOOLS_DIR)/releases/version.sh)
build_info := $(shell $(TOOLS_DIR)/releases/version.sh)
BUILD_INFO_VERSION ?= $(word 1, $(build_info))

build_info_fields := \
version=$(BUILD_INFO_VERSION) \
gitTag=$(BUILD_INFO_GIT_TAG) \
gitCommit=$(BUILD_INFO_GIT_COMMIT) \
buildDate=$(BUILD_INFO_BUILD_DATE)
gitTag=$(word 2, $(build_info)) \
gitCommit=$(word 3, $(build_info)) \
buildDate=$(word 4, $(build_info)) \
Envoy=$(word 5, $(build_info))
build_info_ld_flags := $(foreach entry,$(build_info_fields), -X github.com/kumahq/kuma/pkg/version.$(entry))

LD_FLAGS := -ldflags="-s -w $(build_info_ld_flags) $(EXTRA_LD_FLAGS)"
Expand Down
5 changes: 4 additions & 1 deletion mk/envoy.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
KUMA_DIR ?= .

BUILD_ENVOY_FROM_SOURCES ?= false
ENVOY_TAG ?= v1.22.7
ENVOY_ARTIFACT_EXT ?=

ENVOY_TAG ?= v1.21.3 # commit hash or git tag
# Remember to update pkg/version/compatibility.go
Expand Down Expand Up @@ -45,8 +47,9 @@ ifeq ($(BUILD_ENVOY_FROM_SOURCES),true)
BAZEL_BUILD_EXTRA_OPTIONS=${BAZEL_BUILD_EXTRA_OPTIONS} \
BINARY_PATH=$@ ${KUMA_DIR}/tools/envoy/build_${ENVOY_DISTRO}.sh
else
ENVOY_VERSION=${ENVOY_VERSION} \
ENVOY_TAG=$(ENVOY_TAG) \
ENVOY_DISTRO=${ENVOY_DISTRO} \
ENVOY_ARTIFACT_EXT=${ENVOY_ARTIFACT_EXT} \
BINARY_PATH=$@ ${KUMA_DIR}/tools/envoy/fetch.sh
endif

Expand Down
20 changes: 14 additions & 6 deletions tools/envoy/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#
# Requires:
# - $BINARY_PATH, path where binary will be fetched, for example 'out/envoy'
# - $ENVOY_VERSION, version of the envoy binary to fetch
# - $ENVOY_TAG, tag of the envoy binary to fetch
# - $ENVOY_DISTRO, name of the distributive (i.e darwin, alpine)
# - $ENVOY_ARTIFACT_EXT, optional artifact suffix (i.e. -extended)

set -o errexit
set -o pipefail
Expand All @@ -15,26 +16,33 @@ source "$(dirname -- "${BASH_SOURCE[0]}")/../common.sh"

function download_envoy() {
local binary_name=$1
local bin_dir
bin_dir=$(dirname "${BINARY_PATH}")
echo "Downloading ${binary_name}"

if [ ! -d "$(dirname "${BINARY_PATH}")" ]; then
mkdir -p "$(dirname "${BINARY_PATH}")"
fi

local tar_path="${BINARY_PATH}.tar.gz"

local status
status=$(curl -# --location --output "${BINARY_PATH}" --write-out '%{http_code}' \
"https://download.konghq.com/mesh-alpine/${binary_name}")
status=$(curl -# --location --output "${tar_path}" --write-out '%{http_code}' \
"https://github.com/kumahq/envoy-builds/releases/download/${ENVOY_TAG}/${binary_name}.tar.gz")

if [ "$status" -ne "200" ]; then
rm "${BINARY_PATH}"
msg_err "Error: failed downloading Envoy: ${status} error"
fi

tar -C "$bin_dir" -xzvf "${tar_path}"
rm "$tar_path"
mv "${bin_dir}/envoy-${ENVOY_DISTRO}" "${BINARY_PATH}"

[ -f "${BINARY_PATH}" ] && chmod +x "${BINARY_PATH}"
}

if [[ -n "${ENVOY_VERSION}" ]]; then
BINARY_NAME="envoy-${ENVOY_VERSION}-${ENVOY_DISTRO}-${GOARCH}"
if [[ -n "${ENVOY_TAG}" ]]; then
BINARY_NAME="envoy-${GOOS}-${GOARCH}-${ENVOY_TAG}-${ENVOY_DISTRO}-opt${ENVOY_ARTIFACT_EXT}"
download_envoy "${BINARY_NAME}"
exit 0
fi
10 changes: 8 additions & 2 deletions tools/envoy/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ set -o nounset
# - if ENVOY_TAG is a real git tag like 'v1.20.0' then the version is equal to '1.20.0' (without the first letter 'v').
# - if ENVOY_TAG is a commit hash then the version will look like '1.20.1-dev-b16d390f'

ENVOY_TAG=$1
ENVOY_VERSION=$(curl --silent --location --fail "https://raw.githubusercontent.com/envoyproxy/envoy/${ENVOY_TAG}/VERSION")
ENVOY_TAG=${ENVOY_TAG:-"v1.22.7"}
ENVOY_VERSION=$(curl --silent --location "https://raw.githubusercontent.com/envoyproxy/envoy/${ENVOY_TAG}/VERSION.txt")

# for envoy versions older than v1.22.0 file 'VERSION.txt' used to be called 'VERSION'
if [[ "${ENVOY_VERSION}" == "404: Not Found" ]]; then
ENVOY_VERSION=$(curl --silent --location --fail "https://raw.githubusercontent.com/envoyproxy/envoy/${ENVOY_TAG}/VERSION")
fi

if [[ "${ENVOY_TAG}" =~ ^v[0-9]*\.[0-9]*\.[0-9]*$ ]]; then
echo "${ENVOY_VERSION}"
else
Expand Down
203 changes: 141 additions & 62 deletions tools/releases/distros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,188 @@ set -e
SCRIPT_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
source "${SCRIPT_DIR}/../common.sh"

GOARCH=(amd64)

# first component is the distribution name, second is the system - must map to
# valid $GOOS values
DISTRIBUTIONS=(debian:linux:alpine ubuntu:linux:alpine rhel:linux:centos centos:linux:centos darwin:darwin:darwin)
# first component is the system - must map to valid $GOOS values
# if present, second is the distribution and third is the envoy distribution
# without a distribution we package only kumactl as a static binary
DISTRIBUTIONS=(
linux:debian:alpine:amd64
linux:ubuntu:alpine:amd64
linux:rhel:centos:amd64
linux:centos:centos:amd64
darwin:darwin:darwin:amd64
linux:::amd64
linux:debian:alpine:arm64
linux:ubuntu:alpine:arm64
darwin:darwin:darwin:arm64
linux:::arm64
)

PULP_HOST="https://api.pulp.konnect-prod.konghq.com"
PULP_PACKAGE_TYPE="mesh"
PULP_DIST_NAME="alpine"
[ -z "$RELEASE_NAME" ] && RELEASE_NAME="kuma"
ENVOY_VERSION=1.21.3
BUILD_INFO=$("${SCRIPT_DIR}/../releases/version.sh")
ENVOY_VERSION=$(echo "$BUILD_INFO" | cut -d " " -f 5)
KUMA_VERSION=$(echo "$BUILD_INFO" | cut -d " " -f 1)
[ -z "$KUMA_CONFIG_PATH" ] && KUMA_CONFIG_PATH=pkg/config/app/kuma-cp/kuma-cp.defaults.yaml
CTL_NAME="kumactl"
[ -z "$EBPF_PROGRAMS_IMAGE" ] && EBPF_PROGRAMS_IMAGE="kumahq/kuma-net-ebpf:0.8.6"

function get_ebpf_programs() {
local arch=$1
local system=$2
local kuma_dir=$3
local container

if [[ "$system" != "linux" ]]; then
return
fi

if [[ "$arch" != "amd64" ]] && [[ "$arch" != "arm64" ]]; then
return
fi

container=$(DOCKER_DEFAULT_PLATFORM=$system/$arch docker create "$EBPF_PROGRAMS_IMAGE" copy)
docker cp "$container:/ebpf" "$kuma_dir"
docker rm -v "$container"
}

# create_kumactl_tarball packages only kumactl
function create_kumactl_tarball() {
local arch=$1
local system=$2

msg ">>> Packaging ${RELEASE_NAME} static kumactl binary for $system-$arch..."
msg

function get_envoy() {
local distro=$1
local envoy_distro=$2
local arch=$3
make GOOS="$system" GOARCH="$arch" build/kumactl

local status
status=$(curl -L -o build/envoy-"$distro" \
--write-out '%{http_code}' --silent --output /dev/null \
"https://download.konghq.com/mesh-alpine/envoy-$ENVOY_VERSION-$envoy_distro-$arch")
local dest_dir=build/$RELEASE_NAME-$arch
local kuma_subdir="$RELEASE_NAME-$KUMA_VERSION"
local kuma_dir=$dest_dir/$kuma_subdir

if [ "$status" -ne "200" ]; then msg_err "Error: failed downloading Envoy"; fi
rm -rf "$dest_dir"
mkdir "$dest_dir"
mkdir "$kuma_dir"
mkdir "$kuma_dir/bin"

artifact_dir=$(artifact_dir "$arch" "$system")
cp -p "$artifact_dir/kumactl/kumactl" "$kuma_dir/bin"

cp tools/releases/templates/LICENSE "$kuma_dir"
cp tools/releases/templates/NOTICE-kumactl "$kuma_dir"

archive_path=$(archive_path "$arch" "$system")

tar -czf "${archive_path}" -C "$dest_dir" "$kuma_subdir"
}

function create_tarball() {
local system=$1
local arch=$2
local arch=$1
local system=$2
local distro=$3
local envoy_distro=$4

msg ">>> Packaging ${RELEASE_NAME} for $distro ($system-$arch)..."
msg

make GOOS="$system" GOARCH="$arch" ENVOY_DISTRO="$envoy_distro" build

local dest_dir=build/$RELEASE_NAME-$distro-$arch
local kuma_dir=$dest_dir/$RELEASE_NAME-$KUMA_VERSION
local kuma_subdir="$RELEASE_NAME-$KUMA_VERSION"
local kuma_dir=$dest_dir/$kuma_subdir

rm -rf "$dest_dir"
mkdir "$dest_dir"
mkdir "$kuma_dir"
mkdir "$kuma_dir/bin"
mkdir "$kuma_dir/conf"

get_envoy "$distro" "$envoy_distro" "$arch"
chmod 755 build/envoy-"$distro"
get_ebpf_programs "$arch" "$system" "$kuma_dir"

cp -p "build/envoy-$distro" "$kuma_dir"/bin/envoy
cp -p "build/artifacts-$system-$arch/kuma-cp/kuma-cp" "$kuma_dir/bin"
cp -p "build/artifacts-$system-$arch/kuma-dp/kuma-dp" "$kuma_dir/bin"
cp -p "build/artifacts-$system-$arch/kumactl/kumactl" "$kuma_dir/bin"
cp -p "build/artifacts-$system-$arch/coredns/coredns" "$kuma_dir/bin"
cp -p "build/artifacts-$system-$arch/kuma-prometheus-sd/kuma-prometheus-sd" "$kuma_dir/bin"
artifact_dir=$(artifact_dir "$arch" "$system")
cp -p "$artifact_dir/envoy/envoy-$ENVOY_VERSION-$envoy_distro" "$kuma_dir/bin"
cp -p "$artifact_dir/kuma-cp/kuma-cp" "$kuma_dir/bin"
cp -p "$artifact_dir/kuma-dp/kuma-dp" "$kuma_dir/bin"
cp -p "$artifact_dir/kumactl/kumactl" "$kuma_dir/bin"
cp -p "$artifact_dir/coredns/coredns" "$kuma_dir/bin"
cp -p "$artifact_dir/kuma-prometheus-sd/kuma-prometheus-sd" "$kuma_dir/bin"
cp -p "$KUMA_CONFIG_PATH" "$kuma_dir/conf/kuma-cp.conf.yml"

cp tools/releases/templates/* "$kuma_dir"

tar -czf "build/artifacts-$system-$arch/$RELEASE_NAME-$KUMA_VERSION-$distro-$arch.tar.gz" -C "$dest_dir" .
archive_path=$(archive_path "$arch" "$system" "$distro")

tar -czf "${archive_path}" -C "$dest_dir" "$kuma_subdir"
}

function package() {
for os in "${DISTRIBUTIONS[@]}"; do
local distro
distro=$(echo "$os" | awk '{split($0,parts,":"); print parts[1]}')
local system
system=$(echo "$os" | awk '{split($0,parts,":"); print parts[2]}')
system=$(echo "$os" | awk '{split($0,parts,":"); print parts[1]}')
local distro
distro=$(echo "$os" | awk '{split($0,parts,":"); print parts[2]}')
local envoy_distro
envoy_distro=$(echo "$os" | awk '{split($0,parts,":"); print parts[3]}')
local arch
arch=$(echo "$os" | awk '{split($0,parts,":"); print parts[4]}')

if [[ -n $distro ]]; then
create_tarball "$arch" "$system" "$distro" "$envoy_distro"
else
create_kumactl_tarball "$arch" "$system"
fi

msg
msg_green "... success!"
msg
done
}

for arch in "${GOARCH[@]}"; do
function artifact_dir() {
local arch=$1
local system=$2

msg ">>> Packaging Kuma for $distro ($system-$arch)..."
msg
echo "build/artifacts-$system-$arch"
}

make GOOS="$system" GOARCH="$arch" build
create_tarball "$system" "$arch" "$distro" "$envoy_distro"
function archive_path() {
local arch=$1
local system=$2
local distro=$3

msg
msg_green "... success!"
msg
done
done
if [[ -n $distro ]]; then
echo "$(artifact_dir "$arch" "$system")/$RELEASE_NAME-$KUMA_VERSION-$distro-$arch.tar.gz"
else
echo "$(artifact_dir "$arch" "$system")/$RELEASE_NAME-$CTL_NAME-$KUMA_VERSION-$system-$arch.tar.gz"
fi
}

function release() {
for os in "${DISTRIBUTIONS[@]}"; do
local distro
distro=$(echo "$os" | awk '{split($0,parts,":"); print parts[1]}')
local system
system=$(echo "$os" | awk '{split($0,parts,":"); print parts[2]}')

for arch in "${GOARCH[@]}"; do
local artifact
artifact="build/artifacts-$system-$arch/$RELEASE_NAME-$KUMA_VERSION-$distro-$arch.tar.gz"
[ ! -f "$artifact" ] && msg_yellow "Package '$artifact' not found, skipping..." && continue

msg_green "Releasing Kuma for '$os', '$arch', '$KUMA_VERSION'..."

docker run --rm \
-e PULP_USERNAME="${PULP_USERNAME}" -e PULP_PASSWORD="${PULP_PASSWORD}" \
-e PULP_HOST=${PULP_HOST} \
-v "${PWD}":/files:ro -it kong/release-script \
--file /files/"$artifact" \
--package-type ${PULP_PACKAGE_TYPE} --dist-name ${PULP_DIST_NAME} --publish
done
system=$(echo "$os" | awk '{split($0,parts,":"); print parts[1]}')
local distro
distro=$(echo "$os" | awk '{split($0,parts,":"); print parts[2]}')
local arch
arch=$(echo "$os" | awk '{split($0,parts,":"); print parts[4]}')

local artifact
artifact="$(archive_path "$arch" "$system" "$distro")"
[ ! -f "$artifact" ] && msg_yellow "Package '$artifact' not found, skipping..." && continue

if [[ -n $distro ]]; then
msg_green ">>> Releasing ${RELEASE_NAME} $KUMA_VERSION for $distro ($system-$arch)..."
else
msg_green ">>> Releasing ${RELEASE_NAME} $KUMA_VERSION static kumactl binary for $system-$arch..."
fi

docker run --rm \
-e PULP_USERNAME="${PULP_USERNAME}" -e PULP_PASSWORD="${PULP_PASSWORD}" \
-e PULP_HOST=${PULP_HOST} \
-v "${PWD}":/files:ro -it kong/release-script \
--file /files/"$artifact" \
--package-type ${PULP_PACKAGE_TYPE} --dist-name ${PULP_DIST_NAME} --publish
done
}

Expand All @@ -116,7 +196,6 @@ function usage() {
}

function main() {
KUMA_VERSION=$("${SCRIPT_DIR}/version.sh")

while [[ $# -gt 0 ]]; do
flag=$1
Expand All @@ -138,14 +217,14 @@ function main() {
shift
done

[ -z "$PULP_USERNAME" ] && msg_err "PULP_USERNAME required"
[ -z "$PULP_PASSWORD" ] && msg_err "PULP_PASSWORD required"

case $op in
package)
package
;;
release)
[ -z "$PULP_USERNAME" ] && msg_err "PULP_USERNAME required"
[ -z "$PULP_PASSWORD" ] && msg_err "PULP_PASSWORD required"

release
;;
esac
Expand Down
Loading

0 comments on commit 4c1ed8f

Please sign in to comment.