-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #906 from kubernetes-sigs/tools-releases
✨ Build and publish Kubernetes envtest tools as packages
- Loading branch information
Showing
6 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Package controller-runtime envtest | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'hack/envtest/_matrix/*.yaml' | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
os: | ||
- linux | ||
- darwin | ||
arch: | ||
- amd64 | ||
- arm64 | ||
include: | ||
- arch: ppc64le | ||
os: linux | ||
- arch: s390x | ||
os: linux | ||
- arch: amd64 | ||
os: windows | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v4.1.2 | ||
- name: Get changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@2d756ea4c53f7f6b397767d8723b3a10a9f35bf2 # tag=v44.0.0 | ||
with: | ||
files: | | ||
hack/envtest/_matrix/*.yaml | ||
- name: Setup package release version | ||
id: release-version | ||
run: | | ||
if [[ ${{ steps.changed-files.outputs.all_changed_files_count }} != 1 ]]; then | ||
echo "One Kubernetes patch version files should be changed to create a package, found ${{ steps.changed-files.outputs.all_changed_files_count }}" | ||
exit 1 | ||
fi | ||
for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
export KUBERNETES_VERSION=$(echo "${changed_file}" | grep -oP '(?<=/)[^/]+(?=\.yaml)') | ||
echo "KUBERNETES_VERSION=$KUBERNETES_VERSION" >> $GITHUB_ENV | ||
GO_VERSION=$(yq eval '.go' $changed_file) | ||
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV | ||
ETCD_VERSION=$(yq eval '.etcd' $changed_file) | ||
echo "ETCD_VERSION=$ETCD_VERSION" >> $GITHUB_ENV | ||
done | ||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # tag=v3.2.0 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # tag=v3.1.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push Docker images | ||
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # tag=v5.3.0 | ||
with: | ||
context: . | ||
file: ./hack/envtest/${{matrix.os}}/Dockerfile | ||
build-args: | | ||
GO_VERSION=${{env.GO_VERSION}} | ||
KUBERNETES_VERSION=${{env.KUBERNETES_VERSION}} | ||
ETCD_VERSION=${{env.ETCD_VERSION}} | ||
OS=${{matrix.os}} | ||
ARCH=${{matrix.arch}} | ||
push: true | ||
tags: | | ||
ghcr.io/kubernetes-sigs/controller-tools/envtest:${{env.KUBERNETES_VERSION}}-${{matrix.os}}-${{matrix.arch}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go: 1.21 | ||
etcd: v3.5.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go: 1.21 | ||
etcd: v3.5.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# 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. | ||
|
||
ARG GO_VERSION | ||
FROM golang:${GO_VERSION} as builder | ||
|
||
# Version and platform args. | ||
ARG KUBERNETES_VERSION | ||
ARG ETCD_VERSION | ||
ARG OS=darwin | ||
ARG ARCH | ||
|
||
# Tools path. | ||
ENV DEST=/controller-tools/envtest | ||
|
||
# Install dependencies. | ||
RUN apt update && \ | ||
apt install unzip rsync -y && \ | ||
mkdir -p $DEST | ||
|
||
# kube-apiserver | ||
WORKDIR /kubernetes | ||
RUN git clone https://github.com/kubernetes/kubernetes . --depth=1 -b ${KUBERNETES_VERSION} | ||
ENV CGO_ENABLED=0 | ||
ENV KUBE_BUILD_PLATFORMS=${OS}/${ARCH} | ||
RUN make WHAT=cmd/kube-apiserver && \ | ||
cp _output/local/bin/${KUBE_BUILD_PLATFORMS}/kube-apiserver $DEST | ||
|
||
# kubectl | ||
RUN /bin/bash -x -c ' \ | ||
{ curl -sfLO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kubectl && \ | ||
chmod +x kubectl && \ | ||
cp kubectl $DEST; } || \ | ||
{ make WHAT=cmd/kubectl && \ | ||
cp _output/local/bin/${KUBE_BUILD_PLATFORMS}/kubectl $DEST; }' | ||
|
||
# etcd | ||
ENV ETCD_BASE_NAME=etcd-${ETCD_VERSION}-${OS}-${ARCH} | ||
RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD_BASE_NAME}.zip && \ | ||
unzip -o ${ETCD_BASE_NAME}.zip && \ | ||
cp ${ETCD_BASE_NAME}/etcd $DEST | ||
|
||
# Build the final image with the binaries. | ||
FROM scratch | ||
COPY --from=builder /controller-tools/envtest /controller-tools/envtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# 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. | ||
|
||
ARG GO_VERSION | ||
FROM golang:${GO_VERSION} as builder | ||
|
||
# Version and platform args. | ||
ARG KUBERNETES_VERSION | ||
ARG ETCD_VERSION | ||
ARG OS=linux | ||
ARG ARCH | ||
|
||
# Tools path. | ||
ENV DEST=/controller-tools/envtest | ||
|
||
# Install dependencies. | ||
RUN apt update && \ | ||
apt install unzip rsync -y && \ | ||
mkdir -p $DEST | ||
|
||
# kube-apiserver | ||
RUN curl -sfLO https://dl.k8s.io/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kube-apiserver && \ | ||
chmod +x kube-apiserver && \ | ||
cp kube-apiserver $DEST | ||
|
||
# kubectl | ||
RUN curl -sfLO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kubectl && \ | ||
chmod +x kubectl && \ | ||
cp kubectl $DEST | ||
|
||
# etcd | ||
ENV ETCD_BASE_NAME=etcd-${ETCD_VERSION}-${OS}-${ARCH} | ||
RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD_BASE_NAME}.tar.gz && \ | ||
tar xzf ${ETCD_BASE_NAME}.tar.gz && \ | ||
cp ${ETCD_BASE_NAME}/etcd $DEST | ||
|
||
# Build the final image with the binaries. | ||
FROM scratch | ||
COPY --from=builder /controller-tools/envtest /controller-tools/envtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# 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. | ||
|
||
ARG GO_VERSION | ||
FROM golang:${GO_VERSION} as builder | ||
|
||
# Version and platform args. | ||
ARG KUBERNETES_VERSION | ||
ARG ETCD_VERSION | ||
ARG OS=windows | ||
ARG ARCH | ||
|
||
# Tools path. | ||
ENV DEST=/controller-tools/envtest | ||
|
||
# Install dependencies. | ||
RUN apt update && \ | ||
apt install unzip rsync -y && \ | ||
mkdir -p $DEST | ||
|
||
# kube-apiserver | ||
WORKDIR /kubernetes | ||
RUN git clone https://github.com/kubernetes/kubernetes . --depth=1 -b ${KUBERNETES_VERSION} | ||
ENV CGO_ENABLED=0 | ||
ENV KUBE_BUILD_PLATFORMS=${OS}/${ARCH} | ||
RUN make WHAT=cmd/kube-apiserver && \ | ||
cp _output/local/bin/${KUBE_BUILD_PLATFORMS}/kube-apiserver.exe $DEST | ||
|
||
# kubectl | ||
RUN /bin/bash -x -c ' \ | ||
{ curl -sfLO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kubectl.exe && \ | ||
chmod +x kubectl.exe && \ | ||
cp kubectl.exe $DEST; } || \ | ||
{ make WHAT=cmd/kubectl && \ | ||
cp _output/local/bin/${KUBE_BUILD_PLATFORMS}/kubectl.exe $DEST; }' | ||
|
||
# etcd | ||
ENV ETCD_BASE_NAME=etcd-${ETCD_VERSION}-${OS}-${ARCH} | ||
RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD_BASE_NAME}.zip && \ | ||
unzip -o ${ETCD_BASE_NAME}.zip && \ | ||
cp ${ETCD_BASE_NAME}/etcd.exe $DEST | ||
|
||
# Build the final image with the binaries. | ||
FROM scratch | ||
COPY --from=builder /controller-tools/envtest /controller-tools/envtest |