vendor updates

This commit is contained in:
Serguei Bezverkhi
2018-03-06 17:33:18 -05:00
parent 4b3ebc171b
commit e9033989a0
5854 changed files with 248382 additions and 119809 deletions

View File

@ -15,7 +15,7 @@
REGISTRY ?= gcr.io/kubernetes-e2e-test-images
GOARM=7
QEMUVERSION=v2.9.1
GOLANG_VERSION=1.9.2
GOLANG_VERSION=1.9.3
export
ifndef WHAT

7
vendor/k8s.io/kubernetes/test/images/OWNERS generated vendored Normal file
View File

@ -0,0 +1,7 @@
reviewers:
- luxas
- mkumatag
- ixdy
approvers:
- luxas
- ixdy

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "clusterapi-tester",
importpath = "k8s.io/kubernetes/test/images/clusterapi-tester",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "entrypoint-tester",
importpath = "k8s.io/kubernetes/test/images/entrypoint-tester",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "fakegitserver",
importpath = "k8s.io/kubernetes/test/images/fakegitserver",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "goproxy",
importpath = "k8s.io/kubernetes/test/images/goproxy",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -22,4 +22,4 @@ CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/
RUN apk --update add curl netcat-openbsd iproute2 && rm -rf /var/cache/apk/*
# wait forever
CMD rm -f /fifo && mkfifo /fifo && exec cat </fifo
CMD while true; do sleep 1d; done

View File

@ -1 +1 @@
1.0
1.1

View File

@ -7,6 +7,6 @@ metadata:
spec:
containers:
- name: hostexec
image: gcr.io/kubernetes-e2e-test-images/hostexec-amd64:1.0
image: gcr.io/kubernetes-e2e-test-images/hostexec-amd64:1.1
securityContext:
hostNetwork: true

View File

@ -97,7 +97,7 @@ push() {
fi
for arch in ${archs}; do
TAG=$(<${IMAGE}/VERSION)
gcloud docker -- push ${REGISTRY}/${IMAGE}-${arch}:${TAG}
docker push ${REGISTRY}/${IMAGE}-${arch}:${TAG}
done
}

View File

@ -0,0 +1,4 @@
amd64=alpine:3.6
arm=arm32v6/alpine:3.6
arm64=arm64v8/alpine:3.6
ppc64le=ppc64le/alpine:3.6

View File

@ -0,0 +1,19 @@
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM BASEIMAGE
CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/
RUN apk add --no-cache util-linux

View File

@ -0,0 +1 @@
1.0

View File

@ -1,4 +1,4 @@
amd64=gcr.io/google_containers/ubuntu-slim:0.12
arm=gcr.io/google_containers/ubuntu-slim-arm:0.12
arm64=gcr.io/google_containers/ubuntu-slim-arm64:0.12
ppc64le=gcr.io/google_containers/ubuntu-slim-ppc64le:0.12
amd64=k8s.gcr.io/ubuntu-slim:0.12
arm=k8s.gcr.io/ubuntu-slim-arm:0.12
arm64=k8s.gcr.io/ubuntu-slim-arm64:0.12
ppc64le=k8s.gcr.io/ubuntu-slim-ppc64le:0.12

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "liveness",
importpath = "k8s.io/kubernetes/test/images/liveness",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "logs-generator",
importpath = "k8s.io/kubernetes/test/images/logs-generator",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -33,7 +33,7 @@ line in a given run of the container.
Image is located in the public repository of Google Container Registry under the name
```
gcr.io/google_containers/logs-generator:v0.1.1
k8s.gcr.io/logs-generator:v0.1.1
```
## Examples
@ -42,13 +42,13 @@ gcr.io/google_containers/logs-generator:v0.1.1
docker run -i \
-e "LOGS_GENERATOR_LINES_TOTAL=10" \
-e "LOGS_GENERATOR_DURATION=1s" \
gcr.io/google_containers/logs-generator:v0.1.1
k8s.gcr.io/logs-generator:v0.1.1
```
```
kubectl run logs-generator \
--generator=run-pod/v1 \
--image=gcr.io/google_containers/logs-generator:v0.1.1 \
--image=k8s.gcr.io/logs-generator:v0.1.1 \
--restart=Never \
--env "LOGS_GENERATOR_LINES_TOTAL=1000" \
--env "LOGS_GENERATOR_DURATION=1m"

View File

@ -8,7 +8,12 @@ load(
go_library(
name = "go_default_library",
srcs = ["mt.go"],
srcs = select({
"@io_bazel_rules_go//go/platform:linux": [
"mt.go",
],
"//conditions:default": [],
}),
importpath = "k8s.io/kubernetes/test/images/mounttest",
)
@ -27,6 +32,5 @@ filegroup(
go_binary(
name = "mounttest",
importpath = "k8s.io/kubernetes/test/images/mounttest",
library = ":go_default_library",
embed = [":go_default_library"],
)

View File

@ -1,3 +1,5 @@
// +build linux
/*
Copyright 2015 The Kubernetes Authors.

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "n-way-http",
importpath = "k8s.io/kubernetes/test/images/n-way-http",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "net",
importpath = "k8s.io/kubernetes/test/images/net",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "netexec",
importpath = "k8s.io/kubernetes/test/images/netexec",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -33,6 +33,5 @@ filegroup(
go_binary(
name = "nettest",
importpath = "k8s.io/kubernetes/test/images/nettest",
library = ":go_default_library",
embed = [":go_default_library"],
)

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "no-snat-test-proxy",
importpath = "k8s.io/kubernetes/test/images/no-snat-test-proxy",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "no-snat-test",
importpath = "k8s.io/kubernetes/test/images/no-snat-test",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "nonewprivs",
importpath = "k8s.io/kubernetes/test/images/nonewprivs",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -1,4 +1,4 @@
amd64=gcr.io/google-containers/debian-base-amd64:0.3
arm=gcr.io/google-containers/debian-base-arm:0.3
arm64=gcr.io/google-containers/debian-base-arm64:0.3
ppc64le=gcr.io/google-containers/debian-base-ppc64le:0.3
amd64=k8s.gcr.io/debian-base-amd64:0.3
arm=k8s.gcr.io/debian-base-arm:0.3
arm64=k8s.gcr.io/debian-base-arm64:0.3
ppc64le=k8s.gcr.io/debian-base-ppc64le:0.3

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "peer-finder",
importpath = "k8s.io/kubernetes/test/images/pets/peer-finder",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -1,4 +1,4 @@
amd64=gcr.io/google-containers/debian-base-amd64:0.3
arm=gcr.io/google-containers/debian-base-arm:0.3
arm64=gcr.io/google-containers/debian-base-arm64:0.3
ppc64le=gcr.io/google-containers/debian-base-ppc64le:0.3
amd64=k8s.gcr.io/debian-base-amd64:0.3
arm=k8s.gcr.io/debian-base-arm:0.3
arm64=k8s.gcr.io/debian-base-arm64:0.3
ppc64le=k8s.gcr.io/debian-base-ppc64le:0.3

View File

@ -4,7 +4,7 @@ The image in this directory is the init container for contrib/pets/redis but for
You can execute the image locally via:
```
$ docker run -it gcr.io/google_containers/redis-install-3.2.0:e2e --cmd --install-into=/opt --work-dir=/work-dir
$ docker run -it k8s.gcr.io/redis-install-3.2.0:e2e --cmd --install-into=/opt --work-dir=/work-dir
```
To share the installation with other containers mount the appropriate volumes as `--install-into` and `--work-dir`, where `install-into` is the directory to install redis into, and `work-dir` is the directory to install the user/admin supplied on-{start,change} hook scripts.

View File

@ -1,4 +1,4 @@
amd64=gcr.io/google-containers/debian-base-amd64:0.3
arm=gcr.io/google-containers/debian-base-arm:0.3
arm64=gcr.io/google-containers/debian-base-arm64:0.3
ppc64le=gcr.io/google-containers/debian-base-ppc64le:0.3
amd64=k8s.gcr.io/debian-base-amd64:0.3
arm=k8s.gcr.io/debian-base-arm:0.3
arm64=k8s.gcr.io/debian-base-arm64:0.3
ppc64le=k8s.gcr.io/debian-base-ppc64le:0.3

View File

@ -4,7 +4,7 @@ The image in this directory is the init container for contrib/pets/zookeeper but
You can execute the image locally via:
```
$ docker run -it gcr.io/google_containers/zookeeper-install-3.5.0-alpha:e2e --cmd --install-into=/opt --work-dir=/work-dir
$ docker run -it k8s.gcr.io/zookeeper-install-3.5.0-alpha:e2e --cmd --install-into=/opt --work-dir=/work-dir
```
To share the installation with other containers mount the appropriate volumes as `--install-into` and `--work-dir`, where `install-into` is the directory to install zookeeper into, and `work-dir` is the directory to install the user/admin supplied on-{start,change} hook scripts.

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "port-forward-tester",
importpath = "k8s.io/kubernetes/test/images/port-forward-tester",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "porter",
importpath = "k8s.io/kubernetes/test/images/porter",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -1,4 +1,4 @@
amd64=gcr.io/google-containers/debian-base-amd64:0.3
arm=gcr.io/google-containers/debian-base-arm:0.3
arm64=gcr.io/google-containers/debian-base-arm64:0.3
ppc64le=gcr.io/google-containers/debian-base-ppc64le:0.3
amd64=k8s.gcr.io/debian-base-amd64:0.3
arm=k8s.gcr.io/debian-base-arm:0.3
arm64=k8s.gcr.io/debian-base-arm64:0.3
ppc64le=k8s.gcr.io/debian-base-ppc64le:0.3

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "resource-consumer",
importpath = "k8s.io/kubernetes/test/images/resource-consumer",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -21,7 +21,7 @@ The container consumes specified amount of resources:
- Memory in megabytes,
- Fake custom metrics.
###Consume CPU http request
### Consume CPU http request
- suffix "ConsumeCPU",
- parameters "millicores" and "durationSec".
@ -31,7 +31,7 @@ When CPU consumption is too low this binary uses cpu by calculating math.sqrt(0)
and if consumption is too high binary sleeps for 10 millisecond.
One replica of Resource Consumer cannot consume more that 1 cpu.
###Consume Memory http request
### Consume Memory http request
- suffix "ConsumeMem",
- parameters "megabytes" and "durationSec".
@ -39,16 +39,16 @@ Consumes specified amount of megabytes for durationSec seconds.
Consume Memory uses stress tool (stress -m 1 --vm-bytes megabytes --vm-hang 0 -t durationSec).
Request leading to consuming more memory then container limit will be ignored.
###Bump value of a fake custom metric
### Bump value of a fake custom metric
- suffix "BumpMetric",
- parameters "metric", "delta" and "durationSec".
Bumps metric with given name by delta for durationSec seconds.
Custom metrics in Prometheus format are exposed on "/metrics" endpoint.
###CURL example
### CURL example
```console
$ kubectl run resource-consumer --image=gcr.io/google_containers/resource_consumer:beta --expose --service-overrides='{ "spec": { "type": "LoadBalancer" } }' --port 8080
$ kubectl run resource-consumer --image=k8s.gcr.io/resource_consumer:beta --expose --service-overrides='{ "spec": { "type": "LoadBalancer" } }' --port 8080
$ kubectl get services resource-consumer
```
@ -62,24 +62,22 @@ $ curl --data "millicores=300&durationSec=600" http://<EXTERNAL-IP>:8080/Consume
## Image
Docker image of Resource Consumer can be found in Google Container Registry as gcr.io/google_containers/resource_consumer:beta
Docker image of Resource Consumer can be found in Google Container Registry as k8s.gcr.io/resource_consumer:beta
## Use cases
###Cluster size autoscaling
### Cluster size autoscaling
1. Consume more resources on each node that is specified for autoscaler
2. Observe that cluster size increased
###Horizontal autoscaling of pod
### Horizontal autoscaling of pod
1. Create consuming RC and start consuming appropriate amount of resources
2. Observe that RC has been resized
3. Observe that usage on each replica decreased
###Vertical autoscaling of pod
### Vertical autoscaling of pod
1. Create consuming pod and start consuming appropriate amount of resources
2. Observed that limits has been increased
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/resource-consumer/README.md?pixel)]()

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "consume-cpu",
importpath = "k8s.io/kubernetes/test/images/resource-consumer/consume-cpu",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "controller",
importpath = "k8s.io/kubernetes/test/images/resource-consumer/controller",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -78,7 +78,7 @@ func (handler *Controller) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
func (handler *Controller) handleConsumeCPU(w http.ResponseWriter, query url.Values) {
// geting string data for consumeCPU
// getting string data for consumeCPU
durationSecString := query.Get(DurationSecQuery)
millicoresString := query.Get(MillicoresQuery)
requestSizeInMillicoresString := query.Get(RequestSizeInMillicoresQuery)
@ -111,7 +111,7 @@ func (handler *Controller) handleConsumeCPU(w http.ResponseWriter, query url.Val
}
func (handler *Controller) handleConsumeMem(w http.ResponseWriter, query url.Values) {
// geting string data for consumeMem
// getting string data for consumeMem
durationSecString := query.Get(DurationSecQuery)
megabytesString := query.Get(MegabytesQuery)
requestSizeInMegabytesString := query.Get(RequestSizeInMegabytesQuery)
@ -144,7 +144,7 @@ func (handler *Controller) handleConsumeMem(w http.ResponseWriter, query url.Val
}
func (handler *Controller) handleBumpMetric(w http.ResponseWriter, query url.Values) {
// geting string data for handleBumpMetric
// getting string data for handleBumpMetric
metric := query.Get(MetricNameQuery)
deltaString := query.Get(DeltaQuery)
durationSecString := query.Get(DurationSecQuery)

View File

@ -75,7 +75,7 @@ func (handler *ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *ht
}
func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, query url.Values) {
// geting string data for consumeCPU
// getting string data for consumeCPU
durationSecString := query.Get(DurationSecQuery)
millicoresString := query.Get(MillicoresQuery)
if durationSecString == "" || millicoresString == "" {
@ -98,7 +98,7 @@ func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter,
}
func (handler *ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, query url.Values) {
// geting string data for consumeMem
// getting string data for consumeMem
durationSecString := query.Get(DurationSecQuery)
megabytesString := query.Get(MegabytesQuery)
if durationSecString == "" || megabytesString == "" {
@ -153,7 +153,7 @@ func (handler *ResourceConsumerHandler) bumpMetric(metric string, delta float64,
}
func (handler *ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter, query url.Values) {
// geting string data for handleBumpMetric
// getting string data for handleBumpMetric
metric := query.Get(MetricNameQuery)
deltaString := query.Get(DeltaQuery)
durationSecString := query.Get(DurationSecQuery)

View File

@ -27,6 +27,5 @@ filegroup(
go_binary(
name = "serve-hostname",
importpath = "k8s.io/kubernetes/test/images/serve-hostname",
library = ":go_default_library",
embed = [":go_default_library"],
)

View File

@ -15,19 +15,19 @@ $ make all-push
# Build for linux/amd64 (default)
$ make push ARCH=amd64
# ---> gcr.io/google_containers/serve_hostname-amd64:TAG
# ---> staging-k8s.gcr.io/serve_hostname-amd64:TAG
$ make push ARCH=arm
# ---> gcr.io/google_containers/serve_hostname-arm:TAG
# ---> staging-k8s.gcr.io/serve_hostname-arm:TAG
$ make push ARCH=arm64
# ---> gcr.io/google_containers/serve_hostname-arm64:TAG
# ---> staging-k8s.gcr.io/serve_hostname-arm64:TAG
$ make push ARCH=ppc64le
# ---> gcr.io/google_containers/serve_hostname-ppc64le:TAG
# ---> staging-k8s.gcr.io/serve_hostname-ppc64le:TAG
$ make push ARCH=s390x
# ---> gcr.io/google_containers/serve_hostname-s390x:TAG
# ---> staging-k8s.gcr.io/serve_hostname-s390x:TAG
```
Of course, if you don't want to push the images, run `make all-container` or `make container ARCH={target_arch}` instead.

View File

@ -8,8 +8,7 @@ load(
go_binary(
name = "test-webserver",
importpath = "k8s.io/kubernetes/test/images/test-webserver",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -13,7 +13,7 @@
# limitations under the License.
TAG = 0.1
PREFIX = gcr.io/google_containers
PREFIX = staging-k8s.gcr.io
all: push
@ -24,7 +24,7 @@ image:
docker tag $(PREFIX)/volume-ceph $(PREFIX)/volume-ceph:$(TAG) # Add the version tag to the latest image
push: image
gcloud docker -- push $(PREFIX)/volume-ceph # Push image tagged as latest to repository
gcloud docker -- push $(PREFIX)/volume-ceph:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
docker push $(PREFIX)/volume-ceph # Push image tagged as latest to repository
docker push $(PREFIX)/volume-ceph:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
clean:

View File

@ -13,7 +13,7 @@
# limitations under the License.
TAG = 0.4
PREFIX = gcr.io/google_containers
PREFIX = staging-k8s.gcr.io
all: push
@ -24,7 +24,7 @@ image:
docker tag $(PREFIX)/volume-gluster $(PREFIX)/volume-gluster:$(TAG) # Add the version tag to the latest image
push: image
gcloud docker -- push $(PREFIX)/volume-gluster # Push image tagged as latest to repository
gcloud docker -- push $(PREFIX)/volume-gluster:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
docker push $(PREFIX)/volume-gluster # Push image tagged as latest to repository
docker push $(PREFIX)/volume-gluster:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
clean:

View File

@ -13,7 +13,7 @@
# limitations under the License.
TAG = 0.1
PREFIX = gcr.io/google_containers
PREFIX = staging-k8s.gcr.io
all: push
@ -34,8 +34,8 @@ block:
push: image
# Push image tagged as latest to repository
gcloud docker -- push $(PREFIX)/volume-iscsi
docker push $(PREFIX)/volume-iscsi
# Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
gcloud docker -- push $(PREFIX)/volume-iscsi:$(TAG)
docker push $(PREFIX)/volume-iscsi:$(TAG)
clean:

View File

@ -13,7 +13,7 @@
# limitations under the License.
TAG = 0.8
PREFIX = gcr.io/google_containers
PREFIX = staging-k8s.gcr.io
all: push
@ -24,7 +24,7 @@ image:
docker tag $(PREFIX)/volume-nfs $(PREFIX)/volume-nfs:$(TAG) # Add the version tag to the latest image
push: image
gcloud docker -- push $(PREFIX)/volume-nfs # Push image tagged as latest to repository
gcloud docker -- push $(PREFIX)/volume-nfs:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
docker push $(PREFIX)/volume-nfs # Push image tagged as latest to repository
docker push $(PREFIX)/volume-nfs:$(TAG) # Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
clean:

View File

@ -13,7 +13,7 @@
# limitations under the License.
TAG = 0.1
PREFIX = gcr.io/google_containers
PREFIX = staging-k8s.gcr.io
all: push
@ -34,8 +34,8 @@ block:
push: image
# Push image tagged as latest to repository
gcloud docker -- push $(PREFIX)/volume-rbd
docker push $(PREFIX)/volume-rbd
# Push version tagged image to repository (since this image is already pushed it will simply create or update version tag)
gcloud docker -- push $(PREFIX)/volume-rbd:$(TAG)
docker push $(PREFIX)/volume-rbd:$(TAG)
clean:

View File

@ -24,8 +24,7 @@ go_library(
go_binary(
name = "webhook",
importpath = "k8s.io/kubernetes/test/images/webhook",
library = ":go_default_library",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
@ -46,8 +45,7 @@ filegroup(
go_test(
name = "go_default_test",
srcs = ["patch_test.go"],
importpath = "k8s.io/kubernetes/test/images/webhook",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/evanphx/json-patch:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",

View File

@ -14,7 +14,7 @@
build:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o webhook .
docker build --no-cache -t gcr.io/kubernetes-e2e-test-images/k8s-sample-admission-webhook-amd64:1.8v6 .
docker build --no-cache -t gcr.io/kubernetes-e2e-test-images/k8s-sample-admission-webhook-amd64:1.9v1 .
rm -rf webhook
push:
gcloud docker -- push gcr.io/kubernetes-e2e-test-images/k8s-sample-admission-webhook-amd64:1.8v6
docker push gcr.io/kubernetes-e2e-test-images/k8s-sample-admission-webhook-amd64:1.9v1

View File

@ -1,51 +1,13 @@
# Kubernetes External Admission Webhook Example
# Kubernetes External Admission Webhook Test Image
The example shows how to build and deploy an external webhook that only admits
pods creation and update if the container images have the "grc.io" prefix.
The image tests MutatingAdmissionWebhook and ValidatingAdmissionWebhook. After deploying
it to kubernetes cluster, administrator needs to create a ValidatingWebhookConfiguration
in kubernetes cluster to register remote webhook admission controllers.
## Prerequisites
Please use a Kubernetes release at least as new as v1.8.0 or v1.9.0-alpha.1,
because the generated server cert/key only works with Kubernetes release that
contains this [change](https://github.com/kubernetes/kubernetes/pull/50476).
Please checkout the `pre-v1.8` tag for an example that works with older
clusters.
Please enable the admission webhook feature
([doc](https://kubernetes.io/docs/admin/extensible-admission-controllers/#enable-external-admission-webhooks)).
TODO: add the reference when the document for admission webhook v1beta1 API is done.
## Build the code
```bash
make build
```
## Deploy the code
```bash
make deploy-only
```
The Makefile assumes your cluster is created by the
[hack/local-up-cluster.sh](https://github.com/kubernetes/kubernetes/blob/master/hack/local-up-cluster.sh).
Please modify the Makefile accordingly if your cluster is created differently.
## Explanation on the CAs/Certs/Keys
The apiserver initiates a tls connection with the webhook, so the apiserver is
the tls client, and the webhook is the tls server.
The webhook proves its identity by the `serverCert` in the certs.go. The server
cert is signed by the CA in certs.go. To let the apiserver trust the `caCert`,
the webhook registers itself with the apiserver via the
`admissionregistration/v1beta1/externalAdmissionHook` API, with
`clientConfig.caBundle=caCert`.
For maximum protection, this example webhook requires and verifies the client
(i.e., the apiserver in this case) cert. The cert presented by the apiserver is
signed by a client CA, whose cert is stored in the configmap
`extension-apiserver-authentication` in the `kube-system` namespace. See the
`getAPIServerCert` function for more information. Usually you don't need to
worry about setting up this CA cert. It's taken care of when the cluster is
created. You can disable the client cert verification by setting the
`tls.Config.ClientAuth` to `tls.NoClientCert` in `config.go`.

View File

@ -40,6 +40,9 @@ const (
patch2 string = `[
{ "op": "add", "path": "/data/mutation-stage-2", "value": "yes" }
]`
addInitContainerPatch string = `[
{"op":"add","path":"/spec/initContainers","value":[{"image":"webhook-added-image","name":"webhook-added-init-container","resources":{}}]}
]`
)
// Config contains the server (the webhook) cert and key.
@ -85,11 +88,16 @@ func admitPods(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
reviewResponse.Allowed = true
var msg string
for k, v := range pod.Labels {
if k == "webhook-e2e-test" && v == "webhook-disallow" {
if v, ok := pod.Labels["webhook-e2e-test"]; ok {
if v == "webhook-disallow" {
reviewResponse.Allowed = false
msg = msg + "the pod contains unwanted label; "
}
if v == "wait-forever" {
reviewResponse.Allowed = false
msg = msg + "the pod response should not be sent; "
<-make(chan int) // Sleep forever - no one sends to this channel
}
}
for _, container := range pod.Spec.Containers {
if strings.Contains(container.Name, "webhook-disallow") {
@ -103,6 +111,31 @@ func admitPods(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
return &reviewResponse
}
func mutatePods(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
glog.V(2).Info("mutating pods")
podResource := metav1.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}
if ar.Request.Resource != podResource {
glog.Errorf("expect resource to be %s", podResource)
return nil
}
raw := ar.Request.Object.Raw
pod := corev1.Pod{}
deserializer := codecs.UniversalDeserializer()
if _, _, err := deserializer.Decode(raw, nil, &pod); err != nil {
glog.Error(err)
return toAdmissionResponse(err)
}
reviewResponse := v1beta1.AdmissionResponse{}
reviewResponse.Allowed = true
if pod.Name == "webhook-to-be-mutated" {
reviewResponse.Patch = []byte(addInitContainerPatch)
pt := v1beta1.PatchTypeJSONPatch
reviewResponse.PatchType = &pt
}
return &reviewResponse
}
// deny configmaps with specific key-value pair.
func admitConfigMaps(ar v1beta1.AdmissionReview) *v1beta1.AdmissionResponse {
glog.V(2).Info("admitting configmaps")
@ -266,6 +299,10 @@ func servePods(w http.ResponseWriter, r *http.Request) {
serve(w, r, admitPods)
}
func serveMutatePods(w http.ResponseWriter, r *http.Request) {
serve(w, r, mutatePods)
}
func serveConfigmaps(w http.ResponseWriter, r *http.Request) {
serve(w, r, admitConfigMaps)
}
@ -288,6 +325,7 @@ func main() {
flag.Parse()
http.HandleFunc("/pods", servePods)
http.HandleFunc("/mutating-pods", serveMutatePods)
http.HandleFunc("/configmaps", serveConfigmaps)
http.HandleFunc("/mutating-configmaps", serveMutateConfigmaps)
http.HandleFunc("/crd", serveCRD)