Skip to content

Commit f3690e2

Browse files
committed
build/pause: write in C
Builds statically against glibc. References to the old pause image have been updated.
1 parent cfd7a99 commit f3690e2

30 files changed

Lines changed: 137 additions & 91 deletions

‎build/pause/.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.container-*
2+
/.push-*
3+
/bin

‎build/pause/Dockerfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
# limitations under the License.
1414

1515
FROM scratch
16-
ADD pause /
16+
ARG ARCH
17+
ADD bin/pause-${ARCH} /pause
1718
ENTRYPOINT ["/pause"]

‎build/pause/Makefile‎

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,85 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
.PHONY: build push
15+
.PHONY: all push push-legacy container clean
1616

17-
TAG=2.0
18-
REGISTRY?="gcr.io/google_containers"
17+
REGISTRY ?= gcr.io/google_containers
18+
IMAGE = $(REGISTRY)/pause-$(ARCH)
19+
LEGACY_AMD64_IMAGE = $(REGISTRY)/pause
20+
21+
TAG = 3.0
1922

2023
# Architectures supported: amd64, arm, arm64 and ppc64le
21-
ARCH?=amd64
22-
GOLANG_VERSION=1.6
23-
TEMP_DIR:=$(shell mktemp -d)
24+
ARCH ?= amd64
25+
26+
ALL_ARCH = amd64 arm arm64 ppc64le
27+
28+
CFLAGS = -Os -Wall -static
29+
KUBE_CROSS_IMAGE ?= gcr.io/google_containers/kube-cross
30+
KUBE_CROSS_VERSION ?= $(shell cat ../build-image/cross/VERSION)
31+
32+
BIN = pause
33+
SRCS = pause.c
2434

25-
all: push-legacy-too
35+
ifeq ($(ARCH),amd64)
36+
TRIPLE ?= x86_64-linux-gnu
37+
endif
2638

27-
build:
28-
cp pause.go Dockerfile $(TEMP_DIR)
39+
ifeq ($(ARCH),arm)
40+
TRIPLE ?= arm-linux-gnueabi
41+
endif
2942

30-
docker run -it -v $(TEMP_DIR):/build golang:$(GOLANG_VERSION) /bin/bash -c \
31-
"cd /build && CGO_ENABLED=0 GOARM=6 GOARCH=$(ARCH) go build -a -installsuffix cgo -ldflags '-w' ./pause.go"
43+
ifeq ($(ARCH),arm64)
44+
TRIPLE ?= aarch64-linux-gnu
45+
endif
3246

33-
ifeq ($(ARCH),$(filter $(ARCH),amd64 arm))
34-
# Run goupx for amd64 and arm. The condition above is equal to 'if [[ $ARCH == "amd64" || $ARCH == "arm" ]]' in bash
35-
docker run -it -v $(TEMP_DIR):/build golang:$(GOLANG_VERSION) /bin/bash -c \
36-
"cd /build && apt-get update && apt-get install -y upx \
37-
&& go get github.com/pwaller/goupx && goupx pause"
47+
ifeq ($(ARCH),ppc64le)
48+
TRIPLE ?= powerpc64le-linux-gnu
3849
endif
3950

40-
# And build the image
41-
docker build -t $(REGISTRY)/pause-$(ARCH):$(TAG) $(TEMP_DIR)
51+
# If you want to build AND push all containers, see the 'all-push' rule.
52+
all: all-container
4253

