|
| 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 bullseye-backports |
| 20 | +RUN echo deb http://deb.debian.org/debian bullseye-backports main >> /etc/apt/sources.list \ |
| 21 | + && apt-get update \ |
| 22 | + && apt-get -t bullseye-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 / / |
0 commit comments