mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Make the addon-manager cross-platform, change naming to binary-arch:version, remove deprecated kubectl command, add support for DaemonSets
This commit is contained in:
parent
2c471bce4e
commit
bff87ff2a7
1
cluster/addons/addon-manager/.gitignore
vendored
1
cluster/addons/addon-manager/.gitignore
vendored
@ -1 +0,0 @@
|
||||
kubectl
|
@ -12,13 +12,17 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM python:2.7-slim
|
||||
FROM BASEIMAGE
|
||||
|
||||
# If we're building for another architecture than amd64, the CROSS_BUILD_ placeholder is removed so e.g. CROSS_BUILD_COPY turns into COPY
|
||||
# If we're building normally, for amd64, CROSS_BUILD lines are removed
|
||||
CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
|
||||
|
||||
RUN pip install pyyaml
|
||||
|
||||
ADD kube-addons.sh /opt/
|
||||
ADD kube-addon-update.sh /opt/
|
||||
ADD namespace.yaml /opt/
|
||||
ADD kubectl /usr/local/bin/kubectl
|
||||
ADD kubectl /usr/local/bin/
|
||||
|
||||
CMD /opt/kube-addons.sh
|
||||
CMD ["/opt/kube-addons.sh"]
|
||||
|
@ -13,22 +13,62 @@
|
||||
# limitations under the License.
|
||||
|
||||
IMAGE=gcr.io/google-containers/kube-addon-manager
|
||||
VERSION=v1
|
||||
KUBECTL_VERSION=v1.2.3
|
||||
ARCH?=amd64
|
||||
TEMP_DIR:=$(shell mktemp -d)
|
||||
VERSION=v2
|
||||
|
||||
.PHONY: build push container
|
||||
# amd64 and arm has "stable" binaries pushed for v1.2, arm64 and ppc64le hasn't so they have to fetch the latest alpha
|
||||
# however, arm64 and ppc64le are very experimental right now, so it's okay
|
||||
ifeq ($(ARCH),amd64)
|
||||
KUBECTL_VERSION?=v1.2.4
|
||||
BASEIMAGE?=python:2.7-slim
|
||||
endif
|
||||
ifeq ($(ARCH),arm)
|
||||
KUBECTL_VERSION?=v1.2.4
|
||||
BASEIMAGE?=hypriot/rpi-python:2.7
|
||||
QEMUARCH=arm
|
||||
endif
|
||||
ifeq ($(ARCH),arm64)
|
||||
KUBECTL_VERSION?=v1.3.0-alpha.3
|
||||
BASEIMAGE?=aarch64/python:2.7-slim
|
||||
QEMUARCH=aarch64
|
||||
endif
|
||||
ifeq ($(ARCH),ppc64le)
|
||||
KUBECTL_VERSION?=v1.3.0-alpha.3
|
||||
BASEIMAGE?=ppc64le/python:2.7-slim
|
||||
QEMUARCH=ppc64le
|
||||
endif
|
||||
|
||||
build: kubectl
|
||||
docker build -t "$(IMAGE):$(VERSION)" .
|
||||
.PHONY: build push
|
||||
|
||||
kubectl:
|
||||
curl "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
|
||||
-o kubectl
|
||||
chmod +x kubectl
|
||||
all: build
|
||||
build:
|
||||
cp ./* $(TEMP_DIR)
|
||||
curl -sSL --retry 5 https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/linux/$(ARCH)/kubectl > $(TEMP_DIR)/kubectl
|
||||
chmod +x $(TEMP_DIR)/kubectl
|
||||
cd ${TEMP_DIR} && sed -i.back "s|ARCH|$(QEMUARCH)|g" Dockerfile
|
||||
cd $(TEMP_DIR) && sed -i.back "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
|
||||
|
||||
ifeq ($(ARCH),amd64)
|
||||
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
|
||||
cd $(TEMP_DIR) && sed -i "/CROSS_BUILD_/d" Dockerfile
|
||||
else
|
||||
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
|
||||
# Register /usr/bin/qemu-ARCH-static as the handler for other-arch binaries in the kernel
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
curl -sSL --retry 5 https://github.com/multiarch/qemu-user-static/releases/download/v2.5.0/x86_64_qemu-$(QEMUARCH)-static.tar.xz | tar -xJ -C $(TEMP_DIR)
|
||||
cd $(TEMP_DIR) && sed -i "s/CROSS_BUILD_//g" Dockerfile
|
||||
endif
|
||||
|
||||
docker build -t $(IMAGE)-$(ARCH):$(VERSION) $(TEMP_DIR)
|
||||
|
||||
push: build
|
||||
gcloud docker push "$(IMAGE):$(VERSION)"
|
||||
gcloud docker push $(IMAGE)-$(ARCH):$(VERSION)
|
||||
ifeq ($(ARCH),amd64)
|
||||
# Backward compatibility. TODO: deprecate this image tag
|
||||
docker tag -f $(IMAGE)-$(ARCH):$(VERSION) $(IMAGE):$(VERSION)
|
||||
gcloud docker push $(IMAGE):$(VERSION)
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm kubectl
|
||||
docker rmi -f "$(IMAGE):$(VERSION)"
|
||||
docker rmi -f $(IMAGE)-$(ARCH):$(VERSION)
|
||||
|
37
cluster/addons/addon-manager/README.md
Normal file
37
cluster/addons/addon-manager/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
### addon-manager
|
||||
|
||||
The `addon-manager` periodically checks for Kubernetes manifest changes in the `/etc/kubernetes/addons` directory,
|
||||
and when there's a new or changed addon, the `addon-manager` automatically `kubectl create`s it.
|
||||
|
||||
It supports `ReplicationControllers`, `Deployments`, `DaemonSets`, `Services`, `PersistentVolumes` and `PersistentVolumeClaims`.
|
||||
|
||||
The `addon-manager` is built for multiple architectures.
|
||||
|
||||
#### How to release
|
||||
|
||||
1. Change something in the source
|
||||
2. Bump `VERSION` in the `Makefile`
|
||||
3. Bump `KUBECTL_VERSION` in the `Makefile` if required
|
||||
4. Build the `amd64` image and test it on a cluster
|
||||
5. Push all images
|
||||
|
||||
```console
|
||||
# Build for linux/amd64 (default)
|
||||
$ make push ARCH=amd64
|
||||
# ---> gcr.io/google-containers/kube-addon-manager-amd64:VERSION
|
||||
# ---> gcr.io/google-containers/kube-addon-manager:VERSION (image with backwards-compatible naming)
|
||||
|
||||
$ make push ARCH=arm
|
||||
# ---> gcr.io/google-containers/kube-addon-manager-arm:VERSION
|
||||
|
||||
$ make push ARCH=arm64
|
||||
# ---> gcr.io/google-containers/kube-addon-manager-arm64:VERSION
|
||||
|
||||
$ make push ARCH=ppc64le
|
||||
# ---> gcr.io/google-containers/kube-addon-manager-ppc64le:VERSION
|
||||
```
|
||||
|
||||
If you don't want to push the images, run `make` or `make build` instead
|
||||
|
||||
|
||||
[]()
|
@ -198,7 +198,7 @@ function run-until-success() {
|
||||
# returns a list of <namespace>/<name> pairs (nsnames)
|
||||
function get-addon-nsnames-from-server() {
|
||||
local -r obj_type=$1
|
||||
"${KUBECTL}" get "${obj_type}" --all-namespaces -o go-template="{{range.items}}{{.metadata.namespace}}/{{.metadata.name}} {{end}}" --api-version=v1 -l kubernetes.io/cluster-service=true
|
||||
"${KUBECTL}" get "${obj_type}" --all-namespaces -o go-template="{{range.items}}{{.metadata.namespace}}/{{.metadata.name}} {{end}}" -l kubernetes.io/cluster-service=true
|
||||
}
|
||||
|
||||
# returns the characters after the last separator (including)
|
||||
@ -476,6 +476,7 @@ function update-addons() {
|
||||
# be careful, reconcile-objects uses global variables
|
||||
reconcile-objects ${addon_path} ReplicationController "-" &
|
||||
reconcile-objects ${addon_path} Deployment "-" &
|
||||
reconcile-objects ${addon_path} DaemonSet "-" &
|
||||
|
||||
# We don't expect names to be versioned for the following kinds, so
|
||||
# we match the entire name, ignoring version suffix.
|
||||
|
Loading…
Reference in New Issue
Block a user