54+
sub-container-%:
55+
$(MAKE) ARCH=$* container
56+
57+
sub-push-%:
58+
$(MAKE) ARCH=$* push
59+
60+
all-container: $(addprefix sub-container-,$(ALL_ARCH))
61+
62+
all-push: $(addprefix sub-push-,$(ALL_ARCH))
63+
64+
build: bin/$(BIN)-$(ARCH)
65+
66+
bin/$(BIN)-$(ARCH): $(SRCS)
67+
mkdir -p bin
68+
docker run -u $$(id -u):$$(id -g) -v $$(pwd):/build \
69+
$(KUBE_CROSS_IMAGE):$(KUBE_CROSS_VERSION) \
70+
/bin/bash -c "\
71+
cd /build && \
72+
$(TRIPLE)-gcc $(CFLAGS) -o $@ $^ && \
73+
$(TRIPLE)-strip $@"
74+
75+
container: .container-$(ARCH)
76+
.container-$(ARCH): bin/$(BIN)-$(ARCH)
77+
docker build -t $(IMAGE):$(TAG) --build-arg ARCH=$(ARCH) .
4378
ifeq ($(ARCH),amd64)
44-
docker tag -f $(REGISTRY)/pause-$(ARCH):$(TAG) $(REGISTRY)/pause:$(TAG)
79+
docker tag -f $(IMAGE):$(TAG) $(LEGACY_AMD64_IMAGE):$(TAG)
4580
endif
81+
touch $@
4682

47-
push: build
48-
gcloud docker --server=gcr.io push $(REGISTRY)/pause-$(ARCH):$(TAG)
83+
push: .push-$(ARCH)
84+
.push-$(ARCH): .container-$(ARCH)
85+
gcloud docker push $(IMAGE):$(TAG)
86+
touch $@
4987

50-
push-legacy-too: push
88+
push-legacy: .push-legacy-$(ARCH)
89+
.push-legacy-$(ARCH): .container-$(ARCH)
5190
ifeq ($(ARCH),amd64)
52-
gcloud docker push $(REGISTRY)/pause:$(TAG)
91+
gcloud docker push $(LEGACY_AMD64_IMAGE):$(TAG)
5392
endif
93+
touch $@
94+
95+
clean:
96+
rm -rf .container-* .push-* bin/
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// +build linux
2-
31
/*
4-
Copyright 2014 The Kubernetes Authors All rights reserved.
2+
Copyright 2016 The Kubernetes Authors All rights reserved.
53
64
Licensed under the Apache License, Version 2.0 (the "License");
75
you may not use this file except in compliance with the License.
@@ -16,18 +14,23 @@ See the License for the specific language governing permissions and
1614
limitations under the License.
1715
*/
1816

19-
package main
20-
21-
import (
22-
"os"
23-
"os/signal"
24-
"syscall"
25-
)
17+
#include <signal.h>
18+
#include <stdio.h>
19+
#include <stdlib.h>
20+
#include <unistd.h>
2621

27-
func main() {
28-
c := make(chan os.Signal, 1)
29-
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGTERM)
22+
static void sigdown(int signo) {
23+
psignal(signo, "shutting down, got signal");
24+
exit(0);
25+
}
3026

31-
// Block until a signal is received.
32-
<-c
27+
int main() {
28+
if (signal(SIGINT, sigdown) == SIG_ERR)
29+
return 1;
30+
if (signal(SIGTERM, sigdown) == SIG_ERR)
31+
return 2;
32+
signal(SIGKILL, sigdown);
33+
for (;;) pause();
34+
fprintf(stderr, "error: infinite loop terminated\n");
35+
return 42;
3336
}

‎cmd/integration/integration.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ func runSchedulerNoPhantomPodsTest(client *client.Client) {
844844
Containers: []api.Container{
845845
{
846846
Name: "c1",
847-
Image: "kubernetes/pause",
847+
Image: "gcr.io/google_containers/pause-amd64:3.0",
848848
Ports: []api.ContainerPort{
849849
{ContainerPort: 1234, HostPort: 9999},
850850
},

‎cmd/kubelet/app/options/options.go‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ const (
4040
experimentalFlannelOverlay = false
4141

4242
defaultPodInfraContainerImageName = "gcr.io/google_containers/pause"
43-
defaultPodInfraContainerImageVersion = "2.0"
43+
defaultPodInfraContainerImageVersion = "3.0"
4444
)
4545

4646
// Returns the arch-specific pause image that kubelet should use as the default
4747
func GetDefaultPodInfraContainerImage() string {
48-
if runtime.GOARCH == "amd64" {
49-
return defaultPodInfraContainerImageName + ":" + defaultPodInfraContainerImageVersion
50-
} else {
51-
return defaultPodInfraContainerImageName + "-" + runtime.GOARCH + ":" + defaultPodInfraContainerImageVersion
52-
}
48+
return defaultPodInfraContainerImageName + "-" + runtime.GOARCH + ":" + defaultPodInfraContainerImageVersion
5349
}
5450

5551
// KubeletServer encapsulates all of the parameters necessary for starting up

‎docs/admin/kubelet.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ kubelet
130130
--oom-score-adj=-999: The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]
131131
--outofdisk-transition-frequency=5m0s: Duration for which the kubelet has to wait before transitioning out of out-of-disk node condition status. Default: 5m0s
132132
--pod-cidr="": The CIDR to use for pod IP addresses, only used in standalone mode. In cluster mode, this is obtained from the master.
133-
--pod-infra-container-image="gcr.io/google_containers/pause:2.0": The image whose network/ipc namespaces containers in each pod will use.
133+
--pod-infra-container-image="gcr.io/google_containers/pause-amd64:3.0": The image whose network/ipc namespaces containers in each pod will use.
134134
--port=10250: The port for the Kubelet to serve on.
135135
--read-only-port=10255: The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)
136136
--really-crash-for-testing[=false]: If true, when panics occur crash. Intended for testing.
@@ -156,7 +156,7 @@ kubelet
156156
--volume-stats-agg-period=1m0s: Specifies interval for kubelet to calculate and cache the volume disk usage for all pods and volumes. To disable volume calculations, set to 0. Default: '1m'
157157
```
158158

159-
###### Auto generated by spf13/cobra on 21-Apr-2016
159+
###### Auto generated by spf13/cobra on 3-May-2016
160160

161161

162162
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

‎hack/test-cmd.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,9 @@ runTests() {
597597
kube::test::get_object_assert pods "{{range.items}}{{$image_field}}:{{end}}" 'changed-with-yaml:'
598598
## Patch pod from JSON can change image
599599
# Command
600-
kubectl patch "${kube_flags[@]}" -f docs/admin/limitrange/valid-pod.yaml -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "kubernetes/pause"}]}}'
601-
# Post-condition: valid-pod POD has image kubernetes/pause
602-
kube::test::get_object_assert pods "{{range.items}}{{$image_field}}:{{end}}" 'kubernetes/pause:'
600+
kubectl patch "${kube_flags[@]}" -f docs/admin/limitrange/valid-pod.yaml -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "gcr.io/google_containers/pause-amd64:3.0"}]}}'
601+
# Post-condition: valid-pod POD has image gcr.io/google_containers/pause-amd64:3.0
602+
kube::test::get_object_assert pods "{{range.items}}{{$image_field}}:{{end}}" 'gcr.io/google_containers/pause-amd64:3.0:'
603603

604604
## If resourceVersion is specified in the patch, it will be treated as a precondition, i.e., if the resourceVersion is different from that is stored in the server, the Patch should be rejected
605605
ERROR_FILE="${KUBE_TEMP}/conflict-error"

‎hack/testdata/pod-with-precision.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"containers": [
1010
{
1111
"name": "kubernetes-pause",
12-
"image": "kubernetes/pause"
12+
"image": "gcr.io/google_containers/pause-amd64:3.0"
1313
}
1414
],
1515
"restartPolicy": "Never",

‎test/e2e/cluster_size_autoscaling.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func ReserveCpu(f *framework.Framework, id string, millicores int) {
150150
Name: id,
151151
Namespace: f.Namespace.Name,
152152
Timeout: 10 * time.Minute,
153-
Image: "gcr.io/google_containers/pause:2.0",
153+
Image: "gcr.io/google_containers/pause-amd64:3.0",
154154
Replicas: millicores / 100,
155155
CpuRequest: 100,
156156
}
@@ -164,7 +164,7 @@ func ReserveMemory(f *framework.Framework, id string, megabytes int) {
164164
Name: id,
165165
Namespace: f.Namespace.Name,
166166
Timeout: 10 * time.Minute,
167-
Image: "gcr.io/google_containers/pause:2.0",
167+
Image: "gcr.io/google_containers/pause-amd64:3.0",
168168
Replicas: megabytes / 500,
169169
MemRequest: 500 * 1024 * 1024,
170170
}

0 commit comments

Comments
 (0)