rpi.carlosedp.cluster-monit.../build_images.sh

305 lines
12 KiB
Bash
Raw Normal View History

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
2019-01-31 21:31:53 +01:00
AOR_VERSION=2.1
PROM_ADAPTER_VERSION=v0.4.1
2019-01-31 22:04:07 +01:00
KSM_VERSION=v1.5.0
PROM_OP_VERSION=v0.28.0
KUBE_RBAC_VERSION=v0.4.1
PROMCONFIGRELOADER_VERSION=v0.20.0
PROM_CONFIG_RELOADER_VERSION=v0.28.0
2019-01-31 21:31:53 +01:00
CONFIGMAP_RELOAD_VERSION=v0.2.2
#-------------------------------------------------------------------------------
2018-06-18 23:53:48 +02:00
# Kubernetes addon-resizer
# Retag Addon-resizer google images to have unified manifest on DockerHub
2019-01-31 21:31:53 +01:00
docker pull gcr.io/google-containers/addon-resizer-arm:$AOR_VERSION
docker pull gcr.io/google-containers/addon-resizer-arm64:$AOR_VERSION
docker pull gcr.io/google-containers/addon-resizer-amd64:$AOR_VERSION
2019-01-31 21:31:53 +01:00
docker tag gcr.io/google-containers/addon-resizer-arm:$AOR_VERSION $REPO/addon-resizer:$AOR_VERSION-arm
docker tag gcr.io/google-containers/addon-resizer-arm64:$AOR_VERSION $REPO/addon-resizer:$AOR_VERSION-arm64
docker tag gcr.io/google-containers/addon-resizer-amd64:$AOR_VERSION $REPO/addon-resizer:$AOR_VERSION-amd64
2018-06-11 17:31:49 +02:00
2019-01-31 21:31:53 +01:00
docker push $REPO/addon-resizer:$AOR_VERSION-arm
docker push $REPO/addon-resizer:$AOR_VERSION-arm64
docker push $REPO/addon-resizer:$AOR_VERSION-amd64
2018-06-11 17:31:49 +02:00
2019-01-31 21:45:20 +01:00
docker rmi gcr.io/google-containers/addon-resizer-arm:$AOR_VERSION
docker rmi gcr.io/google-containers/addon-resizer-arm64:$AOR_VERSION
docker rmi gcr.io/google-containers/addon-resizer-amd64:$AOR_VERSION
docker rmi $REPO/addon-resizer:$AOR_VERSION-arm
docker rmi $REPO/addon-resizer:$AOR_VERSION-arm64
docker rmi $REPO/addon-resizer:$AOR_VERSION-amd64
2019-01-31 22:04:07 +01:00
IMAGE=$REPO/addon-resizer
VERSION=$AOR_VERSION
ALL_ARCH='amd64 arm arm64'
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION
2019-01-31 21:31:53 +01:00
#-------------------------------------------------------------------------------
# Prometheus-adapter
# Retag prometheus-adapter from directxman12 images to have unified manifest on DockerHub
docker pull directxman12/k8s-prometheus-adapter-arm:$PROM_ADAPTER_VERSION
docker pull directxman12/k8s-prometheus-adapter-arm64:$PROM_ADAPTER_VERSION
docker pull directxman12/k8s-prometheus-adapter-amd64:$PROM_ADAPTER_VERSION
docker tag directxman12/k8s-prometheus-adapter-arm:$PROM_ADAPTER_VERSION $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-arm
docker tag directxman12/k8s-prometheus-adapter-arm64:$PROM_ADAPTER_VERSION $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-arm64
docker tag directxman12/k8s-prometheus-adapter-amd64:$PROM_ADAPTER_VERSION $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-amd64
docker push $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-arm
docker push $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-arm64
docker push $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-amd64
2019-01-31 21:45:20 +01:00
docker rmi directxman12/k8s-prometheus-adapter-arm:$PROM_ADAPTER_VERSION
docker rmi directxman12/k8s-prometheus-adapter-arm64:$PROM_ADAPTER_VERSION
docker rmi directxman12/k8s-prometheus-adapter-amd64:$PROM_ADAPTER_VERSION
docker rmi $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-arm
docker rmi $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-arm64
docker rmi $REPO/k8s-prometheus-adapter:$PROM_ADAPTER_VERSION-amd64
2019-01-31 21:31:53 +01:00
IMAGE=$REPO/k8s-prometheus-adapter
VERSION=$PROM_ADAPTER_VERSION
ALL_ARCH='amd64 arm arm64'
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION
#-------------------------------------------------------------------------------
2018-06-11 17:31:49 +02:00
# Kube-state-metrics
IMAGE=carlosedp/kube-state-metrics
ALL_ARCH='amd64 arm arm64'
2019-01-31 21:31:53 +01:00
VERSION=$KSM_VERSION
2018-06-11 17:31:49 +02:00
go get github.com/kubernetes/kube-state-metrics
#mv $HOME/go/src/github.com/kubernetes/kube-state-metrics $HOME/go/src/k8s.io/kube-state-metrics
2019-01-31 21:45:20 +01:00
pushd $GOPATH/src/k8s.io/kube-state-metrics
2019-01-31 22:04:07 +01:00
git pull
2018-06-11 17:31:49 +02:00
git checkout ${KSM_VERSION}
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM arm32v6\/alpine:3.7/' > Dockerfile.arm
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM arm64v8\/alpine:3.7/' > Dockerfile.arm64
2019-01-31 21:45:20 +01:00
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM amd64\/alpine:3.7/' > Dockerfile.amd64
2018-06-11 17:31:49 +02:00
GOOS=linux GOARCH=arm go build .
docker build -t $REPO/kube-state-metrics:${KSM_VERSION}-arm -f Dockerfile.arm .
2018-06-11 17:31:49 +02:00
GOOS=linux GOARCH=arm64 go build .
docker build -t $REPO/kube-state-metrics:${KSM_VERSION}-arm64 -f Dockerfile.arm64 .
GOOS=linux GOARCH=amd64 go build .
2019-01-31 21:45:20 +01:00
docker build -t $REPO/kube-state-metrics:${KSM_VERSION}-amd64 -f Dockerfile.amd64 .
2018-06-11 17:31:49 +02:00
docker push $REPO/kube-state-metrics:$KSM_VERSION-arm
docker push $REPO/kube-state-metrics:$KSM_VERSION-arm64
docker push $REPO/kube-state-metrics:$KSM_VERSION-amd64
2018-06-11 17:31:49 +02:00
2019-01-31 21:45:20 +01:00
docker rmi $REPO/kube-state-metrics:$KSM_VERSION-arm
docker rmi $REPO/kube-state-metrics:$KSM_VERSION-arm64
docker rmi $REPO/kube-state-metrics:$KSM_VERSION-amd64
2019-01-31 21:31:53 +01:00
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION
2018-06-11 17:31:49 +02:00
2019-01-31 21:45:20 +01:00
popd
#-------------------------------------------------------------------------------
2018-06-11 17:31:49 +02:00
# Prometheus-operator
IMAGE=carlosedp/prometheus-operator
ALL_ARCH='amd64 arm arm64'
2019-01-31 21:31:53 +01:00
VERSION=$PROM_OP_VERSION
2018-06-11 17:31:49 +02:00
go get github.com/coreos/prometheus-operator
cd $HOME/go/src/github.com/coreos/prometheus-operator
2019-01-31 22:04:07 +01:00
git pull
2018-06-11 17:31:49 +02:00
git checkout ${VERSION}
go get -u github.com/prometheus/promu
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM arm32v6\/busybox/' > Dockerfile.arm
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM arm64v8\/busybox/' > Dockerfile.arm64
2018-06-11 17:31:49 +02:00
2019-01-31 21:45:20 +01:00
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM amd64\/busybox/' > Dockerfile.amd64
2018-06-11 17:31:49 +02:00
GOOS=linux GOARCH=arm $GOPATH/bin/promu build --prefix `pwd`
docker build -t $REPO/prometheus-operator:${VERSION}-arm -f Dockerfile.arm .
GOOS=linux GOARCH=arm64 $GOPATH/bin/promu build --prefix `pwd`
docker build -t $REPO/prometheus-operator:${VERSION}-arm64 -f Dockerfile.arm64 .
2018-06-11 17:31:49 +02:00
2019-01-31 21:45:20 +01:00
GOOS=linux GOARCH=amd64 $GOPATH/bin/promu build --prefix `pwd`
docker build -t $REPO/prometheus-operator:${VERSION}-amd64 -f Dockerfile.amd64 .
2018-06-11 17:31:49 +02:00
docker push $REPO/prometheus-operator:$VERSION-arm
docker push $REPO/prometheus-operator:$VERSION-arm64
2019-01-31 21:45:20 +01:00
docker push $REPO/prometheus-operator:$VERSION-amd64
2018-06-11 17:31:49 +02:00
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION
2018-06-11 17:31:49 +02:00
rm Dockerfile.arm
rm Dockerfile.arm64
#-------------------------------------------------------------------------------
# kube-rbac-proxy
IMAGE=carlosedp/kube-rbac-proxy
2019-01-31 21:31:53 +01:00
VERSION=$KUBE_RBAC_VERSION
ALL_ARCH='amd64 arm arm64'
go get github.com/brancz/kube-rbac-proxy
cd $HOME/go/src/github.com/brancz/kube-rbac-proxy
2019-01-31 22:04:07 +01:00
git pull
git checkout ${VERSION}
cat > Dockerfile.arm <<EOF
FROM arm32v6/alpine:3.8
COPY qemu-arm-static /usr/bin/qemu-arm-static
RUN apk add -U --no-cache ca-certificates && rm -rf /var/cache/apk/*
COPY kube-rbac-proxy .
RUN rm /usr/bin/qemu-arm-static
ENTRYPOINT ["./kube-rbac-proxy"]
EXPOSE 8080
EOF
cat > Dockerfile.arm64 <<EOF
FROM arm64v8/alpine:3.8
COPY qemu-aarch64-static /usr/bin/qemu-aarch64-static
RUN apk add -U --no-cache ca-certificates && rm -rf /var/cache/apk/*
COPY kube-rbac-proxy .
ENTRYPOINT ["./kube-rbac-proxy"]
EXPOSE 8080
EOF
cat > Dockerfile.amd64 <<EOF
FROM alpine:3.8
RUN apk add -U --no-cache ca-certificates && rm -rf /var/cache/apk/*
COPY kube-rbac-proxy .
ENTRYPOINT ["./kube-rbac-proxy"]
EXPOSE 8080
EOF
docker run --rm --privileged multiarch/qemu-user-static:register --reset
wget https://github.com/multiarch/qemu-user-static/releases/download/v3.0.0/qemu-arm-static
chmod +x qemu-arm-static
GOOS=linux GOARCH=arm go build .
docker build -t $IMAGE:$VERSION-arm -f Dockerfile.arm .
wget https://github.com/multiarch/qemu-user-static/releases/download/v3.0.0/qemu-aarch64-static
chmod +x qemu-aarch64-static
GOOS=linux GOARCH=arm64 go build .
docker build -t $IMAGE:$VERSION-arm64 -f Dockerfile.arm64 .
GOOS=linux GOARCH=amd64 go build .
docker build -t $IMAGE:$VERSION-amd64 -f Dockerfile.amd64 .
docker push $IMAGE:$VERSION-arm
docker push $IMAGE:$VERSION-arm64
docker push $IMAGE:$VERSION-amd64
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION
2018-06-11 17:31:49 +02:00
#-------------------------------------------------------------------------------
2018-06-11 17:31:49 +02:00
# prometheus-config-reloader
IMAGE=carlosedp/prometheus-config-reloader
2019-01-31 21:31:53 +01:00
VERSION=$PROM_CONFIG_RELOADER_VERSION
ALL_ARCH='amd64 arm arm64'
2018-06-11 17:31:49 +02:00
go get github.com/coreos/prometheus-operator
cd $HOME/go/src/github.com/coreos/prometheus-operator/cmd/prometheus-config-reloader
2019-01-31 22:04:07 +01:00
git pull
git checkout ${VERSION}
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM arm32v6\/busybox/' > Dockerfile.arm
2018-05-29 19:33:05 +02:00
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM arm64v8\/busybox/' > Dockerfile.arm64
2018-05-29 19:33:05 +02:00
2019-01-31 21:45:20 +01:00
cat Dockerfile |sed -e 's/\.build\/linux-amd64\/operator/operator/' |sed -e 's/^FROM.*/FROM amd64\/busybox/' > Dockerfile.amd64
2018-06-11 17:31:49 +02:00
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -o prometheus-config-reloader main.go
docker build -t $IMAGE:$VERSION-arm -f Dockerfile.arm .
2018-05-29 19:33:05 +02:00
2018-06-11 17:31:49 +02:00
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o prometheus-config-reloader main.go
docker build -t $IMAGE:$VERSION-arm64 -f Dockerfile.arm64 .
2018-05-29 19:33:05 +02:00
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o prometheus-config-reloader main.go
2019-01-31 21:45:20 +01:00
docker build -t $IMAGE:$VERSION-amd64 -f Dockerfile.amd64 .
2018-05-29 19:33:05 +02:00
docker push $IMAGE:$VERSION-arm
docker push $IMAGE:$VERSION-arm64
docker push $IMAGE:$VERSION-amd64
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION
2018-05-29 19:33:05 +02:00
2018-06-11 17:31:49 +02:00
rm Dockerfile.arm
rm Dockerfile.arm64
#-------------------------------------------------------------------------------
# configmap-reload
IMAGE=carlosedp/configmap-reload
2019-01-31 21:31:53 +01:00
VERSION=$CONFIGMAP_RELOAD_VERSION
ALL_ARCH='amd64 arm arm64'
go get github.com/openshift/configmap-reload
cd $HOME/go/src/github.com/openshift/configmap-reload
2019-01-31 22:04:07 +01:00
git pull
git checkout ${VERSION}
cat > Dockerfile.arm <<EOF
FROM arm32v6/busybox
COPY configmap-reload /configmap-reload
ENTRYPOINT ["/configmap-reload"]
EOF
cat > Dockerfile.arm64 <<EOF
FROM arm64v8/busybox
COPY configmap-reload /configmap-reload
ENTRYPOINT ["/configmap-reload"]
EOF
cat > Dockerfile.amd64 <<EOF
FROM busybox
COPY configmap-reload /configmap-reload
ENTRYPOINT ["/configmap-reload"]
EOF
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build .
docker build -t $IMAGE:$VERSION-arm -f Dockerfile.arm .
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build .
docker build -t $IMAGE:$VERSION-arm64 -f Dockerfile.arm64 .
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build .
docker build -t $IMAGE:$VERSION-amd64 -f Dockerfile.amd64 .
docker push $IMAGE:$VERSION-arm
docker push $IMAGE:$VERSION-arm64
docker push $IMAGE:$VERSION-amd64
docker manifest create --amend $IMAGE:$VERSION `echo $ALL_ARCH | sed -e "s~[^ ]*~$IMAGE:$VERSION\-&~g"`
for arch in $ALL_ARCH; do docker manifest annotate --arch $arch $IMAGE:$VERSION $IMAGE:$VERSION-$arch; done
docker manifest push $IMAGE:$VERSION