mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
vendor files
This commit is contained in:
37
vendor/k8s.io/kubernetes/test/images/BUILD
generated
vendored
Normal file
37
vendor/k8s.io/kubernetes/test/images/BUILD
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//test/images/clusterapi-tester:all-srcs",
|
||||
"//test/images/entrypoint-tester:all-srcs",
|
||||
"//test/images/fakegitserver:all-srcs",
|
||||
"//test/images/goproxy:all-srcs",
|
||||
"//test/images/liveness:all-srcs",
|
||||
"//test/images/logs-generator:all-srcs",
|
||||
"//test/images/mounttest:all-srcs",
|
||||
"//test/images/n-way-http:all-srcs",
|
||||
"//test/images/net:all-srcs",
|
||||
"//test/images/netexec:all-srcs",
|
||||
"//test/images/nettest:all-srcs",
|
||||
"//test/images/no-snat-test:all-srcs",
|
||||
"//test/images/no-snat-test-proxy:all-srcs",
|
||||
"//test/images/nonewprivs:all-srcs",
|
||||
"//test/images/pets/peer-finder:all-srcs",
|
||||
"//test/images/port-forward-tester:all-srcs",
|
||||
"//test/images/porter:all-srcs",
|
||||
"//test/images/resource-consumer:all-srcs",
|
||||
"//test/images/serve-hostname:all-srcs",
|
||||
"//test/images/test-webserver:all-srcs",
|
||||
"//test/images/webhook:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
40
vendor/k8s.io/kubernetes/test/images/Makefile
generated
vendored
Normal file
40
vendor/k8s.io/kubernetes/test/images/Makefile
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
REGISTRY ?= gcr.io/kubernetes-e2e-test-images
|
||||
GOARM=7
|
||||
QEMUVERSION=v2.9.1
|
||||
GOLANG_VERSION=1.9.2
|
||||
export
|
||||
|
||||
ifndef WHAT
|
||||
$(error WHAT is a required variable, ex: make all WHAT=net)
|
||||
endif
|
||||
|
||||
# Build code.
|
||||
#
|
||||
# Args:
|
||||
# WHAT: Directory names to build.
|
||||
#
|
||||
# Example:
|
||||
# make all WHAT=clusterapi-tester
|
||||
all: all-container
|
||||
|
||||
all-container:
|
||||
./image-util.sh build $(WHAT)
|
||||
|
||||
all-push: all-container
|
||||
./image-util.sh push $(WHAT)
|
||||
|
||||
.PHONY: all all-push all-container
|
5
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/BASEIMAGE
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
amd64=busybox
|
||||
arm=arm32v6/busybox
|
||||
arm64=arm64v8/busybox
|
||||
ppc64le=ppc64le/busybox
|
||||
s390x=s390x/busybox
|
37
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/BUILD
generated
vendored
Normal file
37
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/BUILD
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "clusterapi-tester",
|
||||
importpath = "k8s.io/kubernetes/test/images/clusterapi-tester",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["clusterapi-tester.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/clusterapi-tester",
|
||||
deps = [
|
||||
"//pkg/client/clientset_generated/internalclientset:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/client-go/rest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
17
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/Dockerfile
generated
vendored
Normal file
17
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2016 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
|
||||
ADD clusterapi-tester /clusterapi-tester
|
||||
ENTRYPOINT ["/clusterapi-tester"]
|
25
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS = clusterapi-tester
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
64
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/clusterapi-tester.go
generated
vendored
Normal file
64
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/clusterapi-tester.go
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
// A simple pod that first lists all nodes/services through the Kubernetes
|
||||
// api, then serves a 200 on /healthz.
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cc, err := restclient.InClusterConfig()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create client: %v", err)
|
||||
}
|
||||
|
||||
kubeClient, err := clientset.NewForConfig(cc)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create client: %v", err)
|
||||
}
|
||||
listAll := metav1.ListOptions{}
|
||||
nodes, err := kubeClient.Core().Nodes().List(listAll)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to list nodes: %v", err)
|
||||
}
|
||||
log.Printf("Nodes:")
|
||||
for _, node := range nodes.Items {
|
||||
log.Printf("\t%v", node.Name)
|
||||
}
|
||||
services, err := kubeClient.Core().Services(metav1.NamespaceDefault).List(listAll)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to list services: %v", err)
|
||||
}
|
||||
log.Printf("Services:")
|
||||
for _, svc := range services.Items {
|
||||
log.Printf("\t%v", svc.Name)
|
||||
}
|
||||
log.Printf("Success")
|
||||
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Ok")
|
||||
})
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
19
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/pod.yaml
generated
vendored
Normal file
19
vendor/k8s.io/kubernetes/test/images/clusterapi-tester/pod.yaml
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: clusterapi-tester
|
||||
spec:
|
||||
containers:
|
||||
- image: gcr.io/kubernetes-e2e-test-images/clusterapi-tester-amd64:1.0
|
||||
name: clusterapi-tester
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
restartPolicy: OnFailure
|
2
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/BASEIMAGE
generated
vendored
Normal file
2
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
amd64=nvidia/cuda:8.0-devel-ubuntu16.04
|
||||
ppc64le=nvidia/cuda-ppc64le:8.0-devel-ubuntu16.04
|
26
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/Dockerfile
generated
vendored
Normal file
26
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
# Copyright 2017 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 apt-get update && apt-get install -y --no-install-recommends \
|
||||
cuda-samples-$CUDA_PKG_VERSION && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /usr/local/cuda/samples/0_Simple/vectorAdd
|
||||
RUN make
|
||||
|
||||
CMD ./vectorAdd
|
13
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/README.md
generated
vendored
Normal file
13
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/README.md
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
## cuda_vector_add
|
||||
|
||||
This is a small CUDA application that performs a simple vector addition. Useful for testing CUDA support in Kubernetes.
|
||||
|
||||
## How to release:
|
||||
|
||||
```
|
||||
# Build
|
||||
$ make
|
||||
|
||||
# Push
|
||||
$ make push
|
||||
```
|
1
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/cuda-vector-add/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
4
vendor/k8s.io/kubernetes/test/images/dnsutils/BASEIMAGE
generated
vendored
Normal file
4
vendor/k8s.io/kubernetes/test/images/dnsutils/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
amd64=alpine:3.6
|
||||
arm=arm32v6/alpine:3.6
|
||||
arm64=arm64v8/alpine:3.6
|
||||
ppc64le=ppc64le/alpine:3.6
|
19
vendor/k8s.io/kubernetes/test/images/dnsutils/Dockerfile
generated
vendored
Normal file
19
vendor/k8s.io/kubernetes/test/images/dnsutils/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2016 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 bind-tools
|
1
vendor/k8s.io/kubernetes/test/images/dnsutils/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/dnsutils/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
32
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/BUILD
generated
vendored
Normal file
32
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/BUILD
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "entrypoint-tester",
|
||||
importpath = "k8s.io/kubernetes/test/images/entrypoint-tester",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["ep.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/entrypoint-tester",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
20
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/Dockerfile
generated
vendored
Normal file
20
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2016 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 scratch
|
||||
ADD ep ep
|
||||
ADD ep ep-2
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/ep"]
|
||||
CMD ["default", "arguments"]
|
25
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=ep
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
29
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/ep.go
generated
vendored
Normal file
29
vendor/k8s.io/kubernetes/test/images/entrypoint-tester/ep.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2015 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// This program prints the arguments it's passed and exits.
|
||||
func main() {
|
||||
args := os.Args
|
||||
fmt.Printf("%v\n", args)
|
||||
os.Exit(0)
|
||||
}
|
32
vendor/k8s.io/kubernetes/test/images/fakegitserver/BUILD
generated
vendored
Normal file
32
vendor/k8s.io/kubernetes/test/images/fakegitserver/BUILD
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "fakegitserver",
|
||||
importpath = "k8s.io/kubernetes/test/images/fakegitserver",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["gitserver.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/fakegitserver",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
19
vendor/k8s.io/kubernetes/test/images/fakegitserver/Dockerfile
generated
vendored
Normal file
19
vendor/k8s.io/kubernetes/test/images/fakegitserver/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2016 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 scratch
|
||||
COPY GITHASH.txt /
|
||||
COPY fakegitserver /
|
||||
ENTRYPOINT ["/fakegitserver"]
|
||||
|
27
vendor/k8s.io/kubernetes/test/images/fakegitserver/Makefile
generated
vendored
Normal file
27
vendor/k8s.io/kubernetes/test/images/fakegitserver/Makefile
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS = fakegitserver
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
IGNORE := $(shell git rev-parse HEAD > $(TARGET)/GITHASH.txt)
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/fakegitserver/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/fakegitserver/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
34
vendor/k8s.io/kubernetes/test/images/fakegitserver/gitserver.go
generated
vendored
Normal file
34
vendor/k8s.io/kubernetes/test/images/fakegitserver/gitserver.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2016 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func hello(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, "I am a fake git server")
|
||||
|
||||
}
|
||||
|
||||
// When doing `git clone localhost:8000`, you will clone an empty git repo named "8000" on local.
|
||||
// You can also use `git clone localhost:8000 my-repo-name` to rename that repo.
|
||||
func main() {
|
||||
http.HandleFunc("/", hello)
|
||||
http.ListenAndServe(":8000", nil)
|
||||
}
|
1
vendor/k8s.io/kubernetes/test/images/goproxy/.gitignore
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/goproxy/.gitignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
goproxy
|
33
vendor/k8s.io/kubernetes/test/images/goproxy/BUILD
generated
vendored
Normal file
33
vendor/k8s.io/kubernetes/test/images/goproxy/BUILD
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "goproxy",
|
||||
importpath = "k8s.io/kubernetes/test/images/goproxy",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["goproxy.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/goproxy",
|
||||
deps = ["//vendor/github.com/elazarl/goproxy:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
18
vendor/k8s.io/kubernetes/test/images/goproxy/Dockerfile
generated
vendored
Normal file
18
vendor/k8s.io/kubernetes/test/images/goproxy/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright 2016 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 scratch
|
||||
ADD goproxy goproxy
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/goproxy"]
|
25
vendor/k8s.io/kubernetes/test/images/goproxy/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/goproxy/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=goproxy
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/goproxy/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/goproxy/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
30
vendor/k8s.io/kubernetes/test/images/goproxy/goproxy.go
generated
vendored
Normal file
30
vendor/k8s.io/kubernetes/test/images/goproxy/goproxy.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2015 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/elazarl/goproxy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
proxy := goproxy.NewProxyHttpServer()
|
||||
proxy.Verbose = true
|
||||
log.Fatal(http.ListenAndServe(":8080", proxy))
|
||||
}
|
16
vendor/k8s.io/kubernetes/test/images/goproxy/pod.yaml
generated
vendored
Normal file
16
vendor/k8s.io/kubernetes/test/images/goproxy/pod.yaml
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: goproxy
|
||||
labels:
|
||||
app: goproxy
|
||||
spec:
|
||||
containers:
|
||||
- name: goproxy
|
||||
image: gcr.io/kubernetes-e2e-test-images/goproxy-amd64:1.0
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: 8080
|
||||
|
4
vendor/k8s.io/kubernetes/test/images/hostexec/BASEIMAGE
generated
vendored
Normal file
4
vendor/k8s.io/kubernetes/test/images/hostexec/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
amd64=alpine:3.6
|
||||
arm=arm32v6/alpine:3.6
|
||||
arm64=arm64v8/alpine:3.6
|
||||
ppc64le=ppc64le/alpine:3.6
|
25
vendor/k8s.io/kubernetes/test/images/hostexec/Dockerfile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/hostexec/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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/
|
||||
|
||||
# install necessary packages:
|
||||
# - curl, nc: used by a lot of e2e tests
|
||||
# - iproute2: includes ss used in NodePort tests
|
||||
RUN apk --update add curl netcat-openbsd iproute2 && rm -rf /var/cache/apk/*
|
||||
|
||||
# wait forever
|
||||
CMD rm -f /fifo && mkfifo /fifo && exec cat </fifo
|
1
vendor/k8s.io/kubernetes/test/images/hostexec/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/hostexec/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
12
vendor/k8s.io/kubernetes/test/images/hostexec/pod.yaml
generated
vendored
Normal file
12
vendor/k8s.io/kubernetes/test/images/hostexec/pod.yaml
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: hostexec
|
||||
labels:
|
||||
app: hostexec
|
||||
spec:
|
||||
containers:
|
||||
- name: hostexec
|
||||
image: gcr.io/kubernetes-e2e-test-images/hostexec-amd64:1.0
|
||||
securityContext:
|
||||
hostNetwork: true
|
118
vendor/k8s.io/kubernetes/test/images/image-util.sh
generated
vendored
Executable file
118
vendor/k8s.io/kubernetes/test/images/image-util.sh
generated
vendored
Executable file
@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 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.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
TASK=$1
|
||||
IMAGE=$2
|
||||
|
||||
KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)"
|
||||
|
||||
# Mapping of go ARCH to actual architectures shipped part of multiarch/qemu-user-static project
|
||||
declare -A QEMUARCHS=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["ppc64le"]="ppc64le" ["s390x"]="s390x" )
|
||||
|
||||
# Returns list of all supported architectures from BASEIMAGE file
|
||||
listArchs() {
|
||||
cut -d "=" -f 1 ${IMAGE}/BASEIMAGE
|
||||
}
|
||||
|
||||
# Returns baseimage need to used in Dockerfile for any given architecture
|
||||
getBaseImage() {
|
||||
arch=$1
|
||||
echo $(grep "${arch}=" BASEIMAGE | cut -d= -f2)
|
||||
}
|
||||
|
||||
# This function will build test image for all the architectures
|
||||
# mentioned in BASEIMAGE file. In the absence of BASEIMAGE file,
|
||||
# it will build for all the supported arch list - amd64, arm,
|
||||
# arm64, ppc64le, s390x
|
||||
build() {
|
||||
if [[ -f ${IMAGE}/BASEIMAGE ]]; then
|
||||
archs=$(listArchs)
|
||||
else
|
||||
archs=${!QEMUARCHS[@]}
|
||||
fi
|
||||
|
||||
for arch in ${archs}; do
|
||||
echo "Building image for ${IMAGE} ARCH: ${arch}..."
|
||||
|
||||
# Create a temporary directory for every architecture and copy the image content
|
||||
# and build the image from temporary directory
|
||||
temp_dir=$(mktemp -d)
|
||||
cp -r ${IMAGE}/* ${temp_dir}
|
||||
if [[ -f ${IMAGE}/Makefile ]]; then
|
||||
# make bin will take care of all the prerequisites needed
|
||||
# for building the docker image
|
||||
make -C ${IMAGE} bin ARCH=${arch} TARGET=${temp_dir}
|
||||
fi
|
||||
pushd ${temp_dir}
|
||||
# image tag
|
||||
TAG=$(<VERSION)
|
||||
|
||||
if [[ -f BASEIMAGE ]]; then
|
||||
BASEIMAGE=$(getBaseImage ${arch})
|
||||
sed -i "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
|
||||
fi
|
||||
|
||||
# copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform
|
||||
if [[ $(grep "CROSS_BUILD_" Dockerfile) ]]; then
|
||||
if [[ "${arch}" == "amd64" ]]; then
|
||||
sed -i "/CROSS_BUILD_/d" Dockerfile
|
||||
else
|
||||
sed -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile
|
||||
# Register qemu-*-static for all supported processors except the current one
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/${QEMUVERSION}/x86_64_qemu-${QEMUARCHS[$arch]}-static.tar.gz | tar -xz -C ${temp_dir}
|
||||
sed -i "s/CROSS_BUILD_//g" Dockerfile
|
||||
fi
|
||||
fi
|
||||
|
||||
docker build --pull -t ${REGISTRY}/${IMAGE}-${arch}:${TAG} .
|
||||
|
||||
popd
|
||||
done
|
||||
}
|
||||
|
||||
# This function will push the docker images
|
||||
push() {
|
||||
if [[ -f ${IMAGE}/BASEIMAGE ]]; then
|
||||
archs=$(listArchs)
|
||||
else
|
||||
archs=${!QEMUARCHS[@]}
|
||||
fi
|
||||
for arch in ${archs}; do
|
||||
TAG=$(<${IMAGE}/VERSION)
|
||||
gcloud docker -- push ${REGISTRY}/${IMAGE}-${arch}:${TAG}
|
||||
done
|
||||
}
|
||||
|
||||
# This function is for building the go code
|
||||
bin() {
|
||||
for SRC in $@;
|
||||
do
|
||||
docker run --rm -it -v ${TARGET}:${TARGET}:Z -v ${KUBE_ROOT}:/go/src/k8s.io/kubernetes:Z \
|
||||
golang:${GOLANG_VERSION} \
|
||||
/bin/bash -c "\
|
||||
cd /go/src/k8s.io/kubernetes/test/images/${SRC_DIR} && \
|
||||
CGO_ENABLED=0 GOARM=${GOARM} GOARCH=${ARCH} go build -a -installsuffix cgo --ldflags '-w' -o ${TARGET}/${SRC} ./$(dirname ${SRC})"
|
||||
done
|
||||
}
|
||||
|
||||
shift
|
||||
|
||||
eval ${TASK} "$@"
|
4
vendor/k8s.io/kubernetes/test/images/iperf/BASEIMAGE
generated
vendored
Normal file
4
vendor/k8s.io/kubernetes/test/images/iperf/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +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
|
23
vendor/k8s.io/kubernetes/test/images/iperf/Dockerfile
generated
vendored
Normal file
23
vendor/k8s.io/kubernetes/test/images/iperf/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright 2016 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 apt-get update && apt-get install -y --no-install-recommends iperf bash \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -s /usr/bin/iperf /usr/local/bin/iperf
|
||||
RUN ls -altrh /usr/local/bin/iperf
|
8
vendor/k8s.io/kubernetes/test/images/iperf/README.md
generated
vendored
Normal file
8
vendor/k8s.io/kubernetes/test/images/iperf/README.md
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
This is a dockerfile which we curate inside of kubernetes for running iperf as a service.
|
||||
|
||||
Eventually we would like to update it to iperf3.
|
||||
|
||||
Possibly we might even start using a pure go based iperf and maintain the same cmd line abstraction.
|
||||
|
||||
|
||||
[]()
|
1
vendor/k8s.io/kubernetes/test/images/iperf/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/iperf/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
4
vendor/k8s.io/kubernetes/test/images/jessie-dnsutils/BASEIMAGE
generated
vendored
Normal file
4
vendor/k8s.io/kubernetes/test/images/jessie-dnsutils/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
amd64=debian:jessie
|
||||
arm=arm32v7/debian:jessie
|
||||
arm64=arm64v8/debian:jessie
|
||||
ppc64le=ppc64le/debian:jessie
|
21
vendor/k8s.io/kubernetes/test/images/jessie-dnsutils/Dockerfile
generated
vendored
Normal file
21
vendor/k8s.io/kubernetes/test/images/jessie-dnsutils/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright 2016 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 apt-get -q update && \
|
||||
apt-get install -y dnsutils && \
|
||||
apt-get clean
|
1
vendor/k8s.io/kubernetes/test/images/jessie-dnsutils/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/jessie-dnsutils/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
5
vendor/k8s.io/kubernetes/test/images/kitten/BASEIMAGE
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/test/images/kitten/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
amd64=gcr.io/kubernetes-e2e-test-images/test-webserver-amd64:1.0
|
||||
arm=gcr.io/kubernetes-e2e-test-images/test-webserver-arm:1.0
|
||||
arm64=gcr.io/kubernetes-e2e-test-images/test-webserver-arm64:1.0
|
||||
ppc64le=gcr.io/kubernetes-e2e-test-images/test-webserver-ppc64le:1.0
|
||||
s390x=gcr.io/kubernetes-e2e-test-images/test-webserver-s390x:1.0
|
17
vendor/k8s.io/kubernetes/test/images/kitten/Dockerfile
generated
vendored
Normal file
17
vendor/k8s.io/kubernetes/test/images/kitten/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2016 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
|
||||
COPY html/kitten.jpg kitten.jpg
|
||||
COPY html/data.json data.json
|
1
vendor/k8s.io/kubernetes/test/images/kitten/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/kitten/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
3
vendor/k8s.io/kubernetes/test/images/kitten/html/data.json
generated
vendored
Normal file
3
vendor/k8s.io/kubernetes/test/images/kitten/html/data.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"image": "kitten.jpg"
|
||||
}
|
BIN
vendor/k8s.io/kubernetes/test/images/kitten/html/kitten.jpg
generated
vendored
Normal file
BIN
vendor/k8s.io/kubernetes/test/images/kitten/html/kitten.jpg
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
32
vendor/k8s.io/kubernetes/test/images/liveness/BUILD
generated
vendored
Normal file
32
vendor/k8s.io/kubernetes/test/images/liveness/BUILD
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "liveness",
|
||||
importpath = "k8s.io/kubernetes/test/images/liveness",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["server.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/liveness",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
17
vendor/k8s.io/kubernetes/test/images/liveness/Dockerfile
generated
vendored
Normal file
17
vendor/k8s.io/kubernetes/test/images/liveness/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2016 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 scratch
|
||||
|
||||
COPY liveness /server
|
25
vendor/k8s.io/kubernetes/test/images/liveness/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/liveness/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS = liveness
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/liveness/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/liveness/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
46
vendor/k8s.io/kubernetes/test/images/liveness/server.go
generated
vendored
Normal file
46
vendor/k8s.io/kubernetes/test/images/liveness/server.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
// A simple server that is alive for 10 seconds, then reports unhealthy for
|
||||
// the rest of its (hopefully) short existence.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
started := time.Now()
|
||||
http.HandleFunc("/started", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(200)
|
||||
data := (time.Now().Sub(started)).String()
|
||||
w.Write([]byte(data))
|
||||
})
|
||||
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
duration := time.Now().Sub(started)
|
||||
if duration.Seconds() > 10 {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte(fmt.Sprintf("error: %v", duration.Seconds())))
|
||||
} else {
|
||||
w.WriteHeader(200)
|
||||
w.Write([]byte("ok"))
|
||||
}
|
||||
})
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
4
vendor/k8s.io/kubernetes/test/images/logs-generator/BASEIMAGE
generated
vendored
Normal file
4
vendor/k8s.io/kubernetes/test/images/logs-generator/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
amd64=busybox
|
||||
arm=arm32v6/busybox
|
||||
arm64=arm64v8/busybox
|
||||
ppc64le=ppc64le/busybox
|
36
vendor/k8s.io/kubernetes/test/images/logs-generator/BUILD
generated
vendored
Normal file
36
vendor/k8s.io/kubernetes/test/images/logs-generator/BUILD
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "logs-generator",
|
||||
importpath = "k8s.io/kubernetes/test/images/logs-generator",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["logs_generator.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/logs-generator",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
22
vendor/k8s.io/kubernetes/test/images/logs-generator/Dockerfile
generated
vendored
Normal file
22
vendor/k8s.io/kubernetes/test/images/logs-generator/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright 2016 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
|
||||
|
||||
ENV LOGS_GENERATOR_LINES_TOTAL 1
|
||||
ENV LOGS_GENERATOR_DURATION 1s
|
||||
|
||||
COPY logs-generator /
|
||||
|
||||
CMD ["sh", "-c", "/logs-generator --logtostderr --log-lines-total=${LOGS_GENERATOR_LINES_TOTAL} --run-duration=${LOGS_GENERATOR_DURATION}"]
|
25
vendor/k8s.io/kubernetes/test/images/logs-generator/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/logs-generator/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=logs-generator
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
57
vendor/k8s.io/kubernetes/test/images/logs-generator/README.md
generated
vendored
Normal file
57
vendor/k8s.io/kubernetes/test/images/logs-generator/README.md
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
# Logs Generator
|
||||
|
||||
## Overview
|
||||
|
||||
Logs generator is a tool to create predictable load on the logs delivery system.
|
||||
Is generates random lines with predictable format and predictable average length.
|
||||
Each line can be later uniquely identified to ensure logs delivery.
|
||||
|
||||
## Usage
|
||||
|
||||
Tool is parametrized with the total number of number that should be generated and the duration of
|
||||
the generation process. For example, if you want to create a throughput of 100 lines per second
|
||||
for a minute, you set total number of lines to 6000 and duration to 1 minute.
|
||||
|
||||
Parameters are passed through environment variables. There are no defaults, you should always
|
||||
set up container parameters. Total number of line is parametrized through env variable
|
||||
`LOGS_GENERATOR_LINES_TOTAL` and duration in go format is parametrized through env variable
|
||||
`LOGS_GENERATOR_DURATION`.
|
||||
|
||||
Inside the container all log lines are written to the stdout.
|
||||
|
||||
Each line is on average 100 bytes long and follows this pattern:
|
||||
|
||||
```
|
||||
2000-12-31T12:59:59Z <id> <method> /api/v1/namespaces/<namespace>/endpoints/<random_string> <random_number>
|
||||
```
|
||||
|
||||
Where `<id>` refers to the number from 0 to `total_lines - 1`, which is unique for each
|
||||
line in a given run of the container.
|
||||
|
||||
## Image
|
||||
|
||||
Image is located in the public repository of Google Container Registry under the name
|
||||
|
||||
```
|
||||
gcr.io/google_containers/logs-generator:v0.1.1
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
docker run -i \
|
||||
-e "LOGS_GENERATOR_LINES_TOTAL=10" \
|
||||
-e "LOGS_GENERATOR_DURATION=1s" \
|
||||
gcr.io/google_containers/logs-generator:v0.1.1
|
||||
```
|
||||
|
||||
```
|
||||
kubectl run logs-generator \
|
||||
--generator=run-pod/v1 \
|
||||
--image=gcr.io/google_containers/logs-generator:v0.1.1 \
|
||||
--restart=Never \
|
||||
--env "LOGS_GENERATOR_LINES_TOTAL=1000" \
|
||||
--env "LOGS_GENERATOR_DURATION=1m"
|
||||
```
|
||||
|
||||
[]()
|
1
vendor/k8s.io/kubernetes/test/images/logs-generator/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/logs-generator/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
82
vendor/k8s.io/kubernetes/test/images/logs-generator/logs_generator.go
generated
vendored
Normal file
82
vendor/k8s.io/kubernetes/test/images/logs-generator/logs_generator.go
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
Copyright 2016 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/apimachinery/pkg/util/rand"
|
||||
)
|
||||
|
||||
var (
|
||||
httpMethods = []string{
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
}
|
||||
namespaces = []string{
|
||||
"kube-system",
|
||||
"default",
|
||||
"ns",
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
linesTotal = flag.Int("log-lines-total", 0, "Total lines that should be generated by the end of the run")
|
||||
duration = flag.Duration("run-duration", 0, "Total duration of the run")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *linesTotal <= 0 {
|
||||
glog.Fatalf("Invalid total number of lines: %d", *linesTotal)
|
||||
}
|
||||
|
||||
if *duration <= 0 {
|
||||
glog.Fatalf("Invalid duration: %v", *duration)
|
||||
}
|
||||
|
||||
generateLogs(*linesTotal, *duration)
|
||||
}
|
||||
|
||||
// Outputs linesTotal lines of logs to stdout uniformly for duration
|
||||
func generateLogs(linesTotal int, duration time.Duration) {
|
||||
delay := duration / time.Duration(linesTotal)
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
tick := time.Tick(delay)
|
||||
for id := 0; id < linesTotal; id++ {
|
||||
glog.Info(generateLogLine(id))
|
||||
<-tick
|
||||
}
|
||||
}
|
||||
|
||||
// Generates apiserver-like line with average length of 100 symbols
|
||||
func generateLogLine(id int) string {
|
||||
method := httpMethods[rand.Intn(len(httpMethods))]
|
||||
namespace := namespaces[rand.Intn(len(namespaces))]
|
||||
|
||||
podName := rand.String(rand.IntnRange(3, 5))
|
||||
url := fmt.Sprintf("/api/v1/namespaces/%s/pods/%s", namespace, podName)
|
||||
status := rand.IntnRange(200, 600)
|
||||
|
||||
return fmt.Sprintf("%d %s %s %d", id, method, url, status)
|
||||
}
|
5
vendor/k8s.io/kubernetes/test/images/mounttest-user/BASEIMAGE
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/test/images/mounttest-user/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
amd64=gcr.io/kubernetes-e2e-test-images/mounttest-amd64:1.0
|
||||
arm=gcr.io/kubernetes-e2e-test-images/mounttest-arm:1.0
|
||||
arm64=gcr.io/kubernetes-e2e-test-images/mounttest-arm64:1.0
|
||||
ppc64le=gcr.io/kubernetes-e2e-test-images/mounttest-ppc64le:1.0
|
||||
s390x=gcr.io/kubernetes-e2e-test-images/mounttest-s390x:1.0
|
16
vendor/k8s.io/kubernetes/test/images/mounttest-user/Dockerfile
generated
vendored
Normal file
16
vendor/k8s.io/kubernetes/test/images/mounttest-user/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright 2016 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
|
||||
USER 1001
|
1
vendor/k8s.io/kubernetes/test/images/mounttest-user/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/mounttest-user/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
32
vendor/k8s.io/kubernetes/test/images/mounttest/BUILD
generated
vendored
Normal file
32
vendor/k8s.io/kubernetes/test/images/mounttest/BUILD
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["mt.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/mounttest",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "mounttest",
|
||||
importpath = "k8s.io/kubernetes/test/images/mounttest",
|
||||
library = ":go_default_library",
|
||||
)
|
17
vendor/k8s.io/kubernetes/test/images/mounttest/Dockerfile
generated
vendored
Normal file
17
vendor/k8s.io/kubernetes/test/images/mounttest/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2016 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 scratch
|
||||
COPY mounttest /
|
||||
ENTRYPOINT ["/mounttest"]
|
25
vendor/k8s.io/kubernetes/test/images/mounttest/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/mounttest/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=mounttest
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/mounttest/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/mounttest/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
268
vendor/k8s.io/kubernetes/test/images/mounttest/mt.go
generated
vendored
Normal file
268
vendor/k8s.io/kubernetes/test/images/mounttest/mt.go
generated
vendored
Normal file
@ -0,0 +1,268 @@
|
||||
/*
|
||||
Copyright 2015 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
fsTypePath = ""
|
||||
fileModePath = ""
|
||||
filePermPath = ""
|
||||
fileOwnerPath = ""
|
||||
newFilePath0644 = ""
|
||||
newFilePath0666 = ""
|
||||
newFilePath0660 = ""
|
||||
newFilePath0777 = ""
|
||||
readFileContentPath = ""
|
||||
readFileContentInLoopPath = ""
|
||||
retryDuration = 180
|
||||
breakOnExpectedContent = true
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&fsTypePath, "fs_type", "", "Path to print the fs type for")
|
||||
flag.StringVar(&fileModePath, "file_mode", "", "Path to print the mode bits of")
|
||||
flag.StringVar(&filePermPath, "file_perm", "", "Path to print the perms of")
|
||||
flag.StringVar(&fileOwnerPath, "file_owner", "", "Path to print the owning UID and GID of")
|
||||
flag.StringVar(&newFilePath0644, "new_file_0644", "", "Path to write to and read from with perm 0644")
|
||||
flag.StringVar(&newFilePath0666, "new_file_0666", "", "Path to write to and read from with perm 0666")
|
||||
flag.StringVar(&newFilePath0660, "new_file_0660", "", "Path to write to and read from with perm 0660")
|
||||
flag.StringVar(&newFilePath0777, "new_file_0777", "", "Path to write to and read from with perm 0777")
|
||||
flag.StringVar(&readFileContentPath, "file_content", "", "Path to read the file content from")
|
||||
flag.StringVar(&readFileContentInLoopPath, "file_content_in_loop", "", "Path to read the file content in loop from")
|
||||
flag.IntVar(&retryDuration, "retry_time", 180, "Retry time during the loop")
|
||||
flag.BoolVar(&breakOnExpectedContent, "break_on_expected_content", true, "Break out of loop on expected content, (use with --file_content_in_loop flag only)")
|
||||
}
|
||||
|
||||
// This program performs some tests on the filesystem as dictated by the
|
||||
// flags passed by the user.
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var (
|
||||
err error
|
||||
errs = []error{}
|
||||
)
|
||||
|
||||
// Clear the umask so we can set any mode bits we want.
|
||||
syscall.Umask(0000)
|
||||
|
||||
// NOTE: the ordering of execution of the various command line
|
||||
// flags is intentional and allows a single command to:
|
||||
//
|
||||
// 1. Check the fstype of a path
|
||||
// 2. Write a new file within that path
|
||||
// 3. Check that the file's content can be read
|
||||
//
|
||||
// Changing the ordering of the following code will break tests.
|
||||
|
||||
err = fsType(fsTypePath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readWriteNewFile(newFilePath0644, 0644)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readWriteNewFile(newFilePath0666, 0666)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readWriteNewFile(newFilePath0660, 0660)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readWriteNewFile(newFilePath0777, 0777)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = fileMode(fileModePath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = filePerm(filePermPath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = fileOwner(fileOwnerPath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readFileContent(readFileContentPath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
err = readFileContentInLoop(readFileContentInLoopPath, retryDuration, breakOnExpectedContent)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
if len(errs) != 0 {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Defined by Linux (sys/statfs.h) - the type number for tmpfs mounts.
|
||||
const linuxTmpfsMagic = 0x01021994
|
||||
|
||||
func fsType(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
buf := syscall.Statfs_t{}
|
||||
if err := syscall.Statfs(path, &buf); err != nil {
|
||||
fmt.Printf("error from statfs(%q): %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
if buf.Type == linuxTmpfsMagic {
|
||||
fmt.Printf("mount type of %q: tmpfs\n", path)
|
||||
} else {
|
||||
fmt.Printf("mount type of %q: %v\n", path, buf.Type)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func fileMode(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
fileinfo, err := os.Stat(path)
|
||||
if err != nil {
|
||||
fmt.Printf("error from Stat(%q): %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("mode of file %q: %v\n", path, fileinfo.Mode())
|
||||
return nil
|
||||
}
|
||||
|
||||
func filePerm(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
fileinfo, err := os.Stat(path)
|
||||
if err != nil {
|
||||
fmt.Printf("error from Stat(%q): %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("perms of file %q: %v\n", path, fileinfo.Mode().Perm())
|
||||
return nil
|
||||
}
|
||||
|
||||
func fileOwner(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
buf := syscall.Stat_t{}
|
||||
if err := syscall.Stat(path, &buf); err != nil {
|
||||
fmt.Printf("error from stat(%q): %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("owner UID of %q: %v\n", path, buf.Uid)
|
||||
fmt.Printf("owner GID of %q: %v\n", path, buf.Gid)
|
||||
return nil
|
||||
}
|
||||
|
||||
func readFileContent(path string) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
contentBytes, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
fmt.Printf("error reading file content for %q: %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("content of file %q: %v\n", path, string(contentBytes))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
const initialContent string = "mount-tester new file\n"
|
||||
|
||||
func readWriteNewFile(path string, perm os.FileMode) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(path, []byte(initialContent), perm)
|
||||
if err != nil {
|
||||
fmt.Printf("error writing new file %q: %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
|
||||
return readFileContent(path)
|
||||
}
|
||||
|
||||
func readFileContentInLoop(path string, retryDuration int, breakOnExpectedContent bool) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
return testFileContent(path, retryDuration, breakOnExpectedContent)
|
||||
}
|
||||
|
||||
func testFileContent(filePath string, retryDuration int, breakOnExpectedContent bool) error {
|
||||
var (
|
||||
contentBytes []byte
|
||||
err error
|
||||
)
|
||||
|
||||
retryTime := time.Second * time.Duration(retryDuration)
|
||||
for start := time.Now(); time.Since(start) < retryTime; time.Sleep(2 * time.Second) {
|
||||
contentBytes, err = ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading file %s: %v, retrying\n", filePath, err)
|
||||
continue
|
||||
}
|
||||
fmt.Printf("content of file %q: %v\n", filePath, string(contentBytes))
|
||||
if breakOnExpectedContent {
|
||||
if string(contentBytes) != initialContent {
|
||||
fmt.Printf("Unexpected content. Expected: %s. Retrying", initialContent)
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
5
vendor/k8s.io/kubernetes/test/images/n-way-http/BASEIMAGE
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/test/images/n-way-http/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
amd64=busybox
|
||||
arm=arm32v6/busybox
|
||||
arm64=arm64v8/busybox
|
||||
ppc64le=ppc64le/busybox
|
||||
s390x=s390x/busybox
|
32
vendor/k8s.io/kubernetes/test/images/n-way-http/BUILD
generated
vendored
Normal file
32
vendor/k8s.io/kubernetes/test/images/n-way-http/BUILD
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "n-way-http",
|
||||
importpath = "k8s.io/kubernetes/test/images/n-way-http",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["server.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/n-way-http",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
17
vendor/k8s.io/kubernetes/test/images/n-way-http/Dockerfile
generated
vendored
Normal file
17
vendor/k8s.io/kubernetes/test/images/n-way-http/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2016 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
|
||||
COPY n-way-http /
|
||||
ENTRYPOINT ["/n-way-http"]
|
25
vendor/k8s.io/kubernetes/test/images/n-way-http/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/n-way-http/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=n-way-http
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/n-way-http/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/n-way-http/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
55
vendor/k8s.io/kubernetes/test/images/n-way-http/server.go
generated
vendored
Normal file
55
vendor/k8s.io/kubernetes/test/images/n-way-http/server.go
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright 2015 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.
|
||||
*/
|
||||
|
||||
// A webserver that runs n http handlers. Example invocation:
|
||||
// - server -port 8080 -prefix foo -num 10 -start 0
|
||||
// Will given you 10 /foo(i) endpoints that simply echo foo(i) when requested.
|
||||
// - server -start 3 -num 1
|
||||
// Will create just one endpoint, at /foo3
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
port = flag.Int("port", 8080, "Port number for requests.")
|
||||
prefix = flag.String("prefix", "foo", "String used as path prefix")
|
||||
num = flag.Int("num", 10, "Number of endpoints to create.")
|
||||
start = flag.Int("start", 0, "Index to start, only makes sense with --num")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
// This container is used to test the GCE L7 controller which expects "/"
|
||||
// to return a 200 response.
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprint(w, "ok")
|
||||
})
|
||||
for i := *start; i < *start+*num; i++ {
|
||||
path := fmt.Sprintf("%v%d", *prefix, i)
|
||||
http.HandleFunc(fmt.Sprintf("/%v", path), func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprint(w, path)
|
||||
})
|
||||
}
|
||||
log.Printf("server -port %d -prefix %v -num %d -start %d", *port, *prefix, *num, *start)
|
||||
http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
|
||||
}
|
5
vendor/k8s.io/kubernetes/test/images/nautilus/BASEIMAGE
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/test/images/nautilus/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
amd64=gcr.io/kubernetes-e2e-test-images/test-webserver-amd64:1.0
|
||||
arm=gcr.io/kubernetes-e2e-test-images/test-webserver-arm:1.0
|
||||
arm64=gcr.io/kubernetes-e2e-test-images/test-webserver-arm64:1.0
|
||||
ppc64le=gcr.io/kubernetes-e2e-test-images/test-webserver-ppc64le:1.0
|
||||
s390x=gcr.io/kubernetes-e2e-test-images/test-webserver-s390x:1.0
|
17
vendor/k8s.io/kubernetes/test/images/nautilus/Dockerfile
generated
vendored
Normal file
17
vendor/k8s.io/kubernetes/test/images/nautilus/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2016 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
|
||||
COPY html/nautilus.jpg nautilus.jpg
|
||||
COPY html/data.json data.json
|
1
vendor/k8s.io/kubernetes/test/images/nautilus/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/nautilus/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
3
vendor/k8s.io/kubernetes/test/images/nautilus/html/data.json
generated
vendored
Normal file
3
vendor/k8s.io/kubernetes/test/images/nautilus/html/data.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"image": "nautilus.jpg"
|
||||
}
|
BIN
vendor/k8s.io/kubernetes/test/images/nautilus/html/nautilus.jpg
generated
vendored
Normal file
BIN
vendor/k8s.io/kubernetes/test/images/nautilus/html/nautilus.jpg
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
1
vendor/k8s.io/kubernetes/test/images/net/.gitignore
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/net/.gitignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
/net
|
4
vendor/k8s.io/kubernetes/test/images/net/BASEIMAGE
generated
vendored
Normal file
4
vendor/k8s.io/kubernetes/test/images/net/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
amd64=alpine:3.6
|
||||
arm=arm32v6/alpine:3.6
|
||||
arm64=arm64v8/alpine:3.6
|
||||
ppc64le=ppc64le/alpine:3.6
|
40
vendor/k8s.io/kubernetes/test/images/net/BUILD
generated
vendored
Normal file
40
vendor/k8s.io/kubernetes/test/images/net/BUILD
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "net",
|
||||
importpath = "k8s.io/kubernetes/test/images/net",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/net",
|
||||
deps = [
|
||||
"//test/images/net/common:go_default_library",
|
||||
"//test/images/net/nat:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//test/images/net/common:all-srcs",
|
||||
"//test/images/net/nat:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
20
vendor/k8s.io/kubernetes/test/images/net/Dockerfile
generated
vendored
Normal file
20
vendor/k8s.io/kubernetes/test/images/net/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2016 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/
|
||||
|
||||
COPY net /net
|
||||
RUN apk update && apk add curl
|
25
vendor/k8s.io/kubernetes/test/images/net/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/net/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=net
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
36
vendor/k8s.io/kubernetes/test/images/net/README.md
generated
vendored
Normal file
36
vendor/k8s.io/kubernetes/test/images/net/README.md
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
# Overview
|
||||
|
||||
The goal of this Go project is to consolidate all low-level
|
||||
network testing "daemons" into one place. In network testing we
|
||||
frequently have need of simple daemons (common/Runner) that perform
|
||||
some "trivial" set of actions on a socket.
|
||||
|
||||
# Usage
|
||||
|
||||
* A package for each general area that is being tested, for example
|
||||
`nat/` will contain Runners that test various NAT features.
|
||||
* Every runner should be registered via `main.go:makeRunnerMap()`.
|
||||
* Runners receive a JSON options structure as to their configuration. `Run()`
|
||||
should return the disposition of the test.
|
||||
|
||||
Runners can be executed into two different ways, either through the
|
||||
the command-line or via an HTTP request:
|
||||
|
||||
## Command-line
|
||||
|
||||
````
|
||||
$ ./net -runner <runner> -options <json>
|
||||
./net \
|
||||
-runner nat-closewait-client \
|
||||
-options '{"RemoteAddr":"127.0.0.1:9999"}'
|
||||
````
|
||||
|
||||
## HTTP server
|
||||
````
|
||||
$ ./net --serve :8889
|
||||
$ curl -v -X POST localhost:8889/run/nat-closewait-server \
|
||||
-d '{"LocalAddr":"127.0.0.1:9999"}'
|
||||
````
|
||||
|
||||
|
||||
[]()
|
1
vendor/k8s.io/kubernetes/test/images/net/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/net/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
25
vendor/k8s.io/kubernetes/test/images/net/common/BUILD
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/net/common/BUILD
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["common.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/net/common",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
29
vendor/k8s.io/kubernetes/test/images/net/common/common.go
generated
vendored
Normal file
29
vendor/k8s.io/kubernetes/test/images/net/common/common.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
package common
|
||||
|
||||
import "log"
|
||||
|
||||
// Runner is a client or server to run.
|
||||
type Runner interface {
|
||||
// NewOptions returns a new empty options structure to be populated
|
||||
// by from the JSON -options argument.
|
||||
NewOptions() interface{}
|
||||
// Run the client or server, taking in options. This execute the
|
||||
// test code.
|
||||
Run(logger *log.Logger, options interface{}) error
|
||||
}
|
162
vendor/k8s.io/kubernetes/test/images/net/main.go
generated
vendored
Normal file
162
vendor/k8s.io/kubernetes/test/images/net/main.go
generated
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"k8s.io/kubernetes/test/images/net/common"
|
||||
"k8s.io/kubernetes/test/images/net/nat"
|
||||
)
|
||||
|
||||
type runnerMap map[string]common.Runner
|
||||
|
||||
type runRequestJSON struct {
|
||||
runner string
|
||||
options interface{}
|
||||
}
|
||||
|
||||
var (
|
||||
// flags for the command line. See usage args below for
|
||||
// descriptions.
|
||||
flags struct {
|
||||
Serve string
|
||||
Runner string
|
||||
Options string
|
||||
}
|
||||
// runners is a map from runner name to runner instance.
|
||||
runners = makeRunnerMap()
|
||||
)
|
||||
|
||||
type logOutput struct {
|
||||
b bytes.Buffer
|
||||
}
|
||||
|
||||
func main() {
|
||||
initFlags()
|
||||
log.SetFlags(log.Flags() | log.Lshortfile)
|
||||
|
||||
if flags.Serve == "" {
|
||||
output, err := executeRunner(flags.Runner, flags.Options)
|
||||
if err == nil {
|
||||
fmt.Print("output:\n\n" + output.b.String())
|
||||
os.Exit(0)
|
||||
} else {
|
||||
log.Printf("Error: %v", err)
|
||||
fmt.Print("output:\n\n" + output.b.String())
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
http.HandleFunc("/run/", handleRunRequest)
|
||||
log.Printf("Running server on %v", flags.Serve)
|
||||
log.Fatal(http.ListenAndServe(flags.Serve, nil))
|
||||
}
|
||||
}
|
||||
|
||||
func initFlags() {
|
||||
legalRunners := ""
|
||||
for k := range runners {
|
||||
legalRunners += " " + k
|
||||
}
|
||||
flag.StringVar(
|
||||
&flags.Serve, "serve", "",
|
||||
"Address and port to bind to (e.g. 127.0.0.1:8080). Setting this will "+
|
||||
"run the network tester in server mode runner are triggered through "+
|
||||
"HTTP requests.")
|
||||
flag.StringVar(
|
||||
&flags.Runner, "runner", "",
|
||||
"Runner to execute (available:"+legalRunners+")")
|
||||
flag.StringVar(
|
||||
&flags.Options, "options", "",
|
||||
"JSON options to the Runner")
|
||||
flag.Parse()
|
||||
|
||||
if flags.Runner == "" && flags.Serve == "" {
|
||||
log.Fatalf("Must set either -runner or -serve, see --help")
|
||||
}
|
||||
}
|
||||
|
||||
func makeRunnerMap() runnerMap {
|
||||
// runner name is <pkg>-<file>-<specific>.
|
||||
return runnerMap{
|
||||
"nat-closewait-client": nat.NewCloseWaitClient(),
|
||||
"nat-closewait-server": nat.NewCloseWaitServer(),
|
||||
}
|
||||
}
|
||||
|
||||
func executeRunner(name string, rawOptions string) (logOutput, error) {
|
||||
runner, ok := runners[name]
|
||||
if ok {
|
||||
options := runner.NewOptions()
|
||||
if err := json.Unmarshal([]byte(rawOptions), options); err != nil {
|
||||
return logOutput{}, fmt.Errorf("Invalid options JSON: %v", err)
|
||||
}
|
||||
|
||||
log.Printf("Options: %+v", options)
|
||||
|
||||
output := logOutput{}
|
||||
logger := log.New(&output.b, "# ", log.Lshortfile)
|
||||
|
||||
return output, runner.Run(logger, options)
|
||||
}
|
||||
|
||||
return logOutput{}, fmt.Errorf("Invalid runner: '%v', see --help", runner)
|
||||
}
|
||||
|
||||
// handleRunRequest handles a request JSON to the network tester.
|
||||
func handleRunRequest(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("handleRunRequest %v", *r)
|
||||
|
||||
urlParts := strings.Split(r.URL.Path, "/")
|
||||
if len(urlParts) != 3 {
|
||||
http.Error(w, fmt.Sprintf("invalid request to run: %v", urlParts), 400)
|
||||
return
|
||||
}
|
||||
|
||||
runner := urlParts[2]
|
||||
if r.Body == nil {
|
||||
http.Error(w, "Missing request body", 400)
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("error reading body: %v", err), 400)
|
||||
return
|
||||
}
|
||||
|
||||
var output logOutput
|
||||
if output, err = executeRunner(runner, string(body)); err != nil {
|
||||
contents := fmt.Sprintf("Error from runner: %v\noutput:\n\n%s",
|
||||
err, output.b.String())
|
||||
http.Error(w, contents, 500)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "ok\noutput:\n\n"+output.b.String())
|
||||
}
|
||||
|
||||
func setupLogger() {
|
||||
}
|
26
vendor/k8s.io/kubernetes/test/images/net/nat/BUILD
generated
vendored
Normal file
26
vendor/k8s.io/kubernetes/test/images/net/nat/BUILD
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["closewait.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/net/nat",
|
||||
deps = ["//test/images/net/common:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
196
vendor/k8s.io/kubernetes/test/images/net/nat/closewait.go
generated
vendored
Normal file
196
vendor/k8s.io/kubernetes/test/images/net/nat/closewait.go
generated
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
/*
|
||||
Copyright 2016 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.
|
||||
*/
|
||||
|
||||
package nat
|
||||
|
||||
/*
|
||||
client/server for testing CLOSE_WAIT timeout condition in iptables NAT.
|
||||
|
||||
client server
|
||||
| |
|
||||
|<--tcp handshake-->|
|
||||
|<-------fin--------| half-close from server
|
||||
| | client is in CLOSE_WAIT
|
||||
*/
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/test/images/net/common"
|
||||
)
|
||||
|
||||
// leakedConnection is a global variable that should leak the active
|
||||
// connection assigned here.
|
||||
var leakedConnection *net.TCPConn
|
||||
|
||||
// Server JSON options.
|
||||
type CloseWaitServerOptions struct {
|
||||
// Address to bind for the test
|
||||
LocalAddr string
|
||||
// Timeout to wait after sending the FIN.
|
||||
PostFinTimeoutSeconds int
|
||||
}
|
||||
|
||||
type closeWaitServer struct {
|
||||
options *CloseWaitServerOptions
|
||||
}
|
||||
|
||||
// NewCloseWaitServer returns a new Runner.
|
||||
func NewCloseWaitServer() common.Runner {
|
||||
return &closeWaitServer{}
|
||||
}
|
||||
|
||||
// NewOptions allocates new options structure.
|
||||
func (server *closeWaitServer) NewOptions() interface{} {
|
||||
return &CloseWaitServerOptions{}
|
||||
}
|
||||
|
||||
// Run the server-side of the test.
|
||||
func (server *closeWaitServer) Run(logger *log.Logger, rawOptions interface{}) error {
|
||||
if options, ok := rawOptions.(*CloseWaitServerOptions); ok {
|
||||
server.options = options
|
||||
} else {
|
||||
return errors.New("invalid type")
|
||||
}
|
||||
|
||||
logger.Printf("Run %v", server.options)
|
||||
|
||||
addr, err := net.ResolveTCPAddr("tcp", server.options.LocalAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
listener, err := net.ListenTCP("tcp", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer listener.Close()
|
||||
|
||||
logger.Printf("Server listening on %v", addr)
|
||||
|
||||
conn, err := listener.AcceptTCP()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
logger.Printf("Client connected")
|
||||
|
||||
// Send client half-close FIN so client is now in CLOSE_WAIT. We keep
|
||||
// the client -> server pipe open to verify whether or not the NAT
|
||||
// dropped our connection.
|
||||
if err := conn.CloseWrite(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Printf("Server sent FIN, waiting %v seconds",
|
||||
server.options.PostFinTimeoutSeconds)
|
||||
|
||||
<-time.After(time.Duration(server.options.PostFinTimeoutSeconds) * time.Second)
|
||||
|
||||
logger.Printf("Done")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Client JSON options
|
||||
type CloseWaitClientOptions struct {
|
||||
// RemoteAddr of the server to connect to.
|
||||
RemoteAddr string
|
||||
// TimeoutSeconds on I/O with the server.
|
||||
TimeoutSeconds int
|
||||
// Half-close timeout (to give the test time to check the status of the
|
||||
// conntrack table entry.
|
||||
PostFinTimeoutSeconds int
|
||||
// Leak connection (assign to global variable so connection persists
|
||||
// as long as the process remains.
|
||||
LeakConnection bool
|
||||
}
|
||||
|
||||
type closeWaitClient struct {
|
||||
options *CloseWaitClientOptions
|
||||
}
|
||||
|
||||
// NewCloseWaitClient creates a new runner
|
||||
func NewCloseWaitClient() common.Runner {
|
||||
return &closeWaitClient{}
|
||||
}
|
||||
|
||||
// NewOptions allocates new options structure.
|
||||
func (client *closeWaitClient) NewOptions() interface{} {
|
||||
return &CloseWaitClientOptions{}
|
||||
}
|
||||
|
||||
// Run the client.m
|
||||
func (client *closeWaitClient) Run(logger *log.Logger, rawOptions interface{}) error {
|
||||
if options, ok := rawOptions.(*CloseWaitClientOptions); ok {
|
||||
client.options = options
|
||||
} else {
|
||||
return errors.New("invalid type")
|
||||
}
|
||||
|
||||
logger.Printf("Run %v", client.options)
|
||||
|
||||
addr, err := net.ResolveTCPAddr("tcp", client.options.RemoteAddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !client.options.LeakConnection {
|
||||
defer conn.Close()
|
||||
}
|
||||
|
||||
logger.Printf("Connected to server")
|
||||
|
||||
if client.options.TimeoutSeconds > 0 {
|
||||
delay := time.Duration(client.options.TimeoutSeconds) * time.Second
|
||||
conn.SetReadDeadline(time.Now().Add(delay))
|
||||
}
|
||||
|
||||
buf := make([]byte, 1, 1)
|
||||
size, err := conn.Read(buf)
|
||||
|
||||
if err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
if size != 0 {
|
||||
return errors.New("Got data but expected EOF")
|
||||
}
|
||||
|
||||
logger.Printf("Server has half-closed the connection, waiting %v seconds",
|
||||
client.options.PostFinTimeoutSeconds)
|
||||
|
||||
if client.options.LeakConnection {
|
||||
logger.Printf("Leaking client connection (assigning to global variable)")
|
||||
leakedConnection = conn
|
||||
}
|
||||
|
||||
<-time.After(
|
||||
time.Duration(client.options.PostFinTimeoutSeconds) * time.Second)
|
||||
|
||||
logger.Printf("Done")
|
||||
|
||||
return nil
|
||||
}
|
1
vendor/k8s.io/kubernetes/test/images/netexec/.gitignore
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/netexec/.gitignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
netexec
|
5
vendor/k8s.io/kubernetes/test/images/netexec/BASEIMAGE
generated
vendored
Normal file
5
vendor/k8s.io/kubernetes/test/images/netexec/BASEIMAGE
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
amd64=busybox
|
||||
arm=arm32v6/busybox
|
||||
arm64=arm64v8/busybox
|
||||
ppc64le=ppc64le/busybox
|
||||
s390x=s390x/busybox
|
33
vendor/k8s.io/kubernetes/test/images/netexec/BUILD
generated
vendored
Normal file
33
vendor/k8s.io/kubernetes/test/images/netexec/BUILD
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_binary",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "netexec",
|
||||
importpath = "k8s.io/kubernetes/test/images/netexec",
|
||||
library = ":go_default_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["netexec.go"],
|
||||
importpath = "k8s.io/kubernetes/test/images/netexec",
|
||||
deps = ["//vendor/k8s.io/apimachinery/pkg/util/net:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
25
vendor/k8s.io/kubernetes/test/images/netexec/Dockerfile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/netexec/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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/
|
||||
|
||||
ADD netexec netexec
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
RUN mkdir /uploads
|
||||
|
||||
ENTRYPOINT ["/netexec"]
|
25
vendor/k8s.io/kubernetes/test/images/netexec/Makefile
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/test/images/netexec/Makefile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2016 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.
|
||||
|
||||
SRCS=netexec
|
||||
ARCH ?= amd64
|
||||
TARGET ?= $(CURDIR)
|
||||
GOLANG_VERSION ?= latest
|
||||
SRC_DIR = $(notdir $(shell pwd))
|
||||
export
|
||||
|
||||
bin:
|
||||
../image-util.sh bin $(SRCS)
|
||||
|
||||
.PHONY: bin
|
1
vendor/k8s.io/kubernetes/test/images/netexec/VERSION
generated
vendored
Normal file
1
vendor/k8s.io/kubernetes/test/images/netexec/VERSION
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
1.0
|
407
vendor/k8s.io/kubernetes/test/images/netexec/netexec.go
generated
vendored
Normal file
407
vendor/k8s.io/kubernetes/test/images/netexec/netexec.go
generated
vendored
Normal file
@ -0,0 +1,407 @@
|
||||
/*
|
||||
Copyright 2014 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.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||
)
|
||||
|
||||
var (
|
||||
httpPort = 8080
|
||||
udpPort = 8081
|
||||
shellPath = "/bin/sh"
|
||||
serverReady = &atomicBool{0}
|
||||
)
|
||||
|
||||
// atomicBool uses load/store operations on an int32 to simulate an atomic boolean.
|
||||
type atomicBool struct {
|
||||
v int32
|
||||
}
|
||||
|
||||
// set sets the int32 to the given boolean.
|
||||
func (a *atomicBool) set(value bool) {
|
||||
if value {
|
||||
atomic.StoreInt32(&a.v, 1)
|
||||
return
|
||||
}
|
||||
atomic.StoreInt32(&a.v, 0)
|
||||
}
|
||||
|
||||
// get returns true if the int32 == 1
|
||||
func (a *atomicBool) get() bool {
|
||||
return atomic.LoadInt32(&a.v) == 1
|
||||
}
|
||||
|
||||
type output struct {
|
||||
responses []string
|
||||
errors []string
|
||||
}
|
||||
|
||||
func init() {
|
||||
flag.IntVar(&httpPort, "http-port", 8080, "HTTP Listen Port")
|
||||
flag.IntVar(&udpPort, "udp-port", 8081, "UDP Listen Port")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
go startUDPServer(udpPort)
|
||||
startHTTPServer(httpPort)
|
||||
}
|
||||
|
||||
func startHTTPServer(httpPort int) {
|
||||
http.HandleFunc("/", rootHandler)
|
||||
http.HandleFunc("/clientip", clientIpHandler)
|
||||
http.HandleFunc("/echo", echoHandler)
|
||||
http.HandleFunc("/exit", exitHandler)
|
||||
http.HandleFunc("/hostname", hostnameHandler)
|
||||
http.HandleFunc("/shell", shellHandler)
|
||||
http.HandleFunc("/upload", uploadHandler)
|
||||
http.HandleFunc("/dial", dialHandler)
|
||||
http.HandleFunc("/healthz", healthzHandler)
|
||||
// older handlers
|
||||
http.HandleFunc("/hostName", hostNameHandler)
|
||||
http.HandleFunc("/shutdown", shutdownHandler)
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", httpPort), nil))
|
||||
}
|
||||
|
||||
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /")
|
||||
fmt.Fprintf(w, "NOW: %v", time.Now())
|
||||
}
|
||||
|
||||
func echoHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /echo?msg=%s", r.FormValue("msg"))
|
||||
fmt.Fprintf(w, "%s", r.FormValue("msg"))
|
||||
}
|
||||
|
||||
func clientIpHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /clientip")
|
||||
fmt.Fprintf(w, r.RemoteAddr)
|
||||
}
|
||||
|
||||
func exitHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /exit?code=%s", r.FormValue("code"))
|
||||
code, err := strconv.Atoi(r.FormValue("code"))
|
||||
if err == nil || r.FormValue("code") == "" {
|
||||
os.Exit(code)
|
||||
}
|
||||
fmt.Fprintf(w, "argument 'code' must be an integer [0-127] or empty, got %q", r.FormValue("code"))
|
||||
}
|
||||
|
||||
func hostnameHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /hostname")
|
||||
fmt.Fprintf(w, getHostName())
|
||||
}
|
||||
|
||||
// healthHandler response with a 200 if the UDP server is ready. It also serves
|
||||
// as a health check of the HTTP server by virtue of being a HTTP handler.
|
||||
func healthzHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /healthz")
|
||||
if serverReady.get() {
|
||||
w.WriteHeader(200)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusPreconditionFailed)
|
||||
}
|
||||
|
||||
func shutdownHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /shutdown")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func dialHandler(w http.ResponseWriter, r *http.Request) {
|
||||
values, err := url.Parse(r.URL.RequestURI())
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("%v", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
host := values.Query().Get("host")
|
||||
port := values.Query().Get("port")
|
||||
request := values.Query().Get("request") // hostName
|
||||
protocol := values.Query().Get("protocol")
|
||||
tryParam := values.Query().Get("tries")
|
||||
log.Printf("GET /dial?host=%s&protocol=%s&port=%s&request=%s&tries=%s", host, protocol, port, request, tryParam)
|
||||
tries := 1
|
||||
if len(tryParam) > 0 {
|
||||
tries, err = strconv.Atoi(tryParam)
|
||||
}
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("tries parameter is invalid. %v", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if len(request) == 0 {
|
||||
http.Error(w, fmt.Sprintf("request parameter not specified. %v", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if len(protocol) == 0 {
|
||||
protocol = "http"
|
||||
} else {
|
||||
protocol = strings.ToLower(protocol)
|
||||
}
|
||||
if protocol != "http" && protocol != "udp" {
|
||||
http.Error(w, fmt.Sprintf("unsupported protocol. %s", protocol), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
hostPort := net.JoinHostPort(host, port)
|
||||
var udpAddress *net.UDPAddr
|
||||
if protocol == "udp" {
|
||||
udpAddress, err = net.ResolveUDPAddr("udp", hostPort)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("host and/or port param are invalid. %v", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
_, err = net.ResolveTCPAddr("tcp", hostPort)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("host and/or port param are invalid. %v", err), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
errors := make([]string, 0)
|
||||
responses := make([]string, 0)
|
||||
var response string
|
||||
for i := 0; i < tries; i++ {
|
||||
if protocol == "udp" {
|
||||
response, err = dialUDP(request, udpAddress)
|
||||
} else {
|
||||
response, err = dialHTTP(request, hostPort)
|
||||
}
|
||||
if err != nil {
|
||||
errors = append(errors, fmt.Sprintf("%v", err))
|
||||
} else {
|
||||
responses = append(responses, response)
|
||||
}
|
||||
}
|
||||
output := map[string][]string{}
|
||||
if len(response) > 0 {
|
||||
output["responses"] = responses
|
||||
}
|
||||
if len(errors) > 0 {
|
||||
output["errors"] = errors
|
||||
}
|
||||
bytes, err := json.Marshal(output)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("response could not be serialized. %v", err), http.StatusExpectationFailed)
|
||||
}
|
||||
}
|
||||
|
||||
func dialHTTP(request, hostPort string) (string, error) {
|
||||
transport := utilnet.SetTransportDefaults(&http.Transport{})
|
||||
httpClient := createHTTPClient(transport)
|
||||
resp, err := httpClient.Get(fmt.Sprintf("http://%s/%s", hostPort, request))
|
||||
defer transport.CloseIdleConnections()
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err == nil {
|
||||
return string(body), nil
|
||||
}
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
func createHTTPClient(transport *http.Transport) *http.Client {
|
||||
client := &http.Client{
|
||||
Transport: transport,
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func dialUDP(request string, remoteAddress *net.UDPAddr) (string, error) {
|
||||
Conn, err := net.DialUDP("udp", nil, remoteAddress)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("udp dial failed. err:%v", err)
|
||||
}
|
||||
|
||||
defer Conn.Close()
|
||||
buf := []byte(request)
|
||||
_, err = Conn.Write(buf)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("udp connection write failed. err:%v", err)
|
||||
}
|
||||
udpResponse := make([]byte, 1024)
|
||||
Conn.SetReadDeadline(time.Now().Add(5 * time.Second))
|
||||
count, err := Conn.Read(udpResponse)
|
||||
if err != nil || count == 0 {
|
||||
return "", fmt.Errorf("reading from udp connection failed. err:'%v'", err)
|
||||
}
|
||||
return string(udpResponse[0:count]), nil
|
||||
}
|
||||
|
||||
func shellHandler(w http.ResponseWriter, r *http.Request) {
|
||||
cmd := r.FormValue("shellCommand")
|
||||
if cmd == "" {
|
||||
cmd = r.FormValue("cmd")
|
||||
}
|
||||
log.Printf("GET /shell?cmd=%s", cmd)
|
||||
cmdOut, err := exec.Command(shellPath, "-c", cmd).CombinedOutput()
|
||||
output := map[string]string{}
|
||||
if len(cmdOut) > 0 {
|
||||
output["output"] = string(cmdOut)
|
||||
}
|
||||
if err != nil {
|
||||
output["error"] = fmt.Sprintf("%v", err)
|
||||
}
|
||||
log.Printf("Output: %s", output)
|
||||
bytes, err := json.Marshal(output)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("response could not be serialized. %v", err), http.StatusExpectationFailed)
|
||||
}
|
||||
}
|
||||
|
||||
func uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /upload")
|
||||
result := map[string]string{}
|
||||
file, _, err := r.FormFile("file")
|
||||
if err != nil {
|
||||
result["error"] = "Unable to upload file."
|
||||
bytes, err := json.Marshal(result)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("%s. Also unable to serialize output. %v", result["error"], err), http.StatusInternalServerError)
|
||||
}
|
||||
log.Printf("Unable to upload file: %s", err)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
f, err := ioutil.TempFile("/uploads", "upload")
|
||||
if err != nil {
|
||||
result["error"] = "Unable to open file for write"
|
||||
bytes, err := json.Marshal(result)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("%s. Also unable to serialize output. %v", result["error"], err), http.StatusInternalServerError)
|
||||
}
|
||||
log.Printf("Unable to open file for write: %s", err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
if _, err = io.Copy(f, file); err != nil {
|
||||
result["error"] = "Unable to write file."
|
||||
bytes, err := json.Marshal(result)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("%s. Also unable to serialize output. %v", result["error"], err), http.StatusInternalServerError)
|
||||
}
|
||||
log.Printf("Unable to write file: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
UploadFile := f.Name()
|
||||
if err := os.Chmod(UploadFile, 0700); err != nil {
|
||||
result["error"] = "Unable to chmod file."
|
||||
bytes, err := json.Marshal(result)
|
||||
if err == nil {
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
} else {
|
||||
http.Error(w, fmt.Sprintf("%s. Also unable to serialize output. %v", result["error"], err), http.StatusInternalServerError)
|
||||
}
|
||||
log.Printf("Unable to chmod file: %s", err)
|
||||
return
|
||||
}
|
||||
log.Printf("Wrote upload to %s", UploadFile)
|
||||
result["output"] = UploadFile
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
bytes, err := json.Marshal(result)
|
||||
fmt.Fprintf(w, string(bytes))
|
||||
}
|
||||
|
||||
func hostNameHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("GET /hostName")
|
||||
fmt.Fprintf(w, getHostName())
|
||||
}
|
||||
|
||||
// udp server supports the hostName, echo and clientIP commands.
|
||||
func startUDPServer(udpPort int) {
|
||||
serverAddress, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", udpPort))
|
||||
assertNoError(err)
|
||||
serverConn, err := net.ListenUDP("udp", serverAddress)
|
||||
defer serverConn.Close()
|
||||
buf := make([]byte, 1024)
|
||||
|
||||
log.Printf("Started UDP server")
|
||||
// Start responding to readiness probes.
|
||||
serverReady.set(true)
|
||||
defer func() {
|
||||
log.Printf("UDP server exited")
|
||||
serverReady.set(false)
|
||||
}()
|
||||
for {
|
||||
n, clientAddress, err := serverConn.ReadFromUDP(buf)
|
||||
assertNoError(err)
|
||||
receivedText := strings.ToLower(strings.TrimSpace(string(buf[0:n])))
|
||||
if receivedText == "hostname" {
|
||||
log.Println("Sending udp hostName response")
|
||||
_, err = serverConn.WriteToUDP([]byte(getHostName()), clientAddress)
|
||||
assertNoError(err)
|
||||
} else if strings.HasPrefix(receivedText, "echo ") {
|
||||
parts := strings.SplitN(receivedText, " ", 2)
|
||||
resp := ""
|
||||
if len(parts) == 2 {
|
||||
resp = parts[1]
|
||||
}
|
||||
log.Printf("Echoing %v\n", resp)
|
||||
_, err = serverConn.WriteToUDP([]byte(resp), clientAddress)
|
||||
assertNoError(err)
|
||||
} else if receivedText == "clientip" {
|
||||
log.Printf("Sending back clientip to %s", clientAddress.String())
|
||||
_, err = serverConn.WriteToUDP([]byte(clientAddress.String()), clientAddress)
|
||||
assertNoError(err)
|
||||
} else if len(receivedText) > 0 {
|
||||
log.Printf("Unknown udp command received: %v\n", receivedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getHostName() string {
|
||||
hostName, err := os.Hostname()
|
||||
assertNoError(err)
|
||||
return hostName
|
||||
}
|
||||
|
||||
func assertNoError(err error) {
|
||||
if err != nil {
|
||||
log.Fatal("Error occurred. error:", err)
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user