Skip to content

kubernetes

kubernetes #124

Workflow file for this run

name: kubernetes
permissions:
contents: read
on:
push:
branches: [ k8s ]
workflow_dispatch:
inputs:
branch:
description: 'kubernetes branch'
required: true
default: 'v1.27.16'
arm:
description: 'build&push arm64 image'
required: false
default: 'on'
amd:
description: 'build&push amd64 image'
required: false
default: 'on'
env:
REPO: easystack/kubernetes
PROJECT: kubernetes
BRANCH: v1.27.16-es
Dockerfile: Dockerfile-k8s
REGISTRY_NAME: "${{ secrets.MY_HUB_NAME }}"
REGISTRY_USER: "${{ secrets.MY_HUB_USER }}"
REGISTRY_PASS: "${{ secrets.MY_HUB_PASSWORD }}"
jobs:
build:
name: Build
runs-on: ubuntu-20.04 # 兼容 centos 8
steps:
- name: Getting image tag
id: tag
run: |
echo "trigger by ${{ github.event_name }}"
echo "sha256 is ${{ github.sha }}"
echo "date=$(date +'%Y%m%d%H%M')" >> "$GITHUB_ENV"
if ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "vbranch=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "arm=${{ github.event.inputs.arm }}" >> $GITHUB_ENV
echo "amd=${{ github.event.inputs.amd }}" >> $GITHUB_ENV
else
echo "vbranch=${{ env.BRANCH }}" >> $GITHUB_ENV
echo "vbranch=${{ env.BRANCH }}" >> $GITHUB_ENV
echo "arm=on" >> $GITHUB_ENV
echo "amd=on" >> $GITHUB_ENV
fi
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '^1.22'
- name: install arm tools
run: |
sudo apt-get update && sudo apt-get install -y crossbuild-essential-arm64
- name: Check out repo code
uses: actions/checkout@v4
- name: Check out build code
uses: actions/checkout@v4
with:
repository: ${{ env.REPO }}
ref: ${{ env.vbranch }}
token: ${{ secrets.KPULL }}
path: ${{ env.PROJECT }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Image Registry Login
shell: bash
run: |
buildah login -u ${{ env.REGISTRY_USER }} -p ${{ env.REGISTRY_PASS }} ${{ env.REGISTRY_NAME }}
- name: Build binary
run: |
cd ${{ env.PROJECT }}
export KUBE_GIT_COMMIT=""
export KUBE_GIT_VERSION=${{ env.vbranch }}
export KUBE_BUILD_PLATFORMS=linux/amd64
make kube-apiserver kubelet kube-proxy kube-controller-manager kube-scheduler kubectl #cloud-controller-manager
export KUBE_BUILD_PLATFORMS=linux/arm64
make kube-apiserver kubelet kube-proxy kube-controller-manager kube-scheduler kubectl #cloud-controller-manager
tree _output
- name: Docker Image(amd64) Build And Push
if: ${{ contains( env.amd, 'on') }}
shell: bash
run: |
cd ${{ env.PROJECT }}
# amd64
image_repo=${{ env.REGISTRY_NAME }}/captain/hyperkube:${{ env.vbranch }}
image_repo2=${{ env.REGISTRY_NAME }}/production/hyperkube:${{ env.vbranch }}
buildah bud --no-cache --platform linux/amd64 \
-t $image_repo \
-t $image_repo2 \
--build-arg TARGETARCH=amd64 \
-f ../${{ env.Dockerfile }} .
buildah push $image_repo
buildah push $image_repo2
- name: Docker Image(arm64) Build And Push
if: ${{ contains( env.arm, 'on') }}
shell: bash
run: |
cd ${{ env.PROJECT }}
# arm64
image_repo=${{ env.REGISTRY_NAME }}/arm64v8/hyperkube:${{ env.vbranch }}
buildah bud --no-cache --platform linux/arm64 \
-t $image_repo \
--build-arg TARGETARCH=arm64 \
-f ../${{ env.Dockerfile }} .
buildah push $image_repo