From 7329f387398b330d5b954bd76a38cb30406b933c Mon Sep 17 00:00:00 2001 From: Rye Terrell Date: Tue, 21 Mar 2017 10:44:19 -0500 Subject: [PATCH 01/34] add snap packaging --- README.md | 10 +++++++ snap/.gitignore | 1 + snap/Makefile | 38 ++++++++++++++++++++++++ snap/README.md | 32 ++++++++++++++++++++ snap/build-scripts/build | 34 ++++++++++++++++++++++ snap/docker-build.sh | 4 +++ snap/kube-apiserver.yaml | 30 +++++++++++++++++++ snap/kube-controller-manager.yaml | 30 +++++++++++++++++++ snap/kube-proxy.yaml | 30 +++++++++++++++++++ snap/kube-scheduler.yaml | 32 ++++++++++++++++++++ snap/kubeadm.yaml | 19 ++++++++++++ snap/kubectl.yaml | 20 +++++++++++++ snap/kubelet.yaml | 29 +++++++++++++++++++ snap/shared/generate-configure-hook | 45 +++++++++++++++++++++++++++++ snap/shared/run-with-config-args | 8 +++++ 15 files changed, 362 insertions(+) create mode 100644 snap/.gitignore create mode 100644 snap/Makefile create mode 100644 snap/README.md create mode 100755 snap/build-scripts/build create mode 100755 snap/docker-build.sh create mode 100644 snap/kube-apiserver.yaml create mode 100644 snap/kube-controller-manager.yaml create mode 100644 snap/kube-proxy.yaml create mode 100644 snap/kube-scheduler.yaml create mode 100644 snap/kubeadm.yaml create mode 100644 snap/kubectl.yaml create mode 100644 snap/kubelet.yaml create mode 100755 snap/shared/generate-configure-hook create mode 100755 snap/shared/run-with-config-args diff --git a/README.md b/README.md index 3faebefade4..bb0affb8aac 100644 --- a/README.md +++ b/README.md @@ -154,3 +154,13 @@ cd rpm Resulting rpms, and a pre-generated yum repository will be generated in rpm/output/x86_64. +### Snap + +You can build snap packages with: + +``` +cd snap +./docker-build.sh +``` + +The resulting snap packages will be located in snap/build. diff --git a/snap/.gitignore b/snap/.gitignore new file mode 100644 index 00000000000..567609b1234 --- /dev/null +++ b/snap/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/snap/Makefile b/snap/Makefile new file mode 100644 index 00000000000..d9fb318e179 --- /dev/null +++ b/snap/Makefile @@ -0,0 +1,38 @@ +KUBE_VERSION=$(shell curl -L https://dl.k8s.io/release/stable.txt) + +ifndef VERBOSE + MAKEFLAGS += --no-print-directory +endif + +targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm + +build = ./build-scripts/build + +.PHONY: $(targets) + +default: + @KUBE_VERSION=${KUBE_VERSION} ${build} $(targets) + +clean: + @rm -rf build + +kubectl: + @KUBE_VERSION=${KUBE_VERSION} ${build} kubectl + +kubeadm: + @KUBE_VERSION=${KUBE_VERSION} ${build} kubeadm + +kube-apiserver: + @KUBE_VERSION=${KUBE_VERSION} ${build} kube-apiserver + +kube-controller-manager: + @KUBE_VERSION=${KUBE_VERSION} ${build} kube-controller-manager + +kube-scheduler: + @KUBE_VERSION=${KUBE_VERSION} ${build} kube-scheduler + +kubelet: + @KUBE_VERSION=${KUBE_VERSION} ${build} kubelet + +kube-proxy: + @KUBE_VERSION=${KUBE_VERSION} ${build} kube-proxy diff --git a/snap/README.md b/snap/README.md new file mode 100644 index 00000000000..61b7f6ec06f --- /dev/null +++ b/snap/README.md @@ -0,0 +1,32 @@ +# Kubernetes Snaps + +## Build everything + +Run `./docker-build.sh` here and check for the results in the `build/` directory. + +## Build one snap + +To build a specific snap, run `./docker-build.sh` with the name of the snap, e.g., for +kubectl: + +```sh +$ ./docker-build.sh kubectl +``` + +The result will again be in the `build/` directory. + +## Build a specific version + +Set KUBE_VERSION to build the snaps with a particular Kubernetes version, e.g., + +```sh +$ ./docker-build.sh KUBE_VERSION=v1.5.5 +``` + +## Cleaning up + +Simply run `./docker-build.sh clean` to remove everything except downloaded resources: + +```sh +$ ./docker-build.sh clean +``` diff --git a/snap/build-scripts/build b/snap/build-scripts/build new file mode 100755 index 00000000000..db1d9b31d4b --- /dev/null +++ b/snap/build-scripts/build @@ -0,0 +1,34 @@ +#!/bin/bash +set -eu + +apps="$@" + +KUBE_SNAP_BINS="${KUBE_SNAP_BINS:-}" +if [ -z "$KUBE_SNAP_BINS" ]; then + echo "KUBE_SNAP_BINS is not set, downloading binaries from upstream" + export KUBE_SNAP_BINS=build/kube_bins/$KUBE_VERSION + mkdir -p $KUBE_SNAP_BINS + cd $KUBE_SNAP_BINS + for app in kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm; do + curl -LO \ + https://dl.k8s.io/${KUBE_VERSION}/bin/linux/amd64/$app + chmod +x $app + done + cd ../../.. +fi + +export KUBE_SNAP_ROOT="$(readlink -f .)" +export KUBE_SNAP_BINS="$(readlink -f $KUBE_SNAP_BINS)" + +for app in $apps; do + echo "Building $app $KUBE_VERSION from $KUBE_SNAP_BINS" + + build_dir=build/$app + rm -rf $build_dir + mkdir -p $build_dir + + sed "s/KUBE_VERSION/${KUBE_VERSION:1}/g" $app.yaml > $build_dir/snapcraft.yaml + + (cd $build_dir && snapcraft) + mv $build_dir/*.snap build +done diff --git a/snap/docker-build.sh b/snap/docker-build.sh new file mode 100755 index 00000000000..9d7efed128a --- /dev/null +++ b/snap/docker-build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker run --rm -v $PWD:/root/snap -w /root/snap -e SNAPCRAFT_SETUP_CORE=1\ + snapcraft/xenial-amd64 make "$@" diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml new file mode 100644 index 00000000000..a0b5490073f --- /dev/null +++ b/snap/kube-apiserver.yaml @@ -0,0 +1,30 @@ +name: kube-apiserver +version: 'KUBE_VERSION' +summary: kube-apiserver +description: kube-apiserver +grade: stable +confinement: strict + +apps: + daemon: + command: run-with-config-args kube-apiserver + daemon: simple + plugs: + - home + - network + - network-bind + kube-apiserver: + command: kube-apiserver + plugs: + - home + - network + - network-bind +parts: + kube-apiserver: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kube-apiserver . + cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-apiserver diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml new file mode 100644 index 00000000000..81f10720e5d --- /dev/null +++ b/snap/kube-controller-manager.yaml @@ -0,0 +1,30 @@ +name: kube-controller-manager +version: 'KUBE_VERSION' +summary: kube-controller-manager +description: kube-controller-manager +grade: stable +confinement: strict + +apps: + daemon: + command: run-with-config-args kube-controller-manager + daemon: simple + plugs: + - network + - network-bind + - home + kube-controller-manager: + command: kube-controller-manager + plugs: + - network + - network-bind + - home +parts: + kube-controller-manager: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kube-controller-manager . + cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml new file mode 100644 index 00000000000..e1460f29d20 --- /dev/null +++ b/snap/kube-proxy.yaml @@ -0,0 +1,30 @@ +name: kube-proxy +version: 'KUBE_VERSION' +summary: Kubernetes network proxy runs on each node. +description: | + The Kubernetes network proxy runs on each node. This reflects services as + defined in the Kubernetes API on each node and can do simple TCP,UDP stream + forwarding or round robin TCP,UDP forwarding across a set of backends. Service + cluster ips and ports are currently found through Docker-links-compatible + environment variables specifying ports opened by the service proxy. There is + an optional addon that provides cluster DNS for these cluster IPs. The user + must create a service with the apiserver API to configure the proxy. +grade: stable +confinement: classic + +apps: + daemon: + command: run-with-config-args kube-proxy + daemon: simple + kube-proxy: + command: kube-proxy + +parts: + kube-proxy: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kube-proxy . + cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-proxy diff --git a/snap/kube-scheduler.yaml b/snap/kube-scheduler.yaml new file mode 100644 index 00000000000..422b2e17142 --- /dev/null +++ b/snap/kube-scheduler.yaml @@ -0,0 +1,32 @@ +name: kube-scheduler +version: 'KUBE_VERSION' +summary: kube-scheduler controls the Kubernetes cluster manager. +description: | + kube-scheduler is a command line interface for running commands against Kubernetes + clusters. +grade: stable +confinement: strict + +apps: + daemon: + command: run-with-config-args kube-scheduler + daemon: simple + plugs: + - network + - network-bind + - home + kube-scheduler: + command: kube-scheduler + plugs: + - network + - network-bind + - home +parts: + kube-scheduler: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kube-scheduler . + cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-scheduler diff --git a/snap/kubeadm.yaml b/snap/kubeadm.yaml new file mode 100644 index 00000000000..a56097681d9 --- /dev/null +++ b/snap/kubeadm.yaml @@ -0,0 +1,19 @@ +name: kubeadm +version: 'KUBE_VERSION' +summary: easily bootstrap a secure Kubernetes cluster +description: | + easily bootstrap a secure Kubernetes cluster +grade: stable +confinement: classic + +apps: + kubeadm: + command: kubeadm + +parts: + kubeadm: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kubeadm . diff --git a/snap/kubectl.yaml b/snap/kubectl.yaml new file mode 100644 index 00000000000..e9f6ce461d8 --- /dev/null +++ b/snap/kubectl.yaml @@ -0,0 +1,20 @@ +name: kubectl +version: 'KUBE_VERSION' +summary: kubectl controls the Kubernetes cluster manager. +description: | + kubectl is a command line interface for running commands against Kubernetes + clusters. +grade: stable +confinement: classic + +apps: + kubectl: + command: kubectl + +parts: + kubectl: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kubectl . diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml new file mode 100644 index 00000000000..d0fe69fd677 --- /dev/null +++ b/snap/kubelet.yaml @@ -0,0 +1,29 @@ +name: kubelet +version: 'KUBE_VERSION' +summary: kubelet is the primary “node agent” that runs on each node in Kubernetes. +description: | + The kubelet is the primary “node agent” that runs on each node. The kubelet + works in terms of a PodSpec. A PodSpec is a YAML or JSON object that describes + a pod. The kubelet takes a set of PodSpecs that are provided through various + mechanisms (primarily through the apiserver) and ensures that the containers + described in those PodSpecs are running and healthy. The kubelet doesn’t + manage containers which were not created by Kubernetes. +grade: stable +confinement: classic + +apps: + daemon: + command: run-with-config-args kubelet + daemon: simple + kubelet: + command: kubelet + +parts: + kubelet: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kubelet . + cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + $KUBE_SNAP_ROOT/shared/generate-configure-hook kubelet diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook new file mode 100755 index 00000000000..f18259ef91d --- /dev/null +++ b/snap/shared/generate-configure-hook @@ -0,0 +1,45 @@ +#!/bin/sh +set -eu + +app=$1 + +mkdir -p meta/hooks + +cat << 'EOF' > meta/hooks/configure +#!/bin/bash +set -eu + +rm -f $SNAP_DATA/args + +function config-arg { + key=$1 + value=$(snapctl get -t $key) + if [ "$value" != 'null' ]; then + echo "--$key $value" >> $SNAP_DATA/args + fi +} + +function config-arg-bool { + key=$1 + value=$(snapctl get $key) + if [ "$value" = 'true' ]; then + echo "--$key" >> $SNAP_DATA/args + elif [ -n "$value" ] && [ "$value" != 'false' ]; then + >&2 echo "Invalid value for $key: $value, expected true or false" + exit 1 + fi +} + +EOF + +$KUBE_SNAP_BINS/$app -h 2>&1 | grep '\-\-' | perl -pe 's/.*?--(\S+ \S*).*/\1/' | while read line; do + if [ $(echo "$line" | wc -w) -eq 2 ]; then + key=$(echo "$line" | cut -d ' ' -f 1) + echo "config-arg $key" >> meta/hooks/configure + else + key=$line + echo "config-arg-bool $key" >> meta/hooks/configure + fi +done + +chmod +x meta/hooks/configure diff --git a/snap/shared/run-with-config-args b/snap/shared/run-with-config-args new file mode 100755 index 00000000000..f54d5723fcc --- /dev/null +++ b/snap/shared/run-with-config-args @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +app=$1 + +# This is really the only way I could find to get the args passed in correctly. WTF +declare -a args="($(cat $SNAP_DATA/args))" +exec "$SNAP/$app" "${args[@]}" From 7d59906468ae48b845fb2b6217ed01ce7ab52d76 Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Tue, 11 Apr 2017 12:59:54 +0300 Subject: [PATCH 02/34] Adding snap for kubefed --- snap/Makefile | 5 ++++- snap/build-scripts/build | 2 +- snap/kubefed.yaml | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 snap/kubefed.yaml diff --git a/snap/Makefile b/snap/Makefile index d9fb318e179..7716d95c6f2 100644 --- a/snap/Makefile +++ b/snap/Makefile @@ -4,7 +4,7 @@ ifndef VERBOSE MAKEFLAGS += --no-print-directory endif -targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm +targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubefed build = ./build-scripts/build @@ -22,6 +22,9 @@ kubectl: kubeadm: @KUBE_VERSION=${KUBE_VERSION} ${build} kubeadm +kubefed: + @KUBE_VERSION=${KUBE_VERSION} ${build} kubefed + kube-apiserver: @KUBE_VERSION=${KUBE_VERSION} ${build} kube-apiserver diff --git a/snap/build-scripts/build b/snap/build-scripts/build index db1d9b31d4b..70cc84899e8 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -9,7 +9,7 @@ if [ -z "$KUBE_SNAP_BINS" ]; then export KUBE_SNAP_BINS=build/kube_bins/$KUBE_VERSION mkdir -p $KUBE_SNAP_BINS cd $KUBE_SNAP_BINS - for app in kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm; do + for app in $apps; do curl -LO \ https://dl.k8s.io/${KUBE_VERSION}/bin/linux/amd64/$app chmod +x $app diff --git a/snap/kubefed.yaml b/snap/kubefed.yaml new file mode 100644 index 00000000000..107d7370c32 --- /dev/null +++ b/snap/kubefed.yaml @@ -0,0 +1,20 @@ +name: kubefed +version: 'KUBE_VERSION' +summary: kubefed controls the Kubernetes cluster federation manager. +description: | + kubefed is a command line interface for running commands against Kubernetes + federated clusters. +grade: stable +confinement: classic + +apps: + kubefed: + command: kubefed + +parts: + kubefed: + plugin: dump + source: . + prepare: | + set -eu + cp $KUBE_SNAP_BINS/kubefed . From 22a854d4b47f14321abf9f1a192a00d92866684b Mon Sep 17 00:00:00 2001 From: Cynerva Date: Tue, 18 Apr 2017 15:47:13 -0500 Subject: [PATCH 03/34] add ceph-common to kube-controller-manager snap (#4) This is necessary for kube-controller-manager to provision volumes with `rbd`. --- snap/kube-controller-manager.yaml | 7 +++++-- .../kube-controller-manager-wrapper | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100755 snap/kube-controller-manager/kube-controller-manager-wrapper diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index 81f10720e5d..24d956c62dc 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -7,14 +7,14 @@ confinement: strict apps: daemon: - command: run-with-config-args kube-controller-manager + command: run-with-config-args kube-controller-manager-wrapper daemon: simple plugs: - network - network-bind - home kube-controller-manager: - command: kube-controller-manager + command: kube-controller-manager-wrapper plugs: - network - network-bind @@ -23,8 +23,11 @@ parts: kube-controller-manager: plugin: dump source: . + stage-packages: + - ceph-common prepare: | set -eu cp $KUBE_SNAP_BINS/kube-controller-manager . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + cp $KUBE_SNAP_ROOT/kube-controller-manager/kube-controller-manager-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager diff --git a/snap/kube-controller-manager/kube-controller-manager-wrapper b/snap/kube-controller-manager/kube-controller-manager-wrapper new file mode 100755 index 00000000000..ea3eedc5f1f --- /dev/null +++ b/snap/kube-controller-manager/kube-controller-manager-wrapper @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# Set CEPH_CONF so `rbd` doesn't try to look in /etc/ceph and error out +export CEPH_CONF="$SNAP_USER_DATA/ceph/ceph.conf" + +exec "$SNAP/kube-controller-manager" "$@" From feca1162f6e22090ca99a0569c502fd2c74fbd37 Mon Sep 17 00:00:00 2001 From: Cynerva Date: Thu, 27 Apr 2017 12:33:31 -0500 Subject: [PATCH 04/34] Add kubernetes-test snap (#6) --- snap/Makefile | 5 ++++- snap/build-scripts/build | 19 +++++++++++------- snap/kubernetes-test.yaml | 35 +++++++++++++++++++++++++++++++++ snap/kubernetes-test/ginkgo-e2e | 13 ++++++++++++ 4 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 snap/kubernetes-test.yaml create mode 100755 snap/kubernetes-test/ginkgo-e2e diff --git a/snap/Makefile b/snap/Makefile index 7716d95c6f2..ab7f5100a4f 100644 --- a/snap/Makefile +++ b/snap/Makefile @@ -4,7 +4,7 @@ ifndef VERBOSE MAKEFLAGS += --no-print-directory endif -targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubefed +targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubefed kubernetes-test build = ./build-scripts/build @@ -39,3 +39,6 @@ kubelet: kube-proxy: @KUBE_VERSION=${KUBE_VERSION} ${build} kube-proxy + +kubernetes-test: + @KUBE_VERSION=${KUBE_VERSION} ${build} kubernetes-test diff --git a/snap/build-scripts/build b/snap/build-scripts/build index 70cc84899e8..85121374f34 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -8,13 +8,18 @@ if [ -z "$KUBE_SNAP_BINS" ]; then echo "KUBE_SNAP_BINS is not set, downloading binaries from upstream" export KUBE_SNAP_BINS=build/kube_bins/$KUBE_VERSION mkdir -p $KUBE_SNAP_BINS - cd $KUBE_SNAP_BINS - for app in $apps; do - curl -LO \ - https://dl.k8s.io/${KUBE_VERSION}/bin/linux/amd64/$app - chmod +x $app - done - cd ../../.. + (cd $KUBE_SNAP_BINS + for app in $apps; do + if [ "$app" = "kubernetes-test" ]; then + curl -LO \ + https://dl.k8s.io/${KUBE_VERSION}/kubernetes-test.tar.gz + else + curl -LO \ + https://dl.k8s.io/${KUBE_VERSION}/bin/linux/amd64/$app + chmod +x $app + fi + done + ) fi export KUBE_SNAP_ROOT="$(readlink -f .)" diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml new file mode 100644 index 00000000000..9c0ebb04ddb --- /dev/null +++ b/snap/kubernetes-test.yaml @@ -0,0 +1,35 @@ +name: kubernetes-test +version: 'KUBE_VERSION' +summary: tests for kubernetes +description: | + tests for kubernetes +grade: stable +confinement: classic + +apps: + e2e: + command: ginkgo-e2e + # These will be needed for strict confinement: + # plugs: + # - network + # - network-bind + # - home + +parts: + kubernetes-test: + plugin: dump + source: . + prepare: | + set -eu + + mkdir build-temp + (cd build-temp + tar -xf "$KUBE_SNAP_BINS/kubernetes-test.tar.gz" + mv kubernetes/platforms/linux/amd64/e2e.test .. + mv kubernetes/platforms/linux/amd64/ginkgo .. + ) + rm -rf build-temp + chmod +rx e2e.test + chmod +rx ginkgo + + cp "$KUBE_SNAP_ROOT/kubernetes-test/ginkgo-e2e" . diff --git a/snap/kubernetes-test/ginkgo-e2e b/snap/kubernetes-test/ginkgo-e2e new file mode 100755 index 00000000000..a8eb5012c44 --- /dev/null +++ b/snap/kubernetes-test/ginkgo-e2e @@ -0,0 +1,13 @@ +#!/bin/bash +set -eu + +GINKGO_ARGS="${GINKGO_ARGS:-}" + +# e2e.test needs to be placed in a directory we have write access to. +# Otherwise, some of the tests will fail. +TEMP_DIR="/tmp/cdk-test.ginkgo-e2e" +rm -rf "$TEMP_DIR" +mkdir "$TEMP_DIR" +cp "$SNAP/e2e.test" "$TEMP_DIR" + +exec "$SNAP/ginkgo" $GINKGO_ARGS "$TEMP_DIR/e2e.test" -- "$@" From d3e58100c35d74bb26075b490ec63ef21edf2445 Mon Sep 17 00:00:00 2001 From: Cynerva Date: Fri, 28 Apr 2017 08:47:22 -0500 Subject: [PATCH 05/34] Snaps multiarch support (#7) * support multiple platforms * allow multiple architectures with a single invocation of make --- snap/Makefile | 21 +++++++++++---------- snap/build-scripts/build | 30 ++++++++++++++++++++---------- snap/kube-apiserver.yaml | 3 ++- snap/kube-controller-manager.yaml | 5 +++-- snap/kube-proxy.yaml | 3 ++- snap/kube-scheduler.yaml | 3 ++- snap/kubeadm.yaml | 3 ++- snap/kubectl.yaml | 3 ++- snap/kubefed.yaml | 3 ++- snap/kubelet.yaml | 3 ++- snap/kubernetes-test.yaml | 5 +++-- 11 files changed, 51 insertions(+), 31 deletions(-) diff --git a/snap/Makefile b/snap/Makefile index ab7f5100a4f..38b505fe9a1 100644 --- a/snap/Makefile +++ b/snap/Makefile @@ -1,4 +1,5 @@ KUBE_VERSION=$(shell curl -L https://dl.k8s.io/release/stable.txt) +KUBE_ARCH=amd64 ifndef VERBOSE MAKEFLAGS += --no-print-directory @@ -11,34 +12,34 @@ build = ./build-scripts/build .PHONY: $(targets) default: - @KUBE_VERSION=${KUBE_VERSION} ${build} $(targets) + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} $(targets) clean: @rm -rf build kubectl: - @KUBE_VERSION=${KUBE_VERSION} ${build} kubectl + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubectl kubeadm: - @KUBE_VERSION=${KUBE_VERSION} ${build} kubeadm + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubeadm kubefed: - @KUBE_VERSION=${KUBE_VERSION} ${build} kubefed + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubefed kube-apiserver: - @KUBE_VERSION=${KUBE_VERSION} ${build} kube-apiserver + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kube-apiserver kube-controller-manager: - @KUBE_VERSION=${KUBE_VERSION} ${build} kube-controller-manager + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kube-controller-manager kube-scheduler: - @KUBE_VERSION=${KUBE_VERSION} ${build} kube-scheduler + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kube-scheduler kubelet: - @KUBE_VERSION=${KUBE_VERSION} ${build} kubelet + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubelet kube-proxy: - @KUBE_VERSION=${KUBE_VERSION} ${build} kube-proxy + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kube-proxy kubernetes-test: - @KUBE_VERSION=${KUBE_VERSION} ${build} kubernetes-test + @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubernetes-test diff --git a/snap/build-scripts/build b/snap/build-scripts/build index 85121374f34..1d6581841fb 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -11,12 +11,19 @@ if [ -z "$KUBE_SNAP_BINS" ]; then (cd $KUBE_SNAP_BINS for app in $apps; do if [ "$app" = "kubernetes-test" ]; then + echo "Fetching $app $KUBE_VERSION" curl -LO \ https://dl.k8s.io/${KUBE_VERSION}/kubernetes-test.tar.gz else - curl -LO \ - https://dl.k8s.io/${KUBE_VERSION}/bin/linux/amd64/$app - chmod +x $app + for arch in $KUBE_ARCH; do + mkdir -p $arch + (cd $arch + echo "Fetching $app $KUBE_VERSION $arch" + curl -LO \ + https://dl.k8s.io/${KUBE_VERSION}/bin/linux/$arch/$app + chmod +x $app + ) + done fi done ) @@ -26,14 +33,17 @@ export KUBE_SNAP_ROOT="$(readlink -f .)" export KUBE_SNAP_BINS="$(readlink -f $KUBE_SNAP_BINS)" for app in $apps; do - echo "Building $app $KUBE_VERSION from $KUBE_SNAP_BINS" + for arch in $KUBE_ARCH; do + echo "Building $app $KUBE_VERSION for $arch from $KUBE_SNAP_BINS" - build_dir=build/$app - rm -rf $build_dir - mkdir -p $build_dir + build_dir=build/$app + rm -rf $build_dir + mkdir -p $build_dir - sed "s/KUBE_VERSION/${KUBE_VERSION:1}/g" $app.yaml > $build_dir/snapcraft.yaml + sed "s/KUBE_VERSION/${KUBE_VERSION:1}/g" $app.yaml > $build_dir/snapcraft.yaml + sed -i "s/KUBE_ARCH/$arch/g" $build_dir/snapcraft.yaml - (cd $build_dir && snapcraft) - mv $build_dir/*.snap build + (cd $build_dir && snapcraft) + mv $build_dir/*.snap build + done done diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml index a0b5490073f..05b96df0bf6 100644 --- a/snap/kube-apiserver.yaml +++ b/snap/kube-apiserver.yaml @@ -1,4 +1,5 @@ name: kube-apiserver +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: kube-apiserver description: kube-apiserver @@ -25,6 +26,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kube-apiserver . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-apiserver . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-apiserver diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index 24d956c62dc..57446bceb56 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -1,4 +1,5 @@ name: kube-controller-manager +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: kube-controller-manager description: kube-controller-manager @@ -24,10 +25,10 @@ parts: plugin: dump source: . stage-packages: - - ceph-common + - ceph-common:KUBE_ARCH prepare: | set -eu - cp $KUBE_SNAP_BINS/kube-controller-manager . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-controller-manager . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kube-controller-manager/kube-controller-manager-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml index e1460f29d20..227eb052ede 100644 --- a/snap/kube-proxy.yaml +++ b/snap/kube-proxy.yaml @@ -1,4 +1,5 @@ name: kube-proxy +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: Kubernetes network proxy runs on each node. description: | @@ -25,6 +26,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kube-proxy . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-proxy . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-proxy diff --git a/snap/kube-scheduler.yaml b/snap/kube-scheduler.yaml index 422b2e17142..80a16eb13f0 100644 --- a/snap/kube-scheduler.yaml +++ b/snap/kube-scheduler.yaml @@ -1,4 +1,5 @@ name: kube-scheduler +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: kube-scheduler controls the Kubernetes cluster manager. description: | @@ -27,6 +28,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kube-scheduler . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-scheduler . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-scheduler diff --git a/snap/kubeadm.yaml b/snap/kubeadm.yaml index a56097681d9..c18c1c05cf9 100644 --- a/snap/kubeadm.yaml +++ b/snap/kubeadm.yaml @@ -1,4 +1,5 @@ name: kubeadm +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: easily bootstrap a secure Kubernetes cluster description: | @@ -16,4 +17,4 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kubeadm . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kubeadm . diff --git a/snap/kubectl.yaml b/snap/kubectl.yaml index e9f6ce461d8..2c30c86931e 100644 --- a/snap/kubectl.yaml +++ b/snap/kubectl.yaml @@ -1,4 +1,5 @@ name: kubectl +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: kubectl controls the Kubernetes cluster manager. description: | @@ -17,4 +18,4 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kubectl . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kubectl . diff --git a/snap/kubefed.yaml b/snap/kubefed.yaml index 107d7370c32..c94d1f025e4 100644 --- a/snap/kubefed.yaml +++ b/snap/kubefed.yaml @@ -1,4 +1,5 @@ name: kubefed +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: kubefed controls the Kubernetes cluster federation manager. description: | @@ -17,4 +18,4 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kubefed . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kubefed . diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index d0fe69fd677..de29e969b73 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -1,4 +1,5 @@ name: kubelet +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: kubelet is the primary “node agent” that runs on each node in Kubernetes. description: | @@ -24,6 +25,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/kubelet . + cp $KUBE_SNAP_BINS/KUBE_ARCH/kubelet . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kubelet diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml index 9c0ebb04ddb..95d7389e161 100644 --- a/snap/kubernetes-test.yaml +++ b/snap/kubernetes-test.yaml @@ -1,4 +1,5 @@ name: kubernetes-test +architectures: ['KUBE_ARCH'] version: 'KUBE_VERSION' summary: tests for kubernetes description: | @@ -25,8 +26,8 @@ parts: mkdir build-temp (cd build-temp tar -xf "$KUBE_SNAP_BINS/kubernetes-test.tar.gz" - mv kubernetes/platforms/linux/amd64/e2e.test .. - mv kubernetes/platforms/linux/amd64/ginkgo .. + mv kubernetes/platforms/linux/KUBE_ARCH/e2e.test .. + mv kubernetes/platforms/linux/KUBE_ARCH/ginkgo .. ) rm -rf build-temp chmod +rx e2e.test From d14660b0e174f25adec85150732068b2745e6226 Mon Sep 17 00:00:00 2001 From: Rye Terrell Date: Wed, 3 May 2017 11:30:36 -0500 Subject: [PATCH 06/34] fix configure hook generation (#8) --- snap/shared/generate-configure-hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook index f18259ef91d..abafd4a6c99 100755 --- a/snap/shared/generate-configure-hook +++ b/snap/shared/generate-configure-hook @@ -32,7 +32,7 @@ function config-arg-bool { EOF -$KUBE_SNAP_BINS/$app -h 2>&1 | grep '\-\-' | perl -pe 's/.*?--(\S+ \S*).*/\1/' | while read line; do +./$app -h 2>&1 | grep '\-\-' | perl -pe 's/.*?--(\S+ \S*).*/\1/' | while read line; do if [ $(echo "$line" | wc -w) -eq 2 ]; then key=$(echo "$line" | cut -d ' ' -f 1) echo "config-arg $key" >> meta/hooks/configure From 2503ce7cd730b8c875ed660ee65de120e588d036 Mon Sep 17 00:00:00 2001 From: Cynerva Date: Tue, 9 May 2017 15:19:38 -0500 Subject: [PATCH 07/34] Fix snap arm/ppc64le builds by mapping to the correct arch (#9) --- snap/build-scripts/build | 16 ++++++++++++---- snap/kube-apiserver.yaml | 6 +++--- snap/kube-controller-manager.yaml | 8 ++++---- snap/kube-proxy.yaml | 6 +++--- snap/kube-scheduler.yaml | 6 +++--- snap/kubeadm.yaml | 6 +++--- snap/kubectl.yaml | 6 +++--- snap/kubefed.yaml | 6 +++--- snap/kubelet.yaml | 6 +++--- snap/kubernetes-test.yaml | 8 ++++---- 10 files changed, 41 insertions(+), 33 deletions(-) diff --git a/snap/build-scripts/build b/snap/build-scripts/build index 1d6581841fb..418efe1c759 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -2,6 +2,7 @@ set -eu apps="$@" +architectures="$KUBE_ARCH" KUBE_SNAP_BINS="${KUBE_SNAP_BINS:-}" if [ -z "$KUBE_SNAP_BINS" ]; then @@ -15,7 +16,7 @@ if [ -z "$KUBE_SNAP_BINS" ]; then curl -LO \ https://dl.k8s.io/${KUBE_VERSION}/kubernetes-test.tar.gz else - for arch in $KUBE_ARCH; do + for arch in $architectures; do mkdir -p $arch (cd $arch echo "Fetching $app $KUBE_VERSION $arch" @@ -33,15 +34,22 @@ export KUBE_SNAP_ROOT="$(readlink -f .)" export KUBE_SNAP_BINS="$(readlink -f $KUBE_SNAP_BINS)" for app in $apps; do - for arch in $KUBE_ARCH; do + for arch in $architectures; do echo "Building $app $KUBE_VERSION for $arch from $KUBE_SNAP_BINS" build_dir=build/$app rm -rf $build_dir mkdir -p $build_dir - sed "s/KUBE_VERSION/${KUBE_VERSION:1}/g" $app.yaml > $build_dir/snapcraft.yaml - sed -i "s/KUBE_ARCH/$arch/g" $build_dir/snapcraft.yaml + export KUBE_ARCH="$arch" + declare -A kube_arch_to_snap_arch=( + [ppc64le]=ppc64el + [arm]=armhf + ) + export SNAP_ARCH="${kube_arch_to_snap_arch[$arch]:-$arch}" + + sed "s/\$KUBE_VERSION/${KUBE_VERSION:1}/g" $app.yaml > $build_dir/snapcraft.yaml + sed -i "s/\$SNAP_ARCH/$SNAP_ARCH/g" $build_dir/snapcraft.yaml (cd $build_dir && snapcraft) mv $build_dir/*.snap build diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml index 05b96df0bf6..4581c6215d0 100644 --- a/snap/kube-apiserver.yaml +++ b/snap/kube-apiserver.yaml @@ -1,6 +1,6 @@ name: kube-apiserver -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: kube-apiserver description: kube-apiserver grade: stable @@ -26,6 +26,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-apiserver . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-apiserver . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-apiserver diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index 57446bceb56..ffd86df4372 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -1,6 +1,6 @@ name: kube-controller-manager -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: kube-controller-manager description: kube-controller-manager grade: stable @@ -25,10 +25,10 @@ parts: plugin: dump source: . stage-packages: - - ceph-common:KUBE_ARCH + - ceph-common:$SNAP_ARCH prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-controller-manager . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-controller-manager . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kube-controller-manager/kube-controller-manager-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml index 227eb052ede..537fb5e8d20 100644 --- a/snap/kube-proxy.yaml +++ b/snap/kube-proxy.yaml @@ -1,6 +1,6 @@ name: kube-proxy -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: Kubernetes network proxy runs on each node. description: | The Kubernetes network proxy runs on each node. This reflects services as @@ -26,6 +26,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-proxy . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-proxy . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-proxy diff --git a/snap/kube-scheduler.yaml b/snap/kube-scheduler.yaml index 80a16eb13f0..d5100d4b398 100644 --- a/snap/kube-scheduler.yaml +++ b/snap/kube-scheduler.yaml @@ -1,6 +1,6 @@ name: kube-scheduler -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: kube-scheduler controls the Kubernetes cluster manager. description: | kube-scheduler is a command line interface for running commands against Kubernetes @@ -28,6 +28,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kube-scheduler . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-scheduler . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-scheduler diff --git a/snap/kubeadm.yaml b/snap/kubeadm.yaml index c18c1c05cf9..960de1b7790 100644 --- a/snap/kubeadm.yaml +++ b/snap/kubeadm.yaml @@ -1,6 +1,6 @@ name: kubeadm -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: easily bootstrap a secure Kubernetes cluster description: | easily bootstrap a secure Kubernetes cluster @@ -17,4 +17,4 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kubeadm . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubeadm . diff --git a/snap/kubectl.yaml b/snap/kubectl.yaml index 2c30c86931e..68198f9b683 100644 --- a/snap/kubectl.yaml +++ b/snap/kubectl.yaml @@ -1,6 +1,6 @@ name: kubectl -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: kubectl controls the Kubernetes cluster manager. description: | kubectl is a command line interface for running commands against Kubernetes @@ -18,4 +18,4 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kubectl . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubectl . diff --git a/snap/kubefed.yaml b/snap/kubefed.yaml index c94d1f025e4..648a8b10fa7 100644 --- a/snap/kubefed.yaml +++ b/snap/kubefed.yaml @@ -1,6 +1,6 @@ name: kubefed -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: kubefed controls the Kubernetes cluster federation manager. description: | kubefed is a command line interface for running commands against Kubernetes @@ -18,4 +18,4 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kubefed . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubefed . diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index de29e969b73..4a855930a7e 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -1,6 +1,6 @@ name: kubelet -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: kubelet is the primary “node agent” that runs on each node in Kubernetes. description: | The kubelet is the primary “node agent” that runs on each node. The kubelet @@ -25,6 +25,6 @@ parts: source: . prepare: | set -eu - cp $KUBE_SNAP_BINS/KUBE_ARCH/kubelet . + cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubelet . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . $KUBE_SNAP_ROOT/shared/generate-configure-hook kubelet diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml index 95d7389e161..7f0838aa733 100644 --- a/snap/kubernetes-test.yaml +++ b/snap/kubernetes-test.yaml @@ -1,6 +1,6 @@ name: kubernetes-test -architectures: ['KUBE_ARCH'] -version: 'KUBE_VERSION' +architectures: ['$SNAP_ARCH'] +version: '$KUBE_VERSION' summary: tests for kubernetes description: | tests for kubernetes @@ -26,8 +26,8 @@ parts: mkdir build-temp (cd build-temp tar -xf "$KUBE_SNAP_BINS/kubernetes-test.tar.gz" - mv kubernetes/platforms/linux/KUBE_ARCH/e2e.test .. - mv kubernetes/platforms/linux/KUBE_ARCH/ginkgo .. + mv kubernetes/platforms/linux/$KUBE_ARCH/e2e.test .. + mv kubernetes/platforms/linux/$KUBE_ARCH/ginkgo .. ) rm -rf build-temp chmod +rx e2e.test From 0fea5cc98e8c9e3a908f05e833c35e9da4bdc146 Mon Sep 17 00:00:00 2001 From: Cynerva Date: Wed, 28 Jun 2017 02:07:52 -0500 Subject: [PATCH 08/34] Fix snap configuration not properly handling boolean false values (#10) --- snap/shared/generate-configure-hook | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook index abafd4a6c99..3c0d7968f8b 100755 --- a/snap/shared/generate-configure-hook +++ b/snap/shared/generate-configure-hook @@ -24,7 +24,9 @@ function config-arg-bool { value=$(snapctl get $key) if [ "$value" = 'true' ]; then echo "--$key" >> $SNAP_DATA/args - elif [ -n "$value" ] && [ "$value" != 'false' ]; then + elif [ "$value" = 'false' ]; then + echo "--$key=false" >> $SNAP_DATA/args + elif [ -n "$value" ]; then >&2 echo "Invalid value for $key: $value, expected true or false" exit 1 fi From ee3013b0aef5671cc7dbdd0ef41ee2df43e4b94d Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Sat, 19 Aug 2017 00:30:04 +0300 Subject: [PATCH 09/34] Adding a wrapper and HOME env var to kubelet (#11) --- snap/kubelet.yaml | 3 ++- snap/kubelet/kubelet-wrapper | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 snap/kubelet/kubelet-wrapper diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index 4a855930a7e..babf754a6c5 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -14,7 +14,7 @@ confinement: classic apps: daemon: - command: run-with-config-args kubelet + command: run-with-config-args kubelet-wrapper daemon: simple kubelet: command: kubelet @@ -27,4 +27,5 @@ parts: set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubelet . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + cp $KUBE_SNAP_ROOT/kubelet/kubelet-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kubelet diff --git a/snap/kubelet/kubelet-wrapper b/snap/kubelet/kubelet-wrapper new file mode 100755 index 00000000000..76c128515a5 --- /dev/null +++ b/snap/kubelet/kubelet-wrapper @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu + +export HOME="/root" + +exec "$SNAP/kubelet" "$@" From f52e6659e0f31170ba949ccd3c6ca1f9ee488439 Mon Sep 17 00:00:00 2001 From: Rye Terrell Date: Fri, 2 Mar 2018 10:36:52 -0600 Subject: [PATCH 10/34] include conntrack bin in the kube-proxy snap (#12) * include conntrack bin in the kube-proxy snap * add path to conntrack bin in the kube-proxy snap --- snap/kube-proxy.yaml | 5 ++++- snap/kube-proxy/kube-proxy-wrapper | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 snap/kube-proxy/kube-proxy-wrapper diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml index 537fb5e8d20..414d77f775e 100644 --- a/snap/kube-proxy.yaml +++ b/snap/kube-proxy.yaml @@ -15,7 +15,7 @@ confinement: classic apps: daemon: - command: run-with-config-args kube-proxy + command: run-with-config-args kube-proxy-wrapper daemon: simple kube-proxy: command: kube-proxy @@ -24,8 +24,11 @@ parts: kube-proxy: plugin: dump source: . + stage-packages: + - conntrack:$SNAP_ARCH prepare: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-proxy . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + cp $KUBE_SNAP_ROOT/kube-proxy/kube-proxy-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-proxy diff --git a/snap/kube-proxy/kube-proxy-wrapper b/snap/kube-proxy/kube-proxy-wrapper new file mode 100755 index 00000000000..d6af0704c08 --- /dev/null +++ b/snap/kube-proxy/kube-proxy-wrapper @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu + +export PATH=$PATH:$SNAP/usr/sbin + +exec "$SNAP/kube-proxy" "$@" From 44cda3cad17b14e391dc226fdfa9a756f6b94736 Mon Sep 17 00:00:00 2001 From: George Kraft Date: Thu, 29 Mar 2018 10:18:30 -0500 Subject: [PATCH 11/34] Fix configure hook for 1.10 by converting underscores to dashes (#13) --- snap/shared/generate-configure-hook | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook index 3c0d7968f8b..2118abae2d3 100755 --- a/snap/shared/generate-configure-hook +++ b/snap/shared/generate-configure-hook @@ -11,21 +11,28 @@ set -eu rm -f $SNAP_DATA/args +function option-to-key { + option=$1 + echo $option | sed 's/_/-/g' +} + function config-arg { - key=$1 + option=$1 + key=$(option-to-key $option) value=$(snapctl get -t $key) if [ "$value" != 'null' ]; then - echo "--$key $value" >> $SNAP_DATA/args + echo "--$option $value" >> $SNAP_DATA/args fi } function config-arg-bool { - key=$1 + option=$1 + key=$(option-to-key $option) value=$(snapctl get $key) if [ "$value" = 'true' ]; then - echo "--$key" >> $SNAP_DATA/args + echo "--$option" >> $SNAP_DATA/args elif [ "$value" = 'false' ]; then - echo "--$key=false" >> $SNAP_DATA/args + echo "--$option=false" >> $SNAP_DATA/args elif [ -n "$value" ]; then >&2 echo "Invalid value for $key: $value, expected true or false" exit 1 @@ -36,11 +43,11 @@ EOF ./$app -h 2>&1 | grep '\-\-' | perl -pe 's/.*?--(\S+ \S*).*/\1/' | while read line; do if [ $(echo "$line" | wc -w) -eq 2 ]; then - key=$(echo "$line" | cut -d ' ' -f 1) - echo "config-arg $key" >> meta/hooks/configure + option=$(echo "$line" | cut -d ' ' -f 1) + echo "config-arg $option" >> meta/hooks/configure else - key=$line - echo "config-arg-bool $key" >> meta/hooks/configure + option=$line + echo "config-arg-bool $option" >> meta/hooks/configure fi done From 9b59885e01a54554ec981e3c60152c7e357ffac9 Mon Sep 17 00:00:00 2001 From: George Kraft Date: Thu, 29 Mar 2018 15:57:53 -0500 Subject: [PATCH 12/34] Add hidden kubelet args to snap configure hook (#16) --- snap/kubelet.yaml | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index babf754a6c5..2a50473aedc 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -29,3 +29,127 @@ parts: cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kubelet/kubelet-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kubelet + + # Many of the args in kubelet became hidden with the introduction of + # KubeletConfiguration. We need to include them for backward + # compatibility. + ensure_arg() { + type="$1" + config="$2" + if ! grep "^config-arg.* $config\$" meta/hooks/configure > /dev/null; then + if [ "$type" = "bool" ]; then + echo "config-arg-bool $config" >> meta/hooks/configure + else + echo "config-arg $config" >> meta/hooks/configure + fi + fi + } + + # Hard-coded args generated from a diff of v1.9.6 -> v1.10.0 + ensure_arg string address + ensure_arg bool allow-privileged + ensure_arg bool anonymous-auth + ensure_arg string application-metrics-count-limit + ensure_arg bool authentication-token-webhook + ensure_arg string authentication-token-webhook-cache-ttl + ensure_arg string authorization-mode + ensure_arg string authorization-webhook-cache-authorized-ttl + ensure_arg string authorization-webhook-cache-unauthorized-ttl + ensure_arg string boot-id-file + ensure_arg string cadvisor-port + ensure_arg string cgroup-driver + ensure_arg string cgroup-root + ensure_arg bool cgroups-per-qos + ensure_arg string client-ca-file + ensure_arg string cloud-provider-gce-lb-src-cidrs + ensure_arg string cluster-dns + ensure_arg string cluster-domain + ensure_arg string container-hints + ensure_arg string containerd + ensure_arg bool contention-profiling + ensure_arg bool cpu-cfs-quota + ensure_arg string cpu-manager-policy + ensure_arg string cpu-manager-reconcile-period + ensure_arg string docker + ensure_arg bool docker-disable-shared-pid + ensure_arg string docker-env-metadata-whitelist + ensure_arg bool docker-only + ensure_arg bool docker-tls + ensure_arg string docker-tls-ca + ensure_arg string docker-tls-cert + ensure_arg string docker-tls-key + ensure_arg bool enable-controller-attach-detach + ensure_arg bool enable-debugging-handlers + ensure_arg bool enable-load-reader + ensure_arg string enforce-node-allocatable + ensure_arg string event-burst + ensure_arg string event-qps + ensure_arg string event-storage-age-limit + ensure_arg string event-storage-event-limit + ensure_arg string eviction-hard + ensure_arg string eviction-max-pod-grace-period + ensure_arg string eviction-minimum-reclaim + ensure_arg string eviction-pressure-transition-period + ensure_arg string eviction-soft + ensure_arg string eviction-soft-grace-period + ensure_arg bool fail-swap-on + ensure_arg string feature-gates + ensure_arg string file-check-frequency + ensure_arg string global-housekeeping-interval + ensure_arg string google-json-key + ensure_arg string hairpin-mode + ensure_arg string healthz-bind-address + ensure_arg string healthz-port + ensure_arg string host-ipc-sources + ensure_arg string host-network-sources + ensure_arg string host-pid-sources + ensure_arg string http-check-frequency + ensure_arg string image-gc-high-threshold + ensure_arg string image-gc-low-threshold + ensure_arg string init-config-dir + ensure_arg string iptables-drop-bit + ensure_arg string iptables-masquerade-bit + ensure_arg string kube-api-burst + ensure_arg string kube-api-content-type + ensure_arg string kube-api-qps + ensure_arg string kube-reserved + ensure_arg string kube-reserved-cgroup + ensure_arg string kubelet-cgroups + ensure_arg bool log-cadvisor-usage + ensure_arg string machine-id-file + ensure_arg bool make-iptables-util-chains + ensure_arg string manifest-url + ensure_arg string manifest-url-header + ensure_arg string max-open-files + ensure_arg string max-pods + ensure_arg string minimum-image-ttl-duration + ensure_arg string node-status-update-frequency + ensure_arg string oom-score-adj + ensure_arg string pod-cidr + ensure_arg string pod-manifest-path + ensure_arg string pods-per-core + ensure_arg string port + ensure_arg bool protect-kernel-defaults + ensure_arg string read-only-port + ensure_arg string registry-burst + ensure_arg string registry-qps + ensure_arg string resolv-conf + ensure_arg string rkt-api-endpoint + ensure_arg string rkt-path + ensure_arg string runtime-request-timeout + ensure_arg bool serialize-image-pulls + ensure_arg string storage-driver-buffer-duration + ensure_arg string storage-driver-db + ensure_arg string storage-driver-host + ensure_arg string storage-driver-password + ensure_arg bool storage-driver-secure + ensure_arg string storage-driver-table + ensure_arg string storage-driver-user + ensure_arg string streaming-connection-idle-timeout + ensure_arg string sync-frequency + ensure_arg string system-cgroups + ensure_arg string system-reserved + ensure_arg string system-reserved-cgroup + ensure_arg string tls-cert-file + ensure_arg string tls-private-key-file + ensure_arg string volume-stats-agg-period From 3b21ff4a298a8c9b3449baf88f69a817dbb4e5b7 Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Mon, 2 Apr 2018 21:46:13 +0300 Subject: [PATCH 13/34] Stop building kubefed (#17) * Stop building kubefed * Adding kubefed.yaml back --- snap/Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/snap/Makefile b/snap/Makefile index 38b505fe9a1..b15118239ac 100644 --- a/snap/Makefile +++ b/snap/Makefile @@ -5,7 +5,7 @@ ifndef VERBOSE MAKEFLAGS += --no-print-directory endif -targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubefed kubernetes-test +targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubernetes-test build = ./build-scripts/build @@ -23,9 +23,6 @@ kubectl: kubeadm: @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubeadm -kubefed: - @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kubefed - kube-apiserver: @KUBE_VERSION=${KUBE_VERSION} KUBE_ARCH="${KUBE_ARCH}" ${build} kube-apiserver From 5a983aa322d57f12c52cd0e374774fce4dc310d2 Mon Sep 17 00:00:00 2001 From: Kevin W Monroe Date: Mon, 2 Apr 2018 15:35:17 -0500 Subject: [PATCH 14/34] validate what we download is expected (#14) (#15) --- snap/build-scripts/build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/snap/build-scripts/build b/snap/build-scripts/build index 418efe1c759..b2e076bddf1 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -14,7 +14,11 @@ if [ -z "$KUBE_SNAP_BINS" ]; then if [ "$app" = "kubernetes-test" ]; then echo "Fetching $app $KUBE_VERSION" curl -LO \ - https://dl.k8s.io/${KUBE_VERSION}/kubernetes-test.tar.gz + https://dl.k8s.io/${KUBE_VERSION}/${app}.tar.gz + if ! file ${app}.tar.gz 2>&1 | grep -q 'gzip'; then + echo "${app}.tar.gz is not a gzip archive" + exit 1 + fi else for arch in $architectures; do mkdir -p $arch @@ -23,6 +27,10 @@ if [ -z "$KUBE_SNAP_BINS" ]; then curl -LO \ https://dl.k8s.io/${KUBE_VERSION}/bin/linux/$arch/$app chmod +x $app + if ! file ${app} 2>&1 | grep -q 'executable'; then + echo "${app} is not an executable" + exit 1 + fi ) done fi From 28a56581396123a7c673546d8516bf0c0e3a17d1 Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Tue, 3 Apr 2018 16:19:44 +0300 Subject: [PATCH 15/34] Disable patchelf in classic confinement snaps (#18) --- snap/kube-proxy.yaml | 1 + snap/kubeadm.yaml | 1 + snap/kubectl.yaml | 1 + snap/kubefed.yaml | 1 + snap/kubelet.yaml | 1 + snap/kubernetes-test.yaml | 1 + 6 files changed, 6 insertions(+) diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml index 414d77f775e..aade8dec801 100644 --- a/snap/kube-proxy.yaml +++ b/snap/kube-proxy.yaml @@ -23,6 +23,7 @@ apps: parts: kube-proxy: plugin: dump + build-attributes: [no-patchelf] source: . stage-packages: - conntrack:$SNAP_ARCH diff --git a/snap/kubeadm.yaml b/snap/kubeadm.yaml index 960de1b7790..cf09e6a31d9 100644 --- a/snap/kubeadm.yaml +++ b/snap/kubeadm.yaml @@ -14,6 +14,7 @@ apps: parts: kubeadm: plugin: dump + build-attributes: [no-patchelf] source: . prepare: | set -eu diff --git a/snap/kubectl.yaml b/snap/kubectl.yaml index 68198f9b683..d4be862be29 100644 --- a/snap/kubectl.yaml +++ b/snap/kubectl.yaml @@ -15,6 +15,7 @@ apps: parts: kubectl: plugin: dump + build-attributes: [no-patchelf] source: . prepare: | set -eu diff --git a/snap/kubefed.yaml b/snap/kubefed.yaml index 648a8b10fa7..21b0d56951e 100644 --- a/snap/kubefed.yaml +++ b/snap/kubefed.yaml @@ -15,6 +15,7 @@ apps: parts: kubefed: plugin: dump + build-attributes: [no-patchelf] source: . prepare: | set -eu diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index 2a50473aedc..2bd8bd2fe9c 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -23,6 +23,7 @@ parts: kubelet: plugin: dump source: . + build-attributes: [no-patchelf] prepare: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubelet . diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml index 7f0838aa733..cb14aac4edd 100644 --- a/snap/kubernetes-test.yaml +++ b/snap/kubernetes-test.yaml @@ -20,6 +20,7 @@ parts: kubernetes-test: plugin: dump source: . + build-attributes: [no-patchelf] prepare: | set -eu From cbd379d4d559fd2a0e806821ba5155c43bc17f79 Mon Sep 17 00:00:00 2001 From: Cory Johns Date: Tue, 24 Apr 2018 09:33:17 -0400 Subject: [PATCH 16/34] Source /root/cdk/kube.env in daemon wrappers (#19) In order to pass env vars to the daemons in a generic fashion, this sources the /root/cdk/kube.env file if it exists. --- snap/kube-apiserver.yaml | 3 ++- snap/kube-apiserver/kube-apiserver-wrapper | 10 ++++++++++ .../kube-controller-manager-wrapper | 6 ++++++ snap/kube-proxy/kube-proxy-wrapper | 6 ++++++ snap/kube-scheduler.yaml | 3 ++- snap/kube-scheduler/kube-scheduler-wrapper | 10 ++++++++++ snap/kubelet/kubelet-wrapper | 6 ++++++ 7 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 snap/kube-apiserver/kube-apiserver-wrapper create mode 100755 snap/kube-scheduler/kube-scheduler-wrapper diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml index 4581c6215d0..7fbc90fad99 100644 --- a/snap/kube-apiserver.yaml +++ b/snap/kube-apiserver.yaml @@ -8,7 +8,7 @@ confinement: strict apps: daemon: - command: run-with-config-args kube-apiserver + command: run-with-config-args kube-apiserver-wrapper daemon: simple plugs: - home @@ -28,4 +28,5 @@ parts: set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-apiserver . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + cp $KUBE_SNAP_ROOT/kube-apiserver/kube-apiserver-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-apiserver diff --git a/snap/kube-apiserver/kube-apiserver-wrapper b/snap/kube-apiserver/kube-apiserver-wrapper new file mode 100755 index 00000000000..0116e26f2d6 --- /dev/null +++ b/snap/kube-apiserver/kube-apiserver-wrapper @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +if [ -e /root/cdk/kube.env ]; then + set -a # enable auto-export + . /root/cdk/kube.env + set +a # disable auto-export +fi + +exec "$SNAP/kube-apiserver" "$@" diff --git a/snap/kube-controller-manager/kube-controller-manager-wrapper b/snap/kube-controller-manager/kube-controller-manager-wrapper index ea3eedc5f1f..d85aeebcdd8 100755 --- a/snap/kube-controller-manager/kube-controller-manager-wrapper +++ b/snap/kube-controller-manager/kube-controller-manager-wrapper @@ -4,4 +4,10 @@ set -eu # Set CEPH_CONF so `rbd` doesn't try to look in /etc/ceph and error out export CEPH_CONF="$SNAP_USER_DATA/ceph/ceph.conf" +if [ -e /root/cdk/kube.env ]; then + set -a # enable auto-export + . /root/cdk/kube.env + set +a # disable auto-export +fi + exec "$SNAP/kube-controller-manager" "$@" diff --git a/snap/kube-proxy/kube-proxy-wrapper b/snap/kube-proxy/kube-proxy-wrapper index d6af0704c08..a01e1656d3a 100755 --- a/snap/kube-proxy/kube-proxy-wrapper +++ b/snap/kube-proxy/kube-proxy-wrapper @@ -3,4 +3,10 @@ set -eu export PATH=$PATH:$SNAP/usr/sbin +if [ -e /root/cdk/kube.env ]; then + set -a # enable auto-export + . /root/cdk/kube.env + set +a # disable auto-export +fi + exec "$SNAP/kube-proxy" "$@" diff --git a/snap/kube-scheduler.yaml b/snap/kube-scheduler.yaml index d5100d4b398..ab78f967855 100644 --- a/snap/kube-scheduler.yaml +++ b/snap/kube-scheduler.yaml @@ -10,7 +10,7 @@ confinement: strict apps: daemon: - command: run-with-config-args kube-scheduler + command: run-with-config-args kube-scheduler-wrapper daemon: simple plugs: - network @@ -30,4 +30,5 @@ parts: set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-scheduler . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . + cp $KUBE_SNAP_ROOT/kube-scheduler/kube-scheduler-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-scheduler diff --git a/snap/kube-scheduler/kube-scheduler-wrapper b/snap/kube-scheduler/kube-scheduler-wrapper new file mode 100755 index 00000000000..e681bc02040 --- /dev/null +++ b/snap/kube-scheduler/kube-scheduler-wrapper @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +if [ -e /root/cdk/kube.env ]; then + set -a # enable auto-export + . /root/cdk/kube.env + set +a # disable auto-export +fi + +exec "$SNAP/kube-scheduler" "$@" diff --git a/snap/kubelet/kubelet-wrapper b/snap/kubelet/kubelet-wrapper index 76c128515a5..b0e73366828 100755 --- a/snap/kubelet/kubelet-wrapper +++ b/snap/kubelet/kubelet-wrapper @@ -3,4 +3,10 @@ set -eu export HOME="/root" +if [ -e /root/cdk/kube.env ]; then + set -a # enable auto-export + . /root/cdk/kube.env + set +a # disable auto-export +fi + exec "$SNAP/kubelet" "$@" From 141172c216479ed09f655d2f845d04b3acda63fa Mon Sep 17 00:00:00 2001 From: Cory Johns Date: Wed, 25 Apr 2018 11:14:40 -0400 Subject: [PATCH 17/34] Update wrappers to use $SNAP_COMMON/environment per review (#20) --- snap/kube-apiserver/kube-apiserver-wrapper | 4 ++-- snap/kube-controller-manager/kube-controller-manager-wrapper | 4 ++-- snap/kube-proxy/kube-proxy-wrapper | 4 ++-- snap/kube-scheduler/kube-scheduler-wrapper | 4 ++-- snap/kubelet/kubelet-wrapper | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/snap/kube-apiserver/kube-apiserver-wrapper b/snap/kube-apiserver/kube-apiserver-wrapper index 0116e26f2d6..8ccb66c2b2e 100755 --- a/snap/kube-apiserver/kube-apiserver-wrapper +++ b/snap/kube-apiserver/kube-apiserver-wrapper @@ -1,9 +1,9 @@ #!/bin/sh set -eu -if [ -e /root/cdk/kube.env ]; then +if [ -e "$SNAP_COMMON/environment" ]; then set -a # enable auto-export - . /root/cdk/kube.env + . "$SNAP_COMMON/environment" set +a # disable auto-export fi diff --git a/snap/kube-controller-manager/kube-controller-manager-wrapper b/snap/kube-controller-manager/kube-controller-manager-wrapper index d85aeebcdd8..8ceb4298079 100755 --- a/snap/kube-controller-manager/kube-controller-manager-wrapper +++ b/snap/kube-controller-manager/kube-controller-manager-wrapper @@ -4,9 +4,9 @@ set -eu # Set CEPH_CONF so `rbd` doesn't try to look in /etc/ceph and error out export CEPH_CONF="$SNAP_USER_DATA/ceph/ceph.conf" -if [ -e /root/cdk/kube.env ]; then +if [ -e "$SNAP_COMMON/environment" ]; then set -a # enable auto-export - . /root/cdk/kube.env + . "$SNAP_COMMON/environment" set +a # disable auto-export fi diff --git a/snap/kube-proxy/kube-proxy-wrapper b/snap/kube-proxy/kube-proxy-wrapper index a01e1656d3a..4c568313b74 100755 --- a/snap/kube-proxy/kube-proxy-wrapper +++ b/snap/kube-proxy/kube-proxy-wrapper @@ -3,9 +3,9 @@ set -eu export PATH=$PATH:$SNAP/usr/sbin -if [ -e /root/cdk/kube.env ]; then +if [ -e "$SNAP_COMMON/environment" ]; then set -a # enable auto-export - . /root/cdk/kube.env + . "$SNAP_COMMON/environment" set +a # disable auto-export fi diff --git a/snap/kube-scheduler/kube-scheduler-wrapper b/snap/kube-scheduler/kube-scheduler-wrapper index e681bc02040..8b5975c7550 100755 --- a/snap/kube-scheduler/kube-scheduler-wrapper +++ b/snap/kube-scheduler/kube-scheduler-wrapper @@ -1,9 +1,9 @@ #!/bin/sh set -eu -if [ -e /root/cdk/kube.env ]; then +if [ -e "$SNAP_COMMON/environment" ]; then set -a # enable auto-export - . /root/cdk/kube.env + . "$SNAP_COMMON/environment" set +a # disable auto-export fi diff --git a/snap/kubelet/kubelet-wrapper b/snap/kubelet/kubelet-wrapper index b0e73366828..904f89092ba 100755 --- a/snap/kubelet/kubelet-wrapper +++ b/snap/kubelet/kubelet-wrapper @@ -3,9 +3,9 @@ set -eu export HOME="/root" -if [ -e /root/cdk/kube.env ]; then +if [ -e "$SNAP_COMMON/environment" ]; then set -a # enable auto-export - . /root/cdk/kube.env + . "$SNAP_COMMON/environment" set +a # disable auto-export fi From 4156f5fb647b1713d9bef1fd43b4e6760c6a5078 Mon Sep 17 00:00:00 2001 From: Kevin W Monroe Date: Thu, 31 May 2018 13:55:15 -0500 Subject: [PATCH 18/34] support building snap variants (#21) We need to be able to build snaps with a suffix. These are identical to our normal snap builds, but allow us to have a variation in the store, like 'kubectl-foo'. This makes it possible to keep variants on different versions without having a bunch of channels muddying up the primary 'kubectl' snap. --- snap/build-scripts/build | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/snap/build-scripts/build b/snap/build-scripts/build index b2e076bddf1..f9bd9d0dba3 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -43,8 +43,10 @@ export KUBE_SNAP_BINS="$(readlink -f $KUBE_SNAP_BINS)" for app in $apps; do for arch in $architectures; do - echo "Building $app $KUBE_VERSION for $arch from $KUBE_SNAP_BINS" + # Add -suffix if it's set + snap_name="${app}${SNAP_SUFFIX:+-${SNAP_SUFFIX}}" + echo "Building $snap_name $KUBE_VERSION for $arch from $KUBE_SNAP_BINS" build_dir=build/$app rm -rf $build_dir mkdir -p $build_dir @@ -56,8 +58,11 @@ for app in $apps; do ) export SNAP_ARCH="${kube_arch_to_snap_arch[$arch]:-$arch}" - sed "s/\$KUBE_VERSION/${KUBE_VERSION:1}/g" $app.yaml > $build_dir/snapcraft.yaml - sed -i "s/\$SNAP_ARCH/$SNAP_ARCH/g" $build_dir/snapcraft.yaml + # replace the name (in case we have a suffix), version (stripping the 'v'), + # and arch in our $app.yaml. + sed -e "s/name: $app/name: $snap_name/g" \ + -e "s/\$KUBE_VERSION/${KUBE_VERSION:1}/g" \ + -e "s/\$SNAP_ARCH/$SNAP_ARCH/g" $app.yaml > $build_dir/snapcraft.yaml (cd $build_dir && snapcraft) mv $build_dir/*.snap build From bceacb1913302b4628dcec7ef06d9892b194c285 Mon Sep 17 00:00:00 2001 From: Mike Wilson Date: Thu, 7 Jun 2018 10:51:30 -0700 Subject: [PATCH 19/34] prepare -> override-build (#23) --- snap/kube-apiserver.yaml | 2 +- snap/kube-controller-manager.yaml | 2 +- snap/kube-proxy.yaml | 2 +- snap/kube-scheduler.yaml | 2 +- snap/kubeadm.yaml | 2 +- snap/kubectl.yaml | 2 +- snap/kubefed.yaml | 2 +- snap/kubelet.yaml | 2 +- snap/kubernetes-test.yaml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml index 7fbc90fad99..8f747310849 100644 --- a/snap/kube-apiserver.yaml +++ b/snap/kube-apiserver.yaml @@ -24,7 +24,7 @@ parts: kube-apiserver: plugin: dump source: . - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-apiserver . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index ffd86df4372..9951b00c864 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -26,7 +26,7 @@ parts: source: . stage-packages: - ceph-common:$SNAP_ARCH - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-controller-manager . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml index aade8dec801..49b6fa9ecfd 100644 --- a/snap/kube-proxy.yaml +++ b/snap/kube-proxy.yaml @@ -27,7 +27,7 @@ parts: source: . stage-packages: - conntrack:$SNAP_ARCH - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-proxy . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . diff --git a/snap/kube-scheduler.yaml b/snap/kube-scheduler.yaml index ab78f967855..9967808596d 100644 --- a/snap/kube-scheduler.yaml +++ b/snap/kube-scheduler.yaml @@ -26,7 +26,7 @@ parts: kube-scheduler: plugin: dump source: . - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kube-scheduler . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . diff --git a/snap/kubeadm.yaml b/snap/kubeadm.yaml index cf09e6a31d9..ba0a3669cce 100644 --- a/snap/kubeadm.yaml +++ b/snap/kubeadm.yaml @@ -16,6 +16,6 @@ parts: plugin: dump build-attributes: [no-patchelf] source: . - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubeadm . diff --git a/snap/kubectl.yaml b/snap/kubectl.yaml index d4be862be29..f4a5191c8d2 100644 --- a/snap/kubectl.yaml +++ b/snap/kubectl.yaml @@ -17,6 +17,6 @@ parts: plugin: dump build-attributes: [no-patchelf] source: . - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubectl . diff --git a/snap/kubefed.yaml b/snap/kubefed.yaml index 21b0d56951e..a2a66192ae6 100644 --- a/snap/kubefed.yaml +++ b/snap/kubefed.yaml @@ -17,6 +17,6 @@ parts: plugin: dump build-attributes: [no-patchelf] source: . - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubefed . diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index 2bd8bd2fe9c..631d1f3bff4 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -24,7 +24,7 @@ parts: plugin: dump source: . build-attributes: [no-patchelf] - prepare: | + override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubelet . cp $KUBE_SNAP_ROOT/shared/run-with-config-args . diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml index cb14aac4edd..cc2fcb1a482 100644 --- a/snap/kubernetes-test.yaml +++ b/snap/kubernetes-test.yaml @@ -21,7 +21,7 @@ parts: plugin: dump source: . build-attributes: [no-patchelf] - prepare: | + override-build: | set -eu mkdir build-temp From f5c46cf18690922c89d982592a3d8466b0752e7c Mon Sep 17 00:00:00 2001 From: Mike Wilson Date: Thu, 7 Jun 2018 12:07:08 -0700 Subject: [PATCH 20/34] Adding snapcraftctl build to the build-override steps (#24) --- snap/kube-apiserver.yaml | 2 ++ snap/kube-controller-manager.yaml | 2 ++ snap/kube-proxy.yaml | 2 ++ snap/kube-scheduler.yaml | 2 ++ snap/kubeadm.yaml | 2 ++ snap/kubectl.yaml | 2 ++ snap/kubefed.yaml | 2 ++ snap/kubelet.yaml | 2 ++ snap/kubernetes-test.yaml | 2 ++ 9 files changed, 18 insertions(+) diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml index 8f747310849..46d42523378 100644 --- a/snap/kube-apiserver.yaml +++ b/snap/kube-apiserver.yaml @@ -30,3 +30,5 @@ parts: cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kube-apiserver/kube-apiserver-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-apiserver + + snapcraftctl build \ No newline at end of file diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index 9951b00c864..3856559900f 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -32,3 +32,5 @@ parts: cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kube-controller-manager/kube-controller-manager-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager + + snapcraftctl build \ No newline at end of file diff --git a/snap/kube-proxy.yaml b/snap/kube-proxy.yaml index 49b6fa9ecfd..638f0e11ead 100644 --- a/snap/kube-proxy.yaml +++ b/snap/kube-proxy.yaml @@ -33,3 +33,5 @@ parts: cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kube-proxy/kube-proxy-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-proxy + + snapcraftctl build \ No newline at end of file diff --git a/snap/kube-scheduler.yaml b/snap/kube-scheduler.yaml index 9967808596d..69cd82ca002 100644 --- a/snap/kube-scheduler.yaml +++ b/snap/kube-scheduler.yaml @@ -32,3 +32,5 @@ parts: cp $KUBE_SNAP_ROOT/shared/run-with-config-args . cp $KUBE_SNAP_ROOT/kube-scheduler/kube-scheduler-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-scheduler + + snapcraftctl build \ No newline at end of file diff --git a/snap/kubeadm.yaml b/snap/kubeadm.yaml index ba0a3669cce..f97b72c5c23 100644 --- a/snap/kubeadm.yaml +++ b/snap/kubeadm.yaml @@ -19,3 +19,5 @@ parts: override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubeadm . + + snapcraftctl build \ No newline at end of file diff --git a/snap/kubectl.yaml b/snap/kubectl.yaml index f4a5191c8d2..1da98b2e172 100644 --- a/snap/kubectl.yaml +++ b/snap/kubectl.yaml @@ -20,3 +20,5 @@ parts: override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubectl . + + snapcraftctl build \ No newline at end of file diff --git a/snap/kubefed.yaml b/snap/kubefed.yaml index a2a66192ae6..21b87f35e58 100644 --- a/snap/kubefed.yaml +++ b/snap/kubefed.yaml @@ -20,3 +20,5 @@ parts: override-build: | set -eu cp $KUBE_SNAP_BINS/$KUBE_ARCH/kubefed . + + snapcraftctl build \ No newline at end of file diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index 631d1f3bff4..79966840c52 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -154,3 +154,5 @@ parts: ensure_arg string tls-cert-file ensure_arg string tls-private-key-file ensure_arg string volume-stats-agg-period + + snapcraftctl build \ No newline at end of file diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml index cc2fcb1a482..6c8e2b93ac5 100644 --- a/snap/kubernetes-test.yaml +++ b/snap/kubernetes-test.yaml @@ -35,3 +35,5 @@ parts: chmod +rx ginkgo cp "$KUBE_SNAP_ROOT/kubernetes-test/ginkgo-e2e" . + + snapcraftctl build \ No newline at end of file From dd9238e9be7873b47eb97c21e22c706056869c53 Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Mon, 18 Jun 2018 17:34:21 +0300 Subject: [PATCH 21/34] Making sure service-account-private-key-file arg is available in kube-controller-manager (#25) --- snap/kube-controller-manager.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index 3856559900f..6be4f67a756 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -33,4 +33,21 @@ parts: cp $KUBE_SNAP_ROOT/kube-controller-manager/kube-controller-manager-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager - snapcraftctl build \ No newline at end of file + # By mistake --service-account-private-key-file was marked as deprecated + # https://github.com/kubernetes/kubernetes/pull/62722 + # Should be fixed soon by https://github.com/kubernetes/kubernetes/pull/60270/files#diff-fc9db90cc6b68d7c3ca838a8512447e9R61 + # But until then, we need to do 1.11 testing + ensure_arg() { + type="$1" + config="$2" + if ! grep "^config-arg.* $config\$" meta/hooks/configure > /dev/null; then + if [ "$type" = "bool" ]; then + echo "config-arg-bool $config" >> meta/hooks/configure + else + echo "config-arg $config" >> meta/hooks/configure + fi + fi + } + ensure_arg string service-account-private-key-file + + snapcraftctl build From d4d3c45658fcc54193e60e03f6d5409d42b768eb Mon Sep 17 00:00:00 2001 From: George Kraft Date: Tue, 3 Jul 2018 01:46:04 -0500 Subject: [PATCH 22/34] Fix configure hook incorrectly encoding some args (#26) --- snap/shared/generate-configure-hook | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook index 2118abae2d3..a7a81bf6985 100755 --- a/snap/shared/generate-configure-hook +++ b/snap/shared/generate-configure-hook @@ -19,9 +19,9 @@ function option-to-key { function config-arg { option=$1 key=$(option-to-key $option) - value=$(snapctl get -t $key) - if [ "$value" != 'null' ]; then - echo "--$option $value" >> $SNAP_DATA/args + value=$(snapctl get $key) + if [ -n "$value" ]; then + echo "--$option=\"$value\"" >> $SNAP_DATA/args fi } From 697052e40ed63c61a035b83c037f6fa86c2a705c Mon Sep 17 00:00:00 2001 From: George Kraft Date: Wed, 8 Aug 2018 02:25:19 -0500 Subject: [PATCH 23/34] Support dynamic kubelet config with restart-condition: always (#27) --- snap/kubelet.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index 79966840c52..2cd7ec77ed8 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -16,6 +16,7 @@ apps: daemon: command: run-with-config-args kubelet-wrapper daemon: simple + restart-condition: always # needed for Dynamic Kubelet Config support kubelet: command: kubelet @@ -155,4 +156,4 @@ parts: ensure_arg string tls-private-key-file ensure_arg string volume-stats-agg-period - snapcraftctl build \ No newline at end of file + snapcraftctl build From 39920212dd929e506f046b4d673568afaf6a34df Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Tue, 11 Sep 2018 13:32:54 -0400 Subject: [PATCH 24/34] Add snapcraft cleanbuild (#28) This makes sure snaps can still be built on bionic hosts. Signed-off-by: Adam Stokes --- snap/build-scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/build-scripts/build b/snap/build-scripts/build index f9bd9d0dba3..88130df9bac 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -64,7 +64,7 @@ for app in $apps; do -e "s/\$KUBE_VERSION/${KUBE_VERSION:1}/g" \ -e "s/\$SNAP_ARCH/$SNAP_ARCH/g" $app.yaml > $build_dir/snapcraft.yaml - (cd $build_dir && snapcraft) + (cd $build_dir && snapcraft cleanbuild) mv $build_dir/*.snap build done done From 01e32d189176f2ef10893eb9287e58c4c997c77d Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Wed, 12 Sep 2018 11:17:39 -0400 Subject: [PATCH 25/34] Fix docker builds (#29) * Fix docker builds This updates to a recent stable container for building snaps via docker. Signed-off-by: Adam Stokes * Include file in container, link magic db Signed-off-by: Adam Stokes --- snap/build-scripts/build | 2 +- snap/docker-build.sh | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/snap/build-scripts/build b/snap/build-scripts/build index 88130df9bac..f9bd9d0dba3 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -64,7 +64,7 @@ for app in $apps; do -e "s/\$KUBE_VERSION/${KUBE_VERSION:1}/g" \ -e "s/\$SNAP_ARCH/$SNAP_ARCH/g" $app.yaml > $build_dir/snapcraft.yaml - (cd $build_dir && snapcraft cleanbuild) + (cd $build_dir && snapcraft) mv $build_dir/*.snap build done done diff --git a/snap/docker-build.sh b/snap/docker-build.sh index 9d7efed128a..113ba4f2f19 100755 --- a/snap/docker-build.sh +++ b/snap/docker-build.sh @@ -1,4 +1,13 @@ #!/bin/bash -docker run --rm -v $PWD:/root/snap -w /root/snap -e SNAPCRAFT_SETUP_CORE=1\ - snapcraft/xenial-amd64 make "$@" +docker run --rm -v "$PWD":/root/snap -w /root/snap \ + -e SNAPCRAFT_SETUP_CORE=1 \ + -e KUBE_ARCH=amd64 \ + -e KUBE_VERSION=$(curl -L https://dl.k8s.io/release/stable.txt) \ + -v /usr/bin/curl:/usr/bin/curl \ + -v /usr/bin/make:/usr/bin/make \ + -v /usr/share/misc/magic.mgc:/usr/share/misc/magic.mgc \ + -v /usr/bin/file:/usr/bin/file \ + -v /usr/lib/x86_64-linux-gnu/libmagic.so.1:/usr/lib/x86_64-linux-gnu/libmagic.so.1 \ + snapcore/snapcraft:stable \ + ./build-scripts/build "$@" From 34994b1b975b0ec3b4f5ee64717e0c407db1f685 Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Wed, 12 Sep 2018 11:35:24 -0400 Subject: [PATCH 26/34] Update Makefile to use docker-build (#30) Signed-off-by: Adam Stokes --- snap/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/Makefile b/snap/Makefile index b15118239ac..b4f04ffb312 100644 --- a/snap/Makefile +++ b/snap/Makefile @@ -7,7 +7,7 @@ endif targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubernetes-test -build = ./build-scripts/build +build = ./docker-build.sh .PHONY: $(targets) From f08f2e2064d6c3ea5da3e0eede0bb8049105d3a0 Mon Sep 17 00:00:00 2001 From: George Kraft Date: Wed, 12 Sep 2018 12:47:46 -0500 Subject: [PATCH 27/34] Update README to not use docker-build.sh (#31) --- snap/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/snap/README.md b/snap/README.md index 61b7f6ec06f..2fbf735c35d 100644 --- a/snap/README.md +++ b/snap/README.md @@ -2,15 +2,15 @@ ## Build everything -Run `./docker-build.sh` here and check for the results in the `build/` directory. +Run `make` here and check for the results in the `build/` directory. ## Build one snap -To build a specific snap, run `./docker-build.sh` with the name of the snap, e.g., for +To build a specific snap, run `make` with the name of the snap, e.g., for kubectl: ```sh -$ ./docker-build.sh kubectl +$ make kubectl ``` The result will again be in the `build/` directory. @@ -20,13 +20,13 @@ The result will again be in the `build/` directory. Set KUBE_VERSION to build the snaps with a particular Kubernetes version, e.g., ```sh -$ ./docker-build.sh KUBE_VERSION=v1.5.5 +$ make KUBE_VERSION=v1.5.5 ``` ## Cleaning up -Simply run `./docker-build.sh clean` to remove everything except downloaded resources: +Simply run `make clean` to remove everything except downloaded resources: ```sh -$ ./docker-build.sh clean +$ make clean ``` From f5f84902d809abf954f853d8d2a1dcb73daa9a46 Mon Sep 17 00:00:00 2001 From: George Kraft Date: Thu, 13 Sep 2018 19:34:37 -0500 Subject: [PATCH 28/34] Fix KUBE_VERSION and KUBE_ARCH being ignored (#32) @battlemidget Looks like somewhere along the way we lost the ability to pass KUBE_VERSION and KUBE_ARCH through to the build script. It just always builds the latest stable Kubernetes (currently v1.11.3). This PR should fix it. I also moved the docker-build.sh script into build-scripts/ to tidy up a bit, hope that's cool. --- snap/Makefile | 2 +- snap/{docker-build.sh => build-scripts/docker-build} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename snap/{docker-build.sh => build-scripts/docker-build} (81%) diff --git a/snap/Makefile b/snap/Makefile index b4f04ffb312..4a0d7369733 100644 --- a/snap/Makefile +++ b/snap/Makefile @@ -7,7 +7,7 @@ endif targets = kubectl kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy kubeadm kubernetes-test -build = ./docker-build.sh +build = ./build-scripts/docker-build .PHONY: $(targets) diff --git a/snap/docker-build.sh b/snap/build-scripts/docker-build similarity index 81% rename from snap/docker-build.sh rename to snap/build-scripts/docker-build index 113ba4f2f19..7786f0e0988 100755 --- a/snap/docker-build.sh +++ b/snap/build-scripts/docker-build @@ -2,8 +2,8 @@ docker run --rm -v "$PWD":/root/snap -w /root/snap \ -e SNAPCRAFT_SETUP_CORE=1 \ - -e KUBE_ARCH=amd64 \ - -e KUBE_VERSION=$(curl -L https://dl.k8s.io/release/stable.txt) \ + -e KUBE_ARCH=$KUBE_ARCH \ + -e KUBE_VERSION=$KUBE_VERSION \ -v /usr/bin/curl:/usr/bin/curl \ -v /usr/bin/make:/usr/bin/make \ -v /usr/share/misc/magic.mgc:/usr/share/misc/magic.mgc \ From 3e9af3a9a6317e9d86d873454e30c0e41e7b5360 Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Fri, 14 Sep 2018 12:26:28 -0400 Subject: [PATCH 29/34] Add Dockerfile and update build script to use that (#33) Run with: cd release/snap KUBE_ARCH=amd64 KUBE_VERSION=v1.11.3 ./build-scripts/docker-build kubectl Signed-off-by: Adam Stokes --- snap/Dockerfile | 10 ++++++++++ snap/build-scripts/build | 2 +- snap/build-scripts/docker-build | 12 +++--------- 3 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 snap/Dockerfile diff --git a/snap/Dockerfile b/snap/Dockerfile new file mode 100644 index 00000000000..71df7d3a950 --- /dev/null +++ b/snap/Dockerfile @@ -0,0 +1,10 @@ +FROM snapcore/snapcraft:stable +ADD . /code +WORKDIR /code +ENV SNAPCRAFT_SETUP_CORE=1 +ENV KUBE_ARCH=$KUBE_ARCH +ENV KUBE_VERSION=$KUBE_VERSION +RUN apt-get update +RUN apt-get -y install wget curl file make +ENTRYPOINT ["./build-scripts/build"] +CMD ["$@"] diff --git a/snap/build-scripts/build b/snap/build-scripts/build index f9bd9d0dba3..e0954859d70 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -1,5 +1,5 @@ #!/bin/bash -set -eu +set -eux apps="$@" architectures="$KUBE_ARCH" diff --git a/snap/build-scripts/docker-build b/snap/build-scripts/docker-build index 7786f0e0988..17e053afb75 100755 --- a/snap/build-scripts/docker-build +++ b/snap/build-scripts/docker-build @@ -1,13 +1,7 @@ #!/bin/bash -docker run --rm -v "$PWD":/root/snap -w /root/snap \ - -e SNAPCRAFT_SETUP_CORE=1 \ +docker build -t docker-build . +docker run --rm -v $PWD/build:/code/build \ -e KUBE_ARCH=$KUBE_ARCH \ -e KUBE_VERSION=$KUBE_VERSION \ - -v /usr/bin/curl:/usr/bin/curl \ - -v /usr/bin/make:/usr/bin/make \ - -v /usr/share/misc/magic.mgc:/usr/share/misc/magic.mgc \ - -v /usr/bin/file:/usr/bin/file \ - -v /usr/lib/x86_64-linux-gnu/libmagic.so.1:/usr/lib/x86_64-linux-gnu/libmagic.so.1 \ - snapcore/snapcraft:stable \ - ./build-scripts/build "$@" + docker-build "$@" From 80e586850823b84efd754b94d65544927fd9e01e Mon Sep 17 00:00:00 2001 From: George Kraft Date: Tue, 2 Oct 2018 12:24:45 -0500 Subject: [PATCH 30/34] Add missing "v" arg to kube-apiserver and kube-controller-manager (#34) --- snap/kube-apiserver.yaml | 6 +- snap/kube-controller-manager.yaml | 17 +- snap/kubelet.yaml | 226 ++++++++++++-------------- snap/shared/add-arg-to-configure-hook | 12 ++ 4 files changed, 130 insertions(+), 131 deletions(-) create mode 100755 snap/shared/add-arg-to-configure-hook diff --git a/snap/kube-apiserver.yaml b/snap/kube-apiserver.yaml index 46d42523378..79e31f1c4e5 100644 --- a/snap/kube-apiserver.yaml +++ b/snap/kube-apiserver.yaml @@ -31,4 +31,8 @@ parts: cp $KUBE_SNAP_ROOT/kube-apiserver/kube-apiserver-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-apiserver - snapcraftctl build \ No newline at end of file + # --v is missing from help output in 1.12 + alias add-arg=$KUBE_SNAP_ROOT/shared/add-arg-to-configure-hook + add-arg string v + + snapcraftctl build diff --git a/snap/kube-controller-manager.yaml b/snap/kube-controller-manager.yaml index 6be4f67a756..1edf1af877a 100644 --- a/snap/kube-controller-manager.yaml +++ b/snap/kube-controller-manager.yaml @@ -33,21 +33,14 @@ parts: cp $KUBE_SNAP_ROOT/kube-controller-manager/kube-controller-manager-wrapper . $KUBE_SNAP_ROOT/shared/generate-configure-hook kube-controller-manager + # --v is missing from help output in 1.12 + alias add-arg=$KUBE_SNAP_ROOT/shared/add-arg-to-configure-hook + add-arg string v + # By mistake --service-account-private-key-file was marked as deprecated # https://github.com/kubernetes/kubernetes/pull/62722 # Should be fixed soon by https://github.com/kubernetes/kubernetes/pull/60270/files#diff-fc9db90cc6b68d7c3ca838a8512447e9R61 # But until then, we need to do 1.11 testing - ensure_arg() { - type="$1" - config="$2" - if ! grep "^config-arg.* $config\$" meta/hooks/configure > /dev/null; then - if [ "$type" = "bool" ]; then - echo "config-arg-bool $config" >> meta/hooks/configure - else - echo "config-arg $config" >> meta/hooks/configure - fi - fi - } - ensure_arg string service-account-private-key-file + add-arg string service-account-private-key-file snapcraftctl build diff --git a/snap/kubelet.yaml b/snap/kubelet.yaml index 2cd7ec77ed8..300cd7cef40 100644 --- a/snap/kubelet.yaml +++ b/snap/kubelet.yaml @@ -35,125 +35,115 @@ parts: # Many of the args in kubelet became hidden with the introduction of # KubeletConfiguration. We need to include them for backward # compatibility. - ensure_arg() { - type="$1" - config="$2" - if ! grep "^config-arg.* $config\$" meta/hooks/configure > /dev/null; then - if [ "$type" = "bool" ]; then - echo "config-arg-bool $config" >> meta/hooks/configure - else - echo "config-arg $config" >> meta/hooks/configure - fi - fi - } + alias add-arg=$KUBE_SNAP_ROOT/shared/add-arg-to-configure-hook # Hard-coded args generated from a diff of v1.9.6 -> v1.10.0 - ensure_arg string address - ensure_arg bool allow-privileged - ensure_arg bool anonymous-auth - ensure_arg string application-metrics-count-limit - ensure_arg bool authentication-token-webhook - ensure_arg string authentication-token-webhook-cache-ttl - ensure_arg string authorization-mode - ensure_arg string authorization-webhook-cache-authorized-ttl - ensure_arg string authorization-webhook-cache-unauthorized-ttl - ensure_arg string boot-id-file - ensure_arg string cadvisor-port - ensure_arg string cgroup-driver - ensure_arg string cgroup-root - ensure_arg bool cgroups-per-qos - ensure_arg string client-ca-file - ensure_arg string cloud-provider-gce-lb-src-cidrs - ensure_arg string cluster-dns - ensure_arg string cluster-domain - ensure_arg string container-hints - ensure_arg string containerd - ensure_arg bool contention-profiling - ensure_arg bool cpu-cfs-quota - ensure_arg string cpu-manager-policy - ensure_arg string cpu-manager-reconcile-period - ensure_arg string docker - ensure_arg bool docker-disable-shared-pid - ensure_arg string docker-env-metadata-whitelist - ensure_arg bool docker-only - ensure_arg bool docker-tls - ensure_arg string docker-tls-ca - ensure_arg string docker-tls-cert - ensure_arg string docker-tls-key - ensure_arg bool enable-controller-attach-detach - ensure_arg bool enable-debugging-handlers - ensure_arg bool enable-load-reader - ensure_arg string enforce-node-allocatable - ensure_arg string event-burst - ensure_arg string event-qps - ensure_arg string event-storage-age-limit - ensure_arg string event-storage-event-limit - ensure_arg string eviction-hard - ensure_arg string eviction-max-pod-grace-period - ensure_arg string eviction-minimum-reclaim - ensure_arg string eviction-pressure-transition-period - ensure_arg string eviction-soft - ensure_arg string eviction-soft-grace-period - ensure_arg bool fail-swap-on - ensure_arg string feature-gates - ensure_arg string file-check-frequency - ensure_arg string global-housekeeping-interval - ensure_arg string google-json-key - ensure_arg string hairpin-mode - ensure_arg string healthz-bind-address - ensure_arg string healthz-port - ensure_arg string host-ipc-sources - ensure_arg string host-network-sources - ensure_arg string host-pid-sources - ensure_arg string http-check-frequency - ensure_arg string image-gc-high-threshold - ensure_arg string image-gc-low-threshold - ensure_arg string init-config-dir - ensure_arg string iptables-drop-bit - ensure_arg string iptables-masquerade-bit - ensure_arg string kube-api-burst - ensure_arg string kube-api-content-type - ensure_arg string kube-api-qps - ensure_arg string kube-reserved - ensure_arg string kube-reserved-cgroup - ensure_arg string kubelet-cgroups - ensure_arg bool log-cadvisor-usage - ensure_arg string machine-id-file - ensure_arg bool make-iptables-util-chains - ensure_arg string manifest-url - ensure_arg string manifest-url-header - ensure_arg string max-open-files - ensure_arg string max-pods - ensure_arg string minimum-image-ttl-duration - ensure_arg string node-status-update-frequency - ensure_arg string oom-score-adj - ensure_arg string pod-cidr - ensure_arg string pod-manifest-path - ensure_arg string pods-per-core - ensure_arg string port - ensure_arg bool protect-kernel-defaults - ensure_arg string read-only-port - ensure_arg string registry-burst - ensure_arg string registry-qps - ensure_arg string resolv-conf - ensure_arg string rkt-api-endpoint - ensure_arg string rkt-path - ensure_arg string runtime-request-timeout - ensure_arg bool serialize-image-pulls - ensure_arg string storage-driver-buffer-duration - ensure_arg string storage-driver-db - ensure_arg string storage-driver-host - ensure_arg string storage-driver-password - ensure_arg bool storage-driver-secure - ensure_arg string storage-driver-table - ensure_arg string storage-driver-user - ensure_arg string streaming-connection-idle-timeout - ensure_arg string sync-frequency - ensure_arg string system-cgroups - ensure_arg string system-reserved - ensure_arg string system-reserved-cgroup - ensure_arg string tls-cert-file - ensure_arg string tls-private-key-file - ensure_arg string volume-stats-agg-period + add-arg string address + add-arg bool allow-privileged + add-arg bool anonymous-auth + add-arg string application-metrics-count-limit + add-arg bool authentication-token-webhook + add-arg string authentication-token-webhook-cache-ttl + add-arg string authorization-mode + add-arg string authorization-webhook-cache-authorized-ttl + add-arg string authorization-webhook-cache-unauthorized-ttl + add-arg string boot-id-file + add-arg string cadvisor-port + add-arg string cgroup-driver + add-arg string cgroup-root + add-arg bool cgroups-per-qos + add-arg string client-ca-file + add-arg string cloud-provider-gce-lb-src-cidrs + add-arg string cluster-dns + add-arg string cluster-domain + add-arg string container-hints + add-arg string containerd + add-arg bool contention-profiling + add-arg bool cpu-cfs-quota + add-arg string cpu-manager-policy + add-arg string cpu-manager-reconcile-period + add-arg string docker + add-arg bool docker-disable-shared-pid + add-arg string docker-env-metadata-whitelist + add-arg bool docker-only + add-arg bool docker-tls + add-arg string docker-tls-ca + add-arg string docker-tls-cert + add-arg string docker-tls-key + add-arg bool enable-controller-attach-detach + add-arg bool enable-debugging-handlers + add-arg bool enable-load-reader + add-arg string enforce-node-allocatable + add-arg string event-burst + add-arg string event-qps + add-arg string event-storage-age-limit + add-arg string event-storage-event-limit + add-arg string eviction-hard + add-arg string eviction-max-pod-grace-period + add-arg string eviction-minimum-reclaim + add-arg string eviction-pressure-transition-period + add-arg string eviction-soft + add-arg string eviction-soft-grace-period + add-arg bool fail-swap-on + add-arg string feature-gates + add-arg string file-check-frequency + add-arg string global-housekeeping-interval + add-arg string google-json-key + add-arg string hairpin-mode + add-arg string healthz-bind-address + add-arg string healthz-port + add-arg string host-ipc-sources + add-arg string host-network-sources + add-arg string host-pid-sources + add-arg string http-check-frequency + add-arg string image-gc-high-threshold + add-arg string image-gc-low-threshold + add-arg string init-config-dir + add-arg string iptables-drop-bit + add-arg string iptables-masquerade-bit + add-arg string kube-api-burst + add-arg string kube-api-content-type + add-arg string kube-api-qps + add-arg string kube-reserved + add-arg string kube-reserved-cgroup + add-arg string kubelet-cgroups + add-arg bool log-cadvisor-usage + add-arg string machine-id-file + add-arg bool make-iptables-util-chains + add-arg string manifest-url + add-arg string manifest-url-header + add-arg string max-open-files + add-arg string max-pods + add-arg string minimum-image-ttl-duration + add-arg string node-status-update-frequency + add-arg string oom-score-adj + add-arg string pod-cidr + add-arg string pod-manifest-path + add-arg string pods-per-core + add-arg string port + add-arg bool protect-kernel-defaults + add-arg string read-only-port + add-arg string registry-burst + add-arg string registry-qps + add-arg string resolv-conf + add-arg string rkt-api-endpoint + add-arg string rkt-path + add-arg string runtime-request-timeout + add-arg bool serialize-image-pulls + add-arg string storage-driver-buffer-duration + add-arg string storage-driver-db + add-arg string storage-driver-host + add-arg string storage-driver-password + add-arg bool storage-driver-secure + add-arg string storage-driver-table + add-arg string storage-driver-user + add-arg string streaming-connection-idle-timeout + add-arg string sync-frequency + add-arg string system-cgroups + add-arg string system-reserved + add-arg string system-reserved-cgroup + add-arg string tls-cert-file + add-arg string tls-private-key-file + add-arg string volume-stats-agg-period snapcraftctl build diff --git a/snap/shared/add-arg-to-configure-hook b/snap/shared/add-arg-to-configure-hook new file mode 100755 index 00000000000..02a9923512e --- /dev/null +++ b/snap/shared/add-arg-to-configure-hook @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eu + +type="$1" +config="$2" +if ! grep "^config-arg.* $config\$" meta/hooks/configure > /dev/null; then + if [ "$type" = "bool" ]; then + echo "config-arg-bool $config" >> meta/hooks/configure + else + echo "config-arg $config" >> meta/hooks/configure + fi +fi From bb8253735db193d9a83985b7b80d22259ebd0c6d Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Fri, 19 Oct 2018 21:49:24 -0400 Subject: [PATCH 31/34] Add support for ppc64, arm64, s390x (#35) * Add support for ppc64, arm64, s390x Signed-off-by: Adam Stokes * add make to aarch64 dockerfile Signed-off-by: Adam Stokes --- snap/Dockerfile.aarch64 | 15 +++++++++++++++ snap/Dockerfile.ppc64le | 15 +++++++++++++++ snap/Dockerfile.s390x | 15 +++++++++++++++ snap/{Dockerfile => Dockerfile.x86_64} | 0 snap/build-scripts/docker-build | 4 +++- 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 snap/Dockerfile.aarch64 create mode 100644 snap/Dockerfile.ppc64le create mode 100644 snap/Dockerfile.s390x rename snap/{Dockerfile => Dockerfile.x86_64} (100%) diff --git a/snap/Dockerfile.aarch64 b/snap/Dockerfile.aarch64 new file mode 100644 index 00000000000..07b7d4335d7 --- /dev/null +++ b/snap/Dockerfile.aarch64 @@ -0,0 +1,15 @@ +FROM arm64v8/ubuntu:xenial +RUN apt-get update && \ + apt-get dist-upgrade --yes && \ + apt-get install --yes \ + snapcraft curl file make sudo jq squashfs-tools && \ + apt-get autoclean --yes && \ + apt-get clean --yes + +ADD . /code +WORKDIR /code +ENV SNAPCRAFT_SETUP_CORE=1 +ENV KUBE_ARCH=$KUBE_ARCH +ENV KUBE_VERSION=$KUBE_VERSION +ENTRYPOINT ["./build-scripts/build"] +CMD ["$@"] diff --git a/snap/Dockerfile.ppc64le b/snap/Dockerfile.ppc64le new file mode 100644 index 00000000000..354a56d1f54 --- /dev/null +++ b/snap/Dockerfile.ppc64le @@ -0,0 +1,15 @@ +FROM ppc64le/ubuntu:xenial +RUN apt-get update && \ + apt-get dist-upgrade --yes && \ + apt-get install --yes \ + snapcraft curl file make sudo jq squashfs-tools && \ + apt-get autoclean --yes && \ + apt-get clean --yes + +ADD . /code +WORKDIR /code +ENV SNAPCRAFT_SETUP_CORE=1 +ENV KUBE_ARCH=$KUBE_ARCH +ENV KUBE_VERSION=$KUBE_VERSION +ENTRYPOINT ["./build-scripts/build"] +CMD ["$@"] diff --git a/snap/Dockerfile.s390x b/snap/Dockerfile.s390x new file mode 100644 index 00000000000..53bed322423 --- /dev/null +++ b/snap/Dockerfile.s390x @@ -0,0 +1,15 @@ +FROM s390x/ubuntu:xenial +RUN apt-get update && \ + apt-get dist-upgrade --yes && \ + apt-get install --yes \ + snapcraft curl file make sudo jq squashfs-tools && \ + apt-get autoclean --yes && \ + apt-get clean --yes + +ADD . /code +WORKDIR /code +ENV SNAPCRAFT_SETUP_CORE=1 +ENV KUBE_ARCH=$KUBE_ARCH +ENV KUBE_VERSION=$KUBE_VERSION +ENTRYPOINT ["./build-scripts/build"] +CMD ["$@"] diff --git a/snap/Dockerfile b/snap/Dockerfile.x86_64 similarity index 100% rename from snap/Dockerfile rename to snap/Dockerfile.x86_64 diff --git a/snap/build-scripts/docker-build b/snap/build-scripts/docker-build index 17e053afb75..0bf4bbf2b07 100755 --- a/snap/build-scripts/docker-build +++ b/snap/build-scripts/docker-build @@ -1,6 +1,8 @@ #!/bin/bash -docker build -t docker-build . +set -eux + +docker build -f "./Dockerfile.$(uname -m)" -t docker-build . docker run --rm -v $PWD/build:/code/build \ -e KUBE_ARCH=$KUBE_ARCH \ -e KUBE_VERSION=$KUBE_VERSION \ From 86601284488004b0c36e33056d5f86b19c7a9946 Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Tue, 12 Mar 2019 15:04:06 +0200 Subject: [PATCH 32/34] Add custom args (#38) --- snap/shared/generate-configure-hook | 1 + 1 file changed, 1 insertion(+) diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook index a7a81bf6985..d32ec6ffc94 100755 --- a/snap/shared/generate-configure-hook +++ b/snap/shared/generate-configure-hook @@ -39,6 +39,7 @@ function config-arg-bool { fi } +echo "$(snapctl get args)" >> $SNAP_DATA/args EOF ./$app -h 2>&1 | grep '\-\-' | perl -pe 's/.*?--(\S+ \S*).*/\1/' | while read line; do From 9d7566a02303b4dd843616f68c38eb9d65ae0ae4 Mon Sep 17 00:00:00 2001 From: Adam Stokes Date: Thu, 3 Sep 2020 14:09:12 -0400 Subject: [PATCH 33/34] Fix download url for kubernetes-test Signed-off-by: Adam Stokes --- snap/build-scripts/build | 6 +++--- snap/kubernetes-test.yaml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/snap/build-scripts/build b/snap/build-scripts/build index e0954859d70..0314e158e8c 100755 --- a/snap/build-scripts/build +++ b/snap/build-scripts/build @@ -12,10 +12,10 @@ if [ -z "$KUBE_SNAP_BINS" ]; then (cd $KUBE_SNAP_BINS for app in $apps; do if [ "$app" = "kubernetes-test" ]; then - echo "Fetching $app $KUBE_VERSION" + echo "Fetching https://dl.k8s.io/$KUBE_VERSION/$app-linux-$KUBE_ARCH.tar.gz" curl -LO \ - https://dl.k8s.io/${KUBE_VERSION}/${app}.tar.gz - if ! file ${app}.tar.gz 2>&1 | grep -q 'gzip'; then + https://dl.k8s.io/${KUBE_VERSION}/${app}-linux-${KUBE_ARCH}.tar.gz + if ! file ${app}-linux-${KUBE_ARCH}.tar.gz 2>&1 | grep -q 'gzip'; then echo "${app}.tar.gz is not a gzip archive" exit 1 fi diff --git a/snap/kubernetes-test.yaml b/snap/kubernetes-test.yaml index 6c8e2b93ac5..02778775941 100644 --- a/snap/kubernetes-test.yaml +++ b/snap/kubernetes-test.yaml @@ -26,9 +26,9 @@ parts: mkdir build-temp (cd build-temp - tar -xf "$KUBE_SNAP_BINS/kubernetes-test.tar.gz" - mv kubernetes/platforms/linux/$KUBE_ARCH/e2e.test .. - mv kubernetes/platforms/linux/$KUBE_ARCH/ginkgo .. + tar -xf "$KUBE_SNAP_BINS/kubernetes-test-linux-$KUBE_ARCH.tar.gz" + mv kubernetes/test/bin/e2e.test .. + mv kubernetes/test/bin/ginkgo .. ) rm -rf build-temp chmod +rx e2e.test @@ -36,4 +36,4 @@ parts: cp "$KUBE_SNAP_ROOT/kubernetes-test/ginkgo-e2e" . - snapcraftctl build \ No newline at end of file + snapcraftctl build From 525284761c7a1ece02325ae609b2ba4f29efa956 Mon Sep 17 00:00:00 2001 From: Joe Borg Date: Fri, 13 Aug 2021 16:13:24 -0400 Subject: [PATCH 34/34] Fixing grep (#39) --- snap/shared/generate-configure-hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/shared/generate-configure-hook b/snap/shared/generate-configure-hook index d32ec6ffc94..5bbb1f7344c 100755 --- a/snap/shared/generate-configure-hook +++ b/snap/shared/generate-configure-hook @@ -42,7 +42,7 @@ function config-arg-bool { echo "$(snapctl get args)" >> $SNAP_DATA/args EOF -./$app -h 2>&1 | grep '\-\-' | perl -pe 's/.*?--(\S+ \S*).*/\1/' | while read line; do +./$app -h 2>&1 | perl -ne 'print if s/^ *(-[a-zA-Z],)? *--(\S+ \S*).*/\2/' | while read line; do if [ $(echo "$line" | wc -w) -eq 2 ]; then option=$(echo "$line" | cut -d ' ' -f 1) echo "config-arg $option" >> meta/hooks/configure