Skip to content

Commit

Permalink
Build microk8s for armhf and other architectures (canonical#2048)
Browse files Browse the repository at this point in the history
Build etcd from source

Co-authored-by: angelnu <git@angelnu.com>
  • Loading branch information
ktsakalozos and angelnu authored Feb 24, 2021
1 parent 5c36496 commit 1603084
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ tests/__pycache__
/installer/build/
.tox_env/
__pycache__/
microk8s_*.txt #Remote build log
2 changes: 1 addition & 1 deletion scripts/wrappers/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def get_current_arch():
# architecture mapping
arch_mapping = {"aarch64": "arm64", "x86_64": "amd64"}
arch_mapping = {"aarch64": "arm64", "armv7l": "armhf", "x86_64": "amd64"}

return arch_mapping[platform.machine()]

Expand Down
23 changes: 19 additions & 4 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,25 @@ parts:
etcd:
plugin: dump
source: build-scripts/
build-snaps: [go]
override-build: |
. ./set-env-variables.sh
curl -LO https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-$KUBE_ARCH.tar.gz
tar -xzvf etcd-*.tar.gz --strip-components=1
case ${SNAPCRAFT_ARCH_TRIPLET%%-*} in
x86_64|aarch64)
echo "Supported arch by etcd - use official binary"
curl -LO https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-$KUBE_ARCH.tar.gz
tar -xzvf etcd-*.tar.gz --strip-components=1
;;
*)
echo "Unsupported arch by etcd - build from sources"
curl -LO https://github.com/etcd-io/etcd/archive/${ETCD_VERSION}.tar.gz
tar -xzf *.tar.gz
cd etcd-*
go mod vendor
./build
cp -av bin/* ../
echo "End of build"
esac
snapcraftctl build
stage:
- etcd
Expand Down Expand Up @@ -454,9 +469,9 @@ parts:
cp $KUBE_SNAP_ROOT/microk8s-resources/wrappers/* .
cp -r $KUBE_SNAP_ROOT/microk8s-resources/actions .
if [ "${ARCH}" = "arm64" ]
if [ "${ARCH}" != "amd64" ]
then
# Some actions are not available on arm64
# Some actions are only available on amd64
# Nvidia support
rm "actions/enable.gpu.sh"
rm "actions/disable.gpu.sh"
Expand Down

0 comments on commit 1603084

Please sign in to comment.