Skip to content

Commit f5edc9d

Browse files
committed
debian-iptables: Build bullseye-v1.0.0 images
Signed-off-by: Stephen Augustus <[email protected]>
1 parent 9551785 commit f5edc9d

File tree

4 files changed

+89
-2
lines changed

4 files changed

+89
-2
lines changed

dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ dependencies:
295295
match: '[a-zA-Z]+\-v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)'
296296

297297
- name: "k8s.gcr.io/build-image/debian-iptables"
298-
version: buster-v1.6.6
298+
version: bullseye-v1.0.0
299299
refPaths:
300300
- path: images/build/debian-iptables/Makefile
301301
match: IMAGE_VERSION\ \?=\ [a-zA-Z]+\-v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)

images/build/debian-iptables/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ REGISTRY?="gcr.io/k8s-staging-build-image"
1818
IMAGE=$(REGISTRY)/debian-iptables
1919

2020
TAG ?= $(shell git describe --tags --always --dirty)
21-
IMAGE_VERSION ?= buster-v1.6.6
21+
IMAGE_VERSION ?= bullseye-v1.0.0
2222
CONFIG ?= bullseye
2323
DEBIAN_BASE_VERSION ?= bullseye-v1.0.0
2424

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2021 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG BASEIMAGE
16+
17+
FROM ${BASEIMAGE} as build
18+
19+
# Install iptables and ebtables packages from buster-backports
20+
RUN echo deb http://deb.debian.org/debian buster-backports main >> /etc/apt/sources.list \
21+
&& apt-get update \
22+
&& apt-get -t buster-backports -y --no-install-recommends install \
23+
iptables \
24+
ebtables
25+
26+
# Install other dependencies and then clean up apt caches
27+
RUN clean-install \
28+
conntrack \
29+
ipset \
30+
kmod \
31+
netbase
32+
33+
# Install iptables wrapper scripts to detect the correct iptables mode
34+
# the first time any of them is run
35+
COPY iptables-wrapper /usr/sbin/iptables-wrapper
36+
37+
RUN update-alternatives \
38+
--install /usr/sbin/iptables iptables /usr/sbin/iptables-wrapper 100 \
39+
--slave /usr/sbin/iptables-restore iptables-restore /usr/sbin/iptables-wrapper \
40+
--slave /usr/sbin/iptables-save iptables-save /usr/sbin/iptables-wrapper
41+
RUN update-alternatives \
42+
--install /usr/sbin/ip6tables ip6tables /usr/sbin/iptables-wrapper 100 \
43+
--slave /usr/sbin/ip6tables-restore ip6tables-restore /usr/sbin/iptables-wrapper \
44+
--slave /usr/sbin/ip6tables-save ip6tables-save /usr/sbin/iptables-wrapper
45+
46+
FROM scratch
47+
COPY --from=build / /
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
# Copyright 2021 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
# Detect whether the base system is using iptables-legacy or
20+
# iptables-nft. This assumes that some non-containerized process (eg
21+
# kubelet) has already created some iptables rules.
22+
23+
# Bugs in iptables-nft 1.8.3 may cause it to get stuck in a loop in
24+
# some circumstances, so we have to run the nft check in a timeout. To
25+
# avoid hitting that timeout, we only bother to even check nft if
26+
# legacy iptables was empty / mostly empty.
27+
28+
num_legacy_lines=$( (iptables-legacy-save || true; ip6tables-legacy-save || true) 2>/dev/null | grep '^-' | wc -l || true)
29+
num_nft_lines=$( (timeout 5 sh -c "iptables-nft-save; ip6tables-nft-save" || true) 2>/dev/null | grep '^-' | wc -l || true)
30+
if [ "${num_legacy_lines}" -ge "${num_nft_lines}" ]; then
31+
mode=legacy
32+
else
33+
mode=nft
34+
fi
35+
36+
update-alternatives --set iptables "/usr/sbin/iptables-${mode}" > /dev/null
37+
update-alternatives --set ip6tables "/usr/sbin/ip6tables-${mode}" > /dev/null
38+
39+
# Now re-exec the original command with the newly-selected alternative
40+
exec "$0" "$@"

0 commit comments

Comments
 (0)