2018-05-29 19:33:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-01-31 22:04:07 +01:00
|
|
|
# Build images for Prometheus Operator and dependencies
|
|
|
|
# Run on Linux AMD64 machine due to qemu image for rbac-proxy
|
|
|
|
|
2019-01-31 21:31:53 +01:00
|
|
|
export DOCKER_CLI_EXPERIMENTAL=enabled
|
|
|
|
|
2018-06-11 17:31:49 +02:00
|
|
|
REPO=carlosedp
|
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
export AOR_VERSION=2.3
|
2020-05-26 17:59:47 +02:00
|
|
|
export KSM_VERSION=v1.9.6
|
|
|
|
export PROM_OP_VERSION=v0.39.0
|
2020-03-18 20:58:42 +01:00
|
|
|
export KUBE_RBAC_VERSION=v0.5.0
|
2020-05-26 17:59:47 +02:00
|
|
|
export PROM_CONFIG_RELOADER_VERSION=v0.39.0
|
2020-03-18 20:58:42 +01:00
|
|
|
export CONFIGMAP_RELOAD_VERSION=latest
|
2018-12-12 18:18:00 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
2018-06-18 23:53:48 +02:00
|
|
|
# Kubernetes addon-resizer
|
|
|
|
# Retag Addon-resizer google images to have unified manifest on DockerHub
|
2020-03-18 20:58:42 +01:00
|
|
|
ALL_ARCH=(amd64 arm arm64 ppc64le)
|
|
|
|
IMAGE=addon-resizer
|
|
|
|
|
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
if [[ $arch == "arm" ]]; then archdocker="arm32v7";
|
|
|
|
elif [[ $arch == "arm64" ]]; then archdocker="arm64v8";
|
|
|
|
else archdocker="$arch"; fi
|
|
|
|
docker pull gcr.io/google-containers/$IMAGE-$arch:$AOR_VERSION
|
|
|
|
docker tag gcr.io/google-containers/$IMAGE-$arch:$AOR_VERSION $REPO/$IMAGE:$AOR_VERSION-$arch
|
|
|
|
docker push $REPO/$IMAGE:$AOR_VERSION-$arch
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
docker manifest create --amend $REPO/$IMAGE:$AOR_VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$REPO/$IMAGE:$AOR_VERSION\-&~g"`
|
|
|
|
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $REPO/$IMAGE:$AOR_VERSION $REPO/$IMAGE:$AOR_VERSION-$arch; done
|
|
|
|
docker manifest push --purge $REPO/$IMAGE:$AOR_VERSION
|
|
|
|
|
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
docker rmi gcr.io/google-containers/$IMAGE-$arch:$AOR_VERSION
|
|
|
|
docker rmi $REPO/$IMAGE:$AOR_VERSION-$arch
|
|
|
|
done
|
|
|
|
|
2018-12-12 18:18:00 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
2018-06-11 17:31:49 +02:00
|
|
|
# Kube-state-metrics
|
2018-12-12 18:18:00 +01:00
|
|
|
IMAGE=carlosedp/kube-state-metrics
|
2020-03-18 20:58:42 +01:00
|
|
|
ALL_ARCH=(amd64 arm arm64 ppc64le)
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2019-08-09 00:38:35 +02:00
|
|
|
rm -rf $GOPATH/src/k8s.io/kube-state-metrics
|
|
|
|
mkdir $GOPATH/src/k8s.io/
|
|
|
|
pushd $GOPATH/src/k8s.io/
|
2020-03-18 20:58:42 +01:00
|
|
|
git clone https://github.com/kubernetes/kube-state-metrics -b $KSM_VERSION --depth=1
|
2019-08-09 00:38:35 +02:00
|
|
|
cd kube-state-metrics
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
if [[ $arch == "arm" ]]; then archdocker="arm32v7";
|
|
|
|
elif [[ $arch == "arm64" ]]; then archdocker="arm64v8";
|
|
|
|
else archdocker="$arch"; fi
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -a -installsuffix cgo -ldflags '-s -w -extldflags "-static"' -o kube-state-metrics .
|
|
|
|
docker build -t $REPO/kube-state-metrics:${KSM_VERSION}-$arch .
|
|
|
|
docker push $REPO/kube-state-metrics:$KSM_VERSION-$arch
|
|
|
|
done
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
docker manifest create --amend $IMAGE:$KSM_VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$KSM_VERSION\-&~g"`
|
|
|
|
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$KSM_VERSION $IMAGE:$KSM_VERSION-$arch; done
|
|
|
|
docker manifest push --purge $IMAGE:$KSM_VERSION
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
docker rmi $REPO/kube-state-metrics:$KSM_VERSION-$arch
|
|
|
|
done
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2019-01-31 21:45:20 +01:00
|
|
|
popd
|
2018-12-12 18:18:00 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
2018-06-11 17:31:49 +02:00
|
|
|
# Prometheus-operator
|
2018-12-12 18:18:00 +01:00
|
|
|
IMAGE=carlosedp/prometheus-operator
|
2020-03-18 20:58:42 +01:00
|
|
|
ALL_ARCH=(amd64 arm arm64 ppc64le)
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2019-08-09 00:38:35 +02:00
|
|
|
rm -rf $GOPATH/src/github.com/coreos/prometheus-operator
|
2020-03-18 20:58:42 +01:00
|
|
|
mkdir -p $GOPATH/src/github.com/coreos/
|
2019-08-09 00:38:35 +02:00
|
|
|
pushd $GOPATH/src/github.com/coreos/
|
2020-03-18 20:58:42 +01:00
|
|
|
git clone https://github.com/coreos/prometheus-operator -b $PROM_OP_VERSION --depth=1
|
2019-08-09 00:38:35 +02:00
|
|
|
cd prometheus-operator
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
if [[ $arch == "arm" ]]; then archdocker="arm32v7";
|
|
|
|
elif [[ $arch == "arm64" ]]; then archdocker="arm64v8";
|
|
|
|
else archdocker="$arch"; fi
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e "s/^FROM.*/FROM $archdocker\/busybox/" > Dockerfile.custom
|
|
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=$arch go build -ldflags="-s -X github.com/coreos/prometheus-operator/pkg/version.Version=$(cat VERSION | tr -d " \t\n\r")" -o operator cmd/operator/main.go
|
|
|
|
docker build -t $REPO/prometheus-operator:${PROM_OP_VERSION}-$arch -f Dockerfile.custom .
|
2020-05-26 17:59:47 +02:00
|
|
|
docker push $REPO/prometheus-operator:$PROM_OP_VERSION-$arch
|
2020-03-18 20:58:42 +01:00
|
|
|
done
|
2019-01-31 21:45:20 +01:00
|
|
|
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
docker manifest create --amend $IMAGE:$PROM_OP_VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$PROM_OP_VERSION\-&~g"`
|
|
|
|
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$PROM_OP_VERSION $IMAGE:$PROM_OP_VERSION-$arch; done
|
|
|
|
docker manifest push --purge $IMAGE:$PROM_OP_VERSION
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2020-05-26 17:59:47 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
docker rmi $REPO/prometheus-operator:$PROM_OP_VERSION-$arch
|
|
|
|
done
|
2019-01-31 21:45:20 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
rm -rf Dockerfile.custom
|
2019-08-09 00:38:35 +02:00
|
|
|
popd
|
2018-12-12 18:18:00 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# kube-rbac-proxy
|
|
|
|
IMAGE=carlosedp/kube-rbac-proxy
|
2020-03-18 20:58:42 +01:00
|
|
|
ALL_ARCH=(amd64 arm arm64 ppc64le)
|
|
|
|
|
|
|
|
rm -rf $GOPATH/src/github.com/brancz/
|
|
|
|
mkdir -p $GOPATH/src/github.com/brancz/
|
|
|
|
pushd $GOPATH/src/github.com/brancz/
|
|
|
|
git clone https://github.com/brancz/kube-rbac-proxy -b $KUBE_RBAC_VERSION --depth=1
|
|
|
|
cd kube-rbac-proxy
|
|
|
|
|
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
if [[ $arch == "arm" ]]; then archdocker="arm32v7";
|
|
|
|
elif [[ $arch == "arm64" ]]; then archdocker="arm64v8";
|
|
|
|
else archdocker="$arch"; fi
|
|
|
|
cat > Dockerfile.custom <<EOF
|
|
|
|
FROM $archdocker/alpine:3.11
|
2018-12-12 18:18:00 +01:00
|
|
|
RUN apk add -U --no-cache ca-certificates && rm -rf /var/cache/apk/*
|
|
|
|
COPY kube-rbac-proxy .
|
|
|
|
ENTRYPOINT ["./kube-rbac-proxy"]
|
|
|
|
EXPOSE 8080
|
|
|
|
EOF
|
2020-03-18 20:58:42 +01:00
|
|
|
GOOS=linux GOARCH=$arch make build
|
|
|
|
rm -rf kube-rbac-proxy
|
|
|
|
mv _output/linux/$arch/kube-rbac-proxy ./kube-rbac-proxy
|
|
|
|
docker build -t $IMAGE:$KUBE_RBAC_VERSION-$arch -f Dockerfile.custom .
|
|
|
|
docker push $IMAGE:$KUBE_RBAC_VERSION-$arch
|
|
|
|
done
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
docker manifest create --amend $IMAGE:$KUBE_RBAC_VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$KUBE_RBAC_VERSION\-&~g"`
|
|
|
|
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$KUBE_RBAC_VERSION $IMAGE:$KUBE_RBAC_VERSION-$arch; done
|
|
|
|
docker manifest push --purge $IMAGE:$KUBE_RBAC_VERSION
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
docker rmi $IMAGE:$KUBE_RBAC_VERSION-$arch
|
|
|
|
done
|
2018-06-11 17:31:49 +02:00
|
|
|
|
2018-12-12 18:18:00 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
2018-06-11 17:31:49 +02:00
|
|
|
# prometheus-config-reloader
|
2018-12-12 18:18:00 +01:00
|
|
|
IMAGE=carlosedp/prometheus-config-reloader
|
2020-03-18 20:58:42 +01:00
|
|
|
ALL_ARCH=(amd64 arm arm64 ppc64le)
|
2019-08-09 00:38:35 +02:00
|
|
|
|
|
|
|
pushd $GOPATH/src/github.com/coreos/prometheus-operator
|
|
|
|
cd $GOPATH/src/github.com/coreos/prometheus-operator/cmd/prometheus-config-reloader
|
2020-05-26 17:59:47 +02:00
|
|
|
git checkout ${PROM_CONFIG_RELOADER_VERSION}
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
if [[ $arch == "arm" ]]; then archdocker="arm32v7";
|
|
|
|
elif [[ $arch == "arm64" ]]; then archdocker="arm64v8";
|
|
|
|
else archdocker="$arch"; fi
|
|
|
|
cat Dockerfile | sed -e "s/^FROM.*/FROM $archdocker\/busybox/" > Dockerfile.custom
|
|
|
|
GOOS=linux GOARCH=$arch CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-s -w -extldflags "-static"' -o prometheus-config-reloader main.go
|
|
|
|
docker build -t $IMAGE:$PROM_CONFIG_RELOADER_VERSION-$arch -f Dockerfile.custom .
|
|
|
|
docker push $IMAGE:$PROM_CONFIG_RELOADER_VERSION-$arch
|
|
|
|
done
|
2019-01-31 21:45:20 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
docker manifest create --amend $IMAGE:$PROM_CONFIG_RELOADER_VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$PROM_CONFIG_RELOADER_VERSION\-&~g"`
|
|
|
|
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$PROM_CONFIG_RELOADER_VERSION $IMAGE:$PROM_CONFIG_RELOADER_VERSION-$arch; done
|
|
|
|
docker manifest push --purge $IMAGE:$PROM_CONFIG_RELOADER_VERSION
|
2018-05-29 19:33:05 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
docker rmi $IMAGE:$PROM_CONFIG_RELOADER_VERSION-$arch
|
|
|
|
done
|
2018-05-29 19:33:05 +02:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
rm -rf Dockerfile.custom
|
2018-12-12 18:18:00 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# configmap-reload
|
|
|
|
IMAGE=carlosedp/configmap-reload
|
2020-03-18 20:58:42 +01:00
|
|
|
ALL_ARCH=(amd64 arm arm64 ppc64le)
|
|
|
|
|
|
|
|
rm -rf $GOPATH/src/github.com/openshift/configmap-reload
|
|
|
|
mkdir -p $GOPATH/src/github.com/openshift/
|
|
|
|
pushd $GOPATH/src/github.com/openshift/
|
|
|
|
git clone https://github.com/openshift/configmap-reload
|
|
|
|
cd configmap-reload
|
|
|
|
|
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
if [[ $arch == "arm" ]]; then archdocker="arm32v7";
|
|
|
|
elif [[ $arch == "arm64" ]]; then archdocker="arm64v8";
|
|
|
|
else archdocker="$arch"; fi
|
|
|
|
cat > Dockerfile.custom <<EOF
|
|
|
|
FROM $archdocker/busybox
|
|
|
|
COPY out/configmap-reload /usr/bin/configmap-reload
|
|
|
|
ENTRYPOINT ["/usr/bin/configmap-reload"]
|
2018-12-12 18:18:00 +01:00
|
|
|
EOF
|
2020-03-18 20:58:42 +01:00
|
|
|
GOOS=linux GOARCH=$arch make
|
|
|
|
docker build -t $IMAGE:$CONFIGMAP_RELOAD_VERSION-$arch -f Dockerfile.custom .
|
|
|
|
docker push $IMAGE:$CONFIGMAP_RELOAD_VERSION-$arch
|
|
|
|
done
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
docker manifest create --amend $IMAGE:$CONFIGMAP_RELOAD_VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$CONFIGMAP_RELOAD_VERSION\-&~g"`
|
|
|
|
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$CONFIGMAP_RELOAD_VERSION $IMAGE:$CONFIGMAP_RELOAD_VERSION-$arch; done
|
|
|
|
docker manifest push --purge $IMAGE:$CONFIGMAP_RELOAD_VERSION
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
for arch in $ALL_ARCH; do
|
|
|
|
docker rmi $IMAGE:$CONFIGMAP_RELOAD_VERSION-$arch
|
|
|
|
done
|
2018-12-12 18:18:00 +01:00
|
|
|
|
2020-03-18 20:58:42 +01:00
|
|
|
rm -rf Dockerfile.custom
|