From 5e2b38f9c5f7fd75b3fbd1632d92ed0e4c0f8e29 Mon Sep 17 00:00:00 2001 From: Jason Brooks Date: Thu, 6 Jul 2017 12:35:46 -0700 Subject: [PATCH 1/7] initial commit --- Dockerfile | 25 ++++ config.json.template | 349 +++++++++++++++++++++++++++++++++++++++++++ launch.sh | 8 + service.template | 12 ++ 4 files changed, 394 insertions(+) create mode 100644 Dockerfile create mode 100644 config.json.template create mode 100644 launch.sh create mode 100644 service.template diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..db94c5d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM registry.fedoraproject.org/kubernetes-node:rawhide +MAINTAINER "Jason Brooks" + +ENV container=docker + +ENV NAME=kubernetes-proxy VERSION=0 RELEASE=8 ARCH=x86_64 +LABEL bzcomponent="$NAME" \ + name="$FGC/$NAME" \ + version="$VERSION" \ + release="$RELEASE.$DISTTAG" \ + architecture="$ARCH" \ + atomic.type='system' + +RUN dnf install -y iptables conntrack-tools && dnf clean all + +LABEL RUN /usr/bin/docker run -d --privileged --net=host + +COPY launch.sh /usr/bin/kube-proxy-docker.sh + +COPY service.template config.json.template /exports/ + +RUN mkdir -p /exports/hostfs/etc/kubernetes && cp /etc/kubernetes/{config,proxy} /exports/hostfs/etc/kubernetes + +ENTRYPOINT ["/usr/bin/kube-proxy-docker.sh"] + diff --git a/config.json.template b/config.json.template new file mode 100644 index 0000000..5084c9b --- /dev/null +++ b/config.json.template @@ -0,0 +1,349 @@ +{ + "ociVersion": "1.0.0", + "platform": { + "os": "linux", + "arch": "amd64" + }, + "process": { + "terminal": false, + "user": { + "uid": 994, + "gid": 996 + }, + "args": [ + "/usr/bin/kube-proxy-docker.sh" + ], + "env": [ + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "TERM=xterm" + ], + "cwd": "/", + "capabilities": { + "bounding": [ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_KILL", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETPCAP", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_ADMIN", + "CAP_NET_RAW", + "CAP_IPC_LOCK", + "CAP_IPC_OWNER", + "CAP_SYS_MODULE", + "CAP_SYS_RAWIO", + "CAP_SYS_CHROOT", + "CAP_SYS_PTRACE", + "CAP_SYS_PACCT", + "CAP_SYS_ADMIN", + "CAP_SYS_BOOT", + "CAP_SYS_NICE", + "CAP_SYS_RESOURCE", + "CAP_SYS_TIME", + "CAP_SYS_TTY_CONFIG", + "CAP_MKNOD", + "CAP_LEASE", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + "CAP_SETFCAP", + "CAP_MAC_OVERRIDE", + "CAP_MAC_ADMIN", + "CAP_SYSLOG", + "CAP_WAKE_ALARM", + "CAP_BLOCK_SUSPEND" + ], + "permitted": [ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_KILL", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETPCAP", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_ADMIN", + "CAP_NET_RAW", + "CAP_IPC_LOCK", + "CAP_IPC_OWNER", + "CAP_SYS_MODULE", + "CAP_SYS_RAWIO", + "CAP_SYS_CHROOT", + "CAP_SYS_PTRACE", + "CAP_SYS_PACCT", + "CAP_SYS_ADMIN", + "CAP_SYS_BOOT", + "CAP_SYS_NICE", + "CAP_SYS_RESOURCE", + "CAP_SYS_TIME", + "CAP_SYS_TTY_CONFIG", + "CAP_MKNOD", + "CAP_LEASE", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + "CAP_SETFCAP", + "CAP_MAC_OVERRIDE", + "CAP_MAC_ADMIN", + "CAP_SYSLOG", + "CAP_WAKE_ALARM", + "CAP_BLOCK_SUSPEND" + ], + "inheritable": [ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_KILL", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETPCAP", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_ADMIN", + "CAP_NET_RAW", + "CAP_IPC_LOCK", + "CAP_IPC_OWNER", + "CAP_SYS_MODULE", + "CAP_SYS_RAWIO", + "CAP_SYS_CHROOT", + "CAP_SYS_PTRACE", + "CAP_SYS_PACCT", + "CAP_SYS_ADMIN", + "CAP_SYS_BOOT", + "CAP_SYS_NICE", + "CAP_SYS_RESOURCE", + "CAP_SYS_TIME", + "CAP_SYS_TTY_CONFIG", + "CAP_MKNOD", + "CAP_LEASE", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + "CAP_SETFCAP", + "CAP_MAC_OVERRIDE", + "CAP_MAC_ADMIN", + "CAP_SYSLOG", + "CAP_WAKE_ALARM", + "CAP_BLOCK_SUSPEND" + ], + "effective": [ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_KILL", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETPCAP", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_ADMIN", + "CAP_NET_RAW", + "CAP_IPC_LOCK", + "CAP_IPC_OWNER", + "CAP_SYS_MODULE", + "CAP_SYS_RAWIO", + "CAP_SYS_CHROOT", + "CAP_SYS_PTRACE", + "CAP_SYS_PACCT", + "CAP_SYS_ADMIN", + "CAP_SYS_BOOT", + "CAP_SYS_NICE", + "CAP_SYS_RESOURCE", + "CAP_SYS_TIME", + "CAP_SYS_TTY_CONFIG", + "CAP_MKNOD", + "CAP_LEASE", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + "CAP_SETFCAP", + "CAP_MAC_OVERRIDE", + "CAP_MAC_ADMIN", + "CAP_SYSLOG", + "CAP_WAKE_ALARM", + "CAP_BLOCK_SUSPEND" + ], + "ambient": [ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_KILL", + "CAP_SETGID", + "CAP_SETUID", + "CAP_SETPCAP", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_ADMIN", + "CAP_NET_RAW", + "CAP_IPC_LOCK", + "CAP_IPC_OWNER", + "CAP_SYS_MODULE", + "CAP_SYS_RAWIO", + "CAP_SYS_CHROOT", + "CAP_SYS_PTRACE", + "CAP_SYS_PACCT", + "CAP_SYS_ADMIN", + "CAP_SYS_BOOT", + "CAP_SYS_NICE", + "CAP_SYS_RESOURCE", + "CAP_SYS_TIME", + "CAP_SYS_TTY_CONFIG", + "CAP_MKNOD", + "CAP_LEASE", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + "CAP_SETFCAP", + "CAP_MAC_OVERRIDE", + "CAP_MAC_ADMIN", + "CAP_SYSLOG", + "CAP_WAKE_ALARM", + "CAP_BLOCK_SUSPEND" + ] + }, + "rlimits": [ + { + "type": "RLIMIT_NOFILE", + "hard": 1024, + "soft": 1024 + } + ] + }, + "root": { + "path": "rootfs", + "readonly": true + }, + "mounts": [ + { + "destination": "/proc", + "type": "proc", + "source": "proc" + }, + { + "destination": "/dev", + "type": "tmpfs", + "source": "tmpfs", + "options": [ + "nosuid", + "strictatime", + "mode=755", + "size=65536k" + ] + }, + { + "destination": "/dev/pts", + "type": "devpts", + "source": "devpts", + "options": [ + "nosuid", + "noexec", + "newinstance", + "ptmxmode=0666", + "mode=0620", + "gid=5" + ] + }, + { + "destination": "/dev/shm", + "type": "tmpfs", + "source": "shm", + "options": [ + "nosuid", + "noexec", + "nodev", + "mode=1777", + "size=65536k" + ] + }, + { + "destination": "/dev/mqueue", + "type": "mqueue", + "source": "mqueue", + "options": [ + "nosuid", + "noexec", + "nodev" + ] + }, + { + "destination": "/sys", + "type": "sysfs", + "source": "sysfs", + "options": [ + "nosuid", + "noexec", + "nodev" + ] + }, + { + "destination": "/sys/fs/cgroup", + "type": "cgroup", + "source": "cgroup", + "options": [ + "nosuid", + "noexec", + "nodev", + "relatime", + "ro" + ] + }, + { + "type": "bind", + "source": "/etc/kubernetes", + "destination": "/etc/kubernetes", + "options": [ + "rbind", + "ro", + "rprivate" + ] + }, + { + "destination": "/etc/resolv.conf", + "type": "bind", + "source": "/etc/resolv.conf", + "options": [ + "ro", + "rbind", + "rprivate" + ] + } + ], + "linux": { + "resources": { + "devices": [ + { + "allow": false, + "access": "rwm" + } + ] + }, + "namespaces": [ + { + "type": "pid" + }, + { + "type": "ipc" + }, + { + "type": "mount" + } + ], + "devices": null, + "apparmorProfile": "", + "selinuxProcessLabel": "" + } +} diff --git a/launch.sh b/launch.sh new file mode 100644 index 0000000..2906497 --- /dev/null +++ b/launch.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +source /etc/kubernetes/proxy +source /etc/kubernetes/config + +ARGS=$(echo "$@ $KUBE_LOGTOSTDERR $KUBE_LOG_LEVEL $KUBE_MASTER $KUBE_PROXY_ARGS" | xargs -n1 | sort -u -t = -k 1,1 | xargs) + +exec /usr/bin/kube-proxy $ARGS diff --git a/service.template b/service.template new file mode 100644 index 0000000..3abf07a --- /dev/null +++ b/service.template @@ -0,0 +1,12 @@ +[Unit] +Description=kubernetes-proxy + +[Service] +ExecStart=$EXEC_START +ExecStop=$EXEC_STOP +Restart=on-failure +WorkingDirectory=$DESTDIR + +[Install] +WantedBy=multi-user.target + From ca2d56750db8846e9aff280f44c83f70577e1704 Mon Sep 17 00:00:00 2001 From: Jason Brooks Date: Thu, 6 Jul 2017 13:12:12 -0700 Subject: [PATCH 2/7] fix BZComponent capitalization --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index db94c5d..1cffb99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ MAINTAINER "Jason Brooks" ENV container=docker ENV NAME=kubernetes-proxy VERSION=0 RELEASE=8 ARCH=x86_64 -LABEL bzcomponent="$NAME" \ +LABEL BZComponent="$NAME" \ name="$FGC/$NAME" \ version="$VERSION" \ release="$RELEASE.$DISTTAG" \ From a01b61f01931f8de0f21e1074c30b39b109bdd15 Mon Sep 17 00:00:00 2001 From: Jason Brooks Date: Thu, 6 Jul 2017 14:03:00 -0700 Subject: [PATCH 3/7] build from f27 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1cffb99..618c672 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.fedoraproject.org/kubernetes-node:rawhide +FROM registry.fedoraproject.org/f27/kubernetes-node:latest MAINTAINER "Jason Brooks" ENV container=docker From c88de4b53059ac4a2221be3902e91f8698dd7d64 Mon Sep 17 00:00:00 2001 From: Jason Brooks Date: Tue, 28 Nov 2017 13:01:13 -0800 Subject: [PATCH 4/7] fix gid/uid, make launch.sh executable --- Dockerfile | 2 +- config.json.template | 4 ++-- launch.sh | 0 3 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 launch.sh diff --git a/Dockerfile b/Dockerfile index 618c672..02c6571 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.fedoraproject.org/f27/kubernetes-node:latest +FROM registry.fedoraproject.org/kubernetes-master:rawhide MAINTAINER "Jason Brooks" ENV container=docker diff --git a/config.json.template b/config.json.template index 5084c9b..a4d7a0c 100644 --- a/config.json.template +++ b/config.json.template @@ -7,8 +7,8 @@ "process": { "terminal": false, "user": { - "uid": 994, - "gid": 996 + "uid": 996, + "gid": 994 }, "args": [ "/usr/bin/kube-proxy-docker.sh" diff --git a/launch.sh b/launch.sh old mode 100644 new mode 100755 From 593a3f9bdb863285ed06651819700d23be002bfe Mon Sep 17 00:00:00 2001 From: Jason Brooks Date: Mon, 18 Dec 2017 13:41:11 -0800 Subject: [PATCH 5/7] bind mount /run rw --- config.json.template | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config.json.template b/config.json.template index a4d7a0c..b63aab6 100644 --- a/config.json.template +++ b/config.json.template @@ -320,6 +320,16 @@ "rbind", "rprivate" ] + }, + { + "type": "bind", + "source": "/run", + "destination": "/run", + "options": [ + "rbind", + "rw", + "mode=755" + ] } ], "linux": { From 40655fd376c57d5af0a1c5c338dce560d30a48b4 Mon Sep 17 00:00:00 2001 From: Jason Brooks Date: Tue, 20 Mar 2018 13:26:37 -0700 Subject: [PATCH 6/7] from f28, run proxy as root --- Dockerfile | 4 ++-- config.json.template | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02c6571..e7cfb05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM registry.fedoraproject.org/kubernetes-master:rawhide +FROM registry.fedoraproject.org/kubernetes-master:28 MAINTAINER "Jason Brooks" ENV container=docker -ENV NAME=kubernetes-proxy VERSION=0 RELEASE=8 ARCH=x86_64 +ENV NAME=kubernetes-proxy VERSION=0 RELEASE=0 ARCH=x86_64 LABEL BZComponent="$NAME" \ name="$FGC/$NAME" \ version="$VERSION" \ diff --git a/config.json.template b/config.json.template index b63aab6..3400a6b 100644 --- a/config.json.template +++ b/config.json.template @@ -7,8 +7,8 @@ "process": { "terminal": false, "user": { - "uid": 996, - "gid": 994 + "uid": 0, + "gid": 0 }, "args": [ "/usr/bin/kube-proxy-docker.sh" From 39372cfa577eaff82272bac7ae77890a1fc2fcb9 Mon Sep 17 00:00:00 2001 From: Bhavin Gandhi Date: Sun, 26 Aug 2018 23:46:41 +0530 Subject: [PATCH 7/7] Drop Release label in favor of OSBS release_bump plugin OSBS can automatically bump the release number, for that we just need to drop the label from the Dockerfile See https://pagure.io/ContainerSIG/container-sig/issue/1 Signed-off-by: Bhavin Gandhi --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3cdff5b..837aaf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,10 @@ MAINTAINER "Jason Brooks" ENV container=docker -ENV NAME=kubernetes-proxy VERSION=0 RELEASE=0 ARCH=x86_64 +ENV NAME=kubernetes-proxy VERSION=0 ARCH=x86_64 LABEL BZComponent="$NAME" \ name="$FGC/$NAME" \ version="$VERSION" \ - release="$RELEASE.$DISTTAG" \ architecture="$ARCH" \ atomic.type='system'