Merge pull request #79142 from bclau/test-images/centralize-image-to-agnhost-part-3

Centralizes images into agnhost (part 3)
This commit is contained in:
Kubernetes Prow Robot 2019-06-28 12:42:54 -07:00 committed by GitHub
commit 7417360054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 355 additions and 581 deletions

View File

@ -13,22 +13,16 @@ filegroup(
":package-srcs",
"//test/images/agnhost:all-srcs",
"//test/images/apparmor-loader:all-srcs",
"//test/images/audit-proxy:all-srcs",
"//test/images/crd-conversion-webhook:all-srcs",
"//test/images/echoserver:all-srcs",
"//test/images/entrypoint-tester:all-srcs",
"//test/images/inclusterclient:all-srcs",
"//test/images/metadata-concealment:all-srcs",
"//test/images/mounttest:all-srcs",
"//test/images/nonewprivs:all-srcs",
"//test/images/pets/peer-finder:all-srcs",
"//test/images/porter:all-srcs",
"//test/images/regression-issue-74839:all-srcs",
"//test/images/resource-consumer:all-srcs",
"//test/images/resource-consumer-controller:all-srcs",
"//test/images/sample-apiserver:all-srcs",
"//test/images/sample-device-plugin:all-srcs",
"//test/images/serve-hostname:all-srcs",
"//test/images/test-webserver:all-srcs",
],
tags = ["automanaged"],

View File

@ -16,8 +16,12 @@ go_library(
srcs = ["agnhost.go"],
importpath = "k8s.io/kubernetes/test/images/agnhost",
deps = [
"//test/images/agnhost/audit-proxy:go_default_library",
"//test/images/agnhost/crd-conversion-webhook:go_default_library",
"//test/images/agnhost/dns:go_default_library",
"//test/images/agnhost/entrypoint-tester:go_default_library",
"//test/images/agnhost/fakegitserver:go_default_library",
"//test/images/agnhost/inclusterclient:go_default_library",
"//test/images/agnhost/liveness:go_default_library",
"//test/images/agnhost/logs-generator:go_default_library",
"//test/images/agnhost/net:go_default_library",
@ -27,6 +31,8 @@ go_library(
"//test/images/agnhost/no-snat-test-proxy:go_default_library",
"//test/images/agnhost/pause:go_default_library",
"//test/images/agnhost/port-forward-tester:go_default_library",
"//test/images/agnhost/porter:go_default_library",
"//test/images/agnhost/serve-hostname:go_default_library",
"//test/images/agnhost/webhook:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
@ -44,8 +50,12 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//test/images/agnhost/audit-proxy:all-srcs",
"//test/images/agnhost/crd-conversion-webhook:all-srcs",
"//test/images/agnhost/dns:all-srcs",
"//test/images/agnhost/entrypoint-tester:all-srcs",
"//test/images/agnhost/fakegitserver:all-srcs",
"//test/images/agnhost/inclusterclient:all-srcs",
"//test/images/agnhost/liveness:all-srcs",
"//test/images/agnhost/logs-generator:all-srcs",
"//test/images/agnhost/net:all-srcs",
@ -55,6 +65,8 @@ filegroup(
"//test/images/agnhost/no-snat-test-proxy:all-srcs",
"//test/images/agnhost/pause:all-srcs",
"//test/images/agnhost/port-forward-tester:all-srcs",
"//test/images/agnhost/porter:all-srcs",
"//test/images/agnhost/serve-hostname:all-srcs",
"//test/images/agnhost/webhook:all-srcs",
],
tags = ["automanaged"],

View File

@ -20,15 +20,30 @@ 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/*
# from iperf image
# install necessary packages: iperf, bash
RUN apk --update add curl netcat-openbsd iproute2 iperf bash && rm -rf /var/cache/apk/* \
&& ln -s /usr/bin/iperf /usr/local/bin/iperf \
&& ls -altrh /usr/local/bin/iperf
# PORT 8080 needed by: netexec, nettest
# PORT 8081 needed by: netexec
EXPOSE 8080 8081
# PORT 9376 needed by: serve-hostname
EXPOSE 8080 8081 9376
# from netexec
RUN mkdir /uploads
# from porter
ADD porter/localhost.crt localhost.crt
ADD porter/localhost.key localhost.key
ADD agnhost agnhost
# needed for the entrypoint-tester related tests. Some of the entrypoint-tester related tests
# overrides this image's entrypoint with agnhost-2 binary, and will verify that the correct
# entrypoint is used by the containers.
RUN ln -s agnhost agnhost-2
ENTRYPOINT ["/agnhost"]
CMD ["pause"]

View File

@ -31,7 +31,7 @@ For example, let's consider the following `pod.yaml` file:
containers:
- args:
- dns-suffix
image: gcr.io/kubernetes-e2e-test-images/agnhost:2.1
image: gcr.io/kubernetes-e2e-test-images/agnhost:2.2
name: agnhost
dnsConfig:
nameservers:
@ -65,6 +65,35 @@ created with the `pause` argument instead, allowing us execute multiple commands
The `agnhost` binary is a CLI with the following subcommands:
### audit-proxy
The audit proxy is used to test dynamic auditing. It listens on port 8080 for incoming audit
events and writes them in a uniform manner to stdout.
Usage:
```console
kubectl exec test-agnhost -- /agnhost audit-proxy
```
### crd-conversion-webhook
The subcommand tests `CustomResourceConversionWebhook`. After deploying it to Kubernetes cluster,
the administrator needs to create a `CustomResourceConversion.Webhook` in Kubernetes cluster
to use remote webhook for conversions.
The subcommand starts a HTTP server, listening on port 443, and creating the `/crdconvert`
endpoint.
Usage
```console
kubectl exec test-agnhost -- /agnhost crd-conversion-webhook \
[--tls-cert-file <tls-cert-file>] [--tls-private-key-file <tls-private-key-file>]
```
### dns-server-list
It will output the host's configured DNS servers, separated by commas.
@ -87,6 +116,17 @@ Usage:
```
### entrypoint-tester
This subcommand will print the arguments it's passed and exists.
Usage:
```console
kubectl exec test-agnhost -- /agnhost entrypoint-tester foo lish args
```
### etc-hosts
It will output the contents of host's `hosts` file. This file's location is `/etc/hosts`
@ -124,6 +164,22 @@ Usage:
```
### inclusterclient
The subcommand will periodically poll the Kubernetes `/healthz` endpoint using the in-cluster
config. Because of this, the subcommand is meant to be run inside of a Kubernetes pod. It can
also be used to validate token rotation.
The given `--poll-interval` flag (default is 30 seconds) represents the poll interval in
seconds of the call to `/healhz`.
Usage:
```console
kubectl exec test-agnhost -- /agnhost inclusterclient [--poll-interval <poll-interval>]
```
### liveness
Starts a simple server that is alive for 10 seconds, then reports unhealthy for the rest
@ -165,14 +221,14 @@ Examples:
```console
docker run -i \
gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \
gcr.io/kubernetes-e2e-test-images/agnhost:2.2 \
logs-generator --log-lines-total 10 --run-duration 1s
```
```console
kubectl run logs-generator \
--generator=run-pod/v1 \
--image=gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \
--image=gcr.io/kubernetes-e2e-test-images/agnhost:2.2 \
--restart=Never \
-- logs-generator -t 10 -d 1s
```
@ -299,7 +355,7 @@ Usage:
```console
kubectl run test-agnhost \
--generator=run-pod/v1 \
--image=gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \
--image=gcr.io/kubernetes-e2e-test-images/agnhost:2.2 \
--restart=Never \
--env "POD_IP=<POD_IP>" \
--env "NODE_IP=<NODE_IP>" \
@ -366,6 +422,59 @@ Usage:
```
### porter
Serves requested data on ports specified in ENV variables. For example, if the the environment
variable `SERVE_PORT_9001` is set, then the subcommand will start serving on the port 9001.
Additionally, if the environment variable `SERVE_TLS_PORT_9002` is set, then the subcommand
will start a TLS server on that port.
The included `localhost.crt` is a PEM-encoded TLS cert with SAN IPs `127.0.0.1` and `[::1]`,
expiring in January 2084, generated from `src/crypto/tls`:
```console
go run generate_cert.go --rsa-bits 2048 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
```
To use a different cert/key, mount them into the pod and set the `CERT_FILE` and `KEY_FILE`
environment variables to the desired paths.
Usage:
```console
kubectl exec test-agnhost -- /agnhost porter
```
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/porter/README.md?pixel)]()
### serve-hostname
This is a small util app to serve your hostname on TCP and/or UDP. Useful for testing.
The subcommand can accept the following flags:
- `tcp` (default: `false`): Serve raw over TCP.
- `udp` (default: `false`): Serve raw over UDP.
- `http` (default: `true`): Serve HTTP.
- `close` (default: `false`): Close connection per each HTTP request.
- `port` (default: `9376`): The port number to listen to.
Keep in mind that `--http` cannot be given at the same time as `--tcp` or `--udp`.
Usage:
```console
kubectl exec test-agnhost -- /agnhost serve-hostname [--tcp] [--udp] [--http] [--close] [--port <port>]
```
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/for-demos/serve_hostname/README.md
?pixel)]()
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/serve_hostname/README.md?pixel
)]()
### webhook (Kubernetes External Admission Webhook)
The subcommand tests MutatingAdmissionWebhook and ValidatingAdmissionWebhook. After deploying
@ -382,8 +491,14 @@ Usage:
kubectl exec test-agnhost -- /agnhost webhook [--tls-cert-file <key-file>] [--tls-private-key-file <cert-file>]
```
## Other tools
The image contains `iperf`.
## Image
The image can be found at `gcr.io/kubernetes-e2e-test-images/agnhost:2.1` for Linux
containers, and `e2eteam/agnhost:2.1` for Windows containers. In the future, the same
The image can be found at `gcr.io/kubernetes-e2e-test-images/agnhost:2.2` for Linux
containers, and `e2eteam/agnhost:2.2` for Windows containers. In the future, the same
repository can be used for both OSes.

View File

@ -1 +1 @@
2.1
2.2

View File

@ -22,8 +22,12 @@ import (
"github.com/spf13/cobra"
"k8s.io/klog"
"k8s.io/kubernetes/test/images/agnhost/audit-proxy"
"k8s.io/kubernetes/test/images/agnhost/crd-conversion-webhook"
"k8s.io/kubernetes/test/images/agnhost/dns"
"k8s.io/kubernetes/test/images/agnhost/entrypoint-tester"
"k8s.io/kubernetes/test/images/agnhost/fakegitserver"
"k8s.io/kubernetes/test/images/agnhost/inclusterclient"
"k8s.io/kubernetes/test/images/agnhost/liveness"
"k8s.io/kubernetes/test/images/agnhost/logs-generator"
"k8s.io/kubernetes/test/images/agnhost/net"
@ -33,15 +37,21 @@ import (
"k8s.io/kubernetes/test/images/agnhost/no-snat-test-proxy"
"k8s.io/kubernetes/test/images/agnhost/pause"
"k8s.io/kubernetes/test/images/agnhost/port-forward-tester"
"k8s.io/kubernetes/test/images/agnhost/porter"
"k8s.io/kubernetes/test/images/agnhost/serve-hostname"
"k8s.io/kubernetes/test/images/agnhost/webhook"
)
func main() {
rootCmd := &cobra.Command{Use: "app"}
rootCmd.AddCommand(auditproxy.CmdAuditProxy)
rootCmd.AddCommand(crdconvwebhook.CmdCrdConversionWebhook)
rootCmd.AddCommand(dns.CmdDNSSuffix)
rootCmd.AddCommand(dns.CmdDNSServerList)
rootCmd.AddCommand(dns.CmdEtcHosts)
rootCmd.AddCommand(entrypoint.CmdEntrypointTester)
rootCmd.AddCommand(fakegitserver.CmdFakeGitServer)
rootCmd.AddCommand(inclusterclient.CmdInClusterClient)
rootCmd.AddCommand(liveness.CmdLiveness)
rootCmd.AddCommand(logsgen.CmdLogsGenerator)
rootCmd.AddCommand(net.CmdNet)
@ -50,7 +60,9 @@ func main() {
rootCmd.AddCommand(nosnat.CmdNoSnatTest)
rootCmd.AddCommand(nosnatproxy.CmdNoSnatTestProxy)
rootCmd.AddCommand(pause.CmdPause)
rootCmd.AddCommand(porter.CmdPorter)
rootCmd.AddCommand(portforwardtester.CmdPortForwardTester)
rootCmd.AddCommand(servehostname.CmdServeHostname)
rootCmd.AddCommand(webhook.CmdWebhook)
// NOTE(claudiub): Some tests are passing logging related flags, so we need to be able to

View File

@ -1,25 +1,20 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "k8s.io/kubernetes/test/images/audit-proxy",
visibility = ["//visibility:private"],
importpath = "k8s.io/kubernetes/test/images/agnhost/audit-proxy",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/audit/install:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/audit/v1:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/audit:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
],
)
go_binary(
name = "audit-proxy",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package auditproxy
import (
"io/ioutil"
@ -22,6 +22,8 @@ import (
"net/http"
"os"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer/json"
auditinstall "k8s.io/apiserver/pkg/apis/audit/install"
@ -29,12 +31,21 @@ import (
"k8s.io/apiserver/pkg/audit"
)
// CmdAuditProxy is used by agnhost Cobra.
var CmdAuditProxy = &cobra.Command{
Use: "audit-proxy",
Short: "Listens on port 8080 for incoming audit events",
Long: "Used to test dynamic auditing. It listens on port 8080 for incoming audit events and writes them in a uniform manner to stdout.",
Args: cobra.MaximumNArgs(0),
Run: main,
}
var (
encoder runtime.Encoder
decoder runtime.Decoder
)
func main() {
func main(cmd *cobra.Command, args []string) {
scheme := runtime.NewScheme()
auditinstall.Install(scheme)
serializer := json.NewSerializer(json.DefaultMetaFactory, scheme, scheme, false)

View File

@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
@ -6,22 +6,17 @@ go_library(
"config.go",
"main.go",
],
importpath = "k8s.io/kubernetes/test/images/crd-conversion-webhook",
visibility = ["//visibility:private"],
importpath = "k8s.io/kubernetes/test/images/agnhost/crd-conversion-webhook",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
"//test/images/crd-conversion-webhook/converter:go_default_library",
"//test/images/agnhost/crd-conversion-webhook/converter:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)
go_binary(
name = "crd-conversion-webhook",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
@ -33,7 +28,7 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//test/images/crd-conversion-webhook/converter:all-srcs",
"//test/images/agnhost/crd-conversion-webhook/converter:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package crdconvwebhook
import (
"crypto/tls"

View File

@ -6,7 +6,7 @@ go_library(
"example_converter.go",
"framework.go",
],
importpath = "k8s.io/kubernetes/test/images/crd-conversion-webhook/converter",
importpath = "k8s.io/kubernetes/test/images/agnhost/crd-conversion-webhook/converter",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",

View File

@ -14,33 +14,50 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package crdconvwebhook
import (
"flag"
"net/http"
"k8s.io/kubernetes/test/images/crd-conversion-webhook/converter"
"github.com/spf13/cobra"
"k8s.io/kubernetes/test/images/agnhost/crd-conversion-webhook/converter"
)
var (
certFile string
keyFile string
)
// CmdCrdConversionWebhook is used by agnhost Cobra.
var CmdCrdConversionWebhook = &cobra.Command{
Use: "crd-conversion-webhook",
Short: "Starts HTTP server on port 443 for testing CustomResourceConversionWebhook",
Long: `The subcommand tests "CustomResourceConversionWebhook".
After deploying it to Kubernetes cluster, the administrator needs to create a "CustomResourceConversion.Webhook" in Kubernetes cluster to use remote webhook for conversions.
The subcommand starts a HTTP server, listening on port 443, and creating the "/crdconvert" endpoint.`,
Args: cobra.MaximumNArgs(0),
Run: main,
}
func init() {
CmdCrdConversionWebhook.Flags().StringVar(&certFile, "tls-cert-file", "",
"File containing the default x509 Certificate for HTTPS. (CA cert, if any, concatenated "+
"after server cert.")
CmdCrdConversionWebhook.Flags().StringVar(&keyFile, "tls-private-key-file", "",
"File containing the default x509 private key matching --tls-cert-file.")
}
// Config contains the server (the webhook) cert and key.
type Config struct {
CertFile string
KeyFile string
}
func (c *Config) addFlags() {
flag.StringVar(&c.CertFile, "tls-cert-file", c.CertFile, ""+
"File containing the default x509 Certificate for HTTPS. (CA cert, if any, concatenated "+
"after server cert).")
flag.StringVar(&c.KeyFile, "tls-private-key-file", c.KeyFile, ""+
"File containing the default x509 private key matching --tls-cert-file.")
}
func main() {
var config Config
config.addFlags()
flag.Parse()
func main(cmd *cobra.Command, args []string) {
config := Config{CertFile: certFile, KeyFile: keyFile}
http.HandleFunc("/crdconvert", converter.ServeExampleConvert)
clientset := getClient()

View File

@ -1,20 +1,12 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "entrypoint-tester",
embed = [":go_default_library"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["ep.go"],
importpath = "k8s.io/kubernetes/test/images/entrypoint-tester",
importpath = "k8s.io/kubernetes/test/images/agnhost/entrypoint-tester",
deps = ["//vendor/github.com/spf13/cobra:go_default_library"],
)
filegroup(

View File

@ -0,0 +1,42 @@
/*
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 entrypoint
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
// CmdEntrypointTester is used by agnhost Cobra.
var CmdEntrypointTester = &cobra.Command{
Use: "entrypoint-tester",
Short: "Prints the args it's passed and exits",
Long: "Prints the args it's passed and exits.",
Run: main,
}
// This program prints all the executable's arguments and exits.
func main(cmd *cobra.Command, args []string) {
// Some of the entrypoint-tester related tests overrides agnhost's default entrypoint
// with agnhost-2, and this function's args will only contain the subcommand's
// args (./agnhost entrypoint-tester these args), but we need to print *all* the
// args, which is why os.Args should be printed instead.
fmt.Printf("%v\n", os.Args)
os.Exit(0)
}

View File

@ -1,24 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "k8s.io/kubernetes/test/images/inclusterclient",
visibility = ["//visibility:private"],
importpath = "k8s.io/kubernetes/test/images/agnhost/inclusterclient",
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/component-base/logs:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)
go_binary(
name = "inclusterconfig",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package main
package inclusterclient
import (
"crypto/sha256"
@ -25,19 +25,37 @@ import (
"net/http"
"time"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/component-base/logs"
"k8s.io/klog"
)
func main() {
var pollInterval int
// CmdInClusterClient is used by agnhost Cobra.
var CmdInClusterClient = &cobra.Command{
Use: "inclusterclient",
Short: "Periodically poll the Kubernetes \"/healthz\" endpoint",
Long: `Periodically polls the Kubernetes "/healthz" endpoint using the in-cluster config. Because of this, this subcommand is meant to be run inside of a Kubernetes pod.
This subcommand can also be used to validate token rotation.`,
Args: cobra.MaximumNArgs(0),
Run: main,
}
func init() {
CmdInClusterClient.Flags().IntVar(&pollInterval, "poll-interval", 30,
"poll interval of call to /healhtz in seconds")
}
func main(cmd *cobra.Command, args []string) {
logs.InitLogs()
defer logs.FlushLogs()
pollInterval := flag.Int("poll-interval", 30, "poll interval of call to /healhtz in seconds")
flag.Set("logtostderr", "true")
flag.Parse()
klog.Infof("started")
@ -54,7 +72,7 @@ func main() {
c := kubernetes.NewForConfigOrDie(cfg).RESTClient()
t := time.Tick(time.Duration(*pollInterval) * time.Second)
t := time.Tick(time.Duration(pollInterval) * time.Second)
for {
<-t
klog.Infof("calling /healthz")

View File

@ -35,6 +35,7 @@ var CmdPause = &cobra.Command{
}
func pause(cmd *cobra.Command, args []string) {
fmt.Println("Paused")
sigCh := make(chan os.Signal)
done := make(chan int, 1)
signal.Notify(sigCh, syscall.SIGINT)

View File

@ -2,19 +2,14 @@ package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "porter",
embed = [":go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["porter.go"],
importpath = "k8s.io/kubernetes/test/images/porter",
importpath = "k8s.io/kubernetes/test/images/agnhost/porter",
deps = ["//vendor/github.com/spf13/cobra:go_default_library"],
)
filegroup(

View File

@ -19,7 +19,8 @@ limitations under the License.
// Reads env vars; for every var of the form SERVE_PORT_X, where X is a valid
// port number, porter starts an HTTP server which serves the env var's value
// in response to any query.
package main
package porter
import (
"fmt"
@ -27,12 +28,29 @@ import (
"net/http"
"os"
"strings"
"github.com/spf13/cobra"
)
const prefix = "SERVE_PORT_"
const tlsPrefix = "SERVE_TLS_PORT_"
func main() {
// CmdPorter is used by agnhost Cobra.
var CmdPorter = &cobra.Command{
Use: "porter",
Short: "Serves requested data on ports specified in ENV variables",
Long: `Serves requested data on ports specified in ENV variables. For example, if the the environment variable "SERVE_PORT_9001" is set, then the subcommand will start serving on the port 9001.
Additionally, if the environment variable "SERVE_TLS_PORT_9002" is set, then the subcommand will start a TLS server on that port.
The included "localhost.crt" is a PEM-encoded TLS cert with SAN IPs "127.0.0.1" and "[::1]", expiring in January 2084, generated from "src/crypto/tls".
To use a different cert/key, mount them into the pod and set the "CERT_FILE" and "KEY_FILE" environment variables to the desired paths.`,
Args: cobra.MaximumNArgs(0),
Run: main,
}
func main(cmd *cobra.Command, args []string) {
for _, vk := range os.Environ() {
// Put everything before the first = sign in parts[0], and
// everything else in parts[1] (even if there are multiple =

View File

@ -2,14 +2,16 @@ package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["serve_hostname.go"],
importpath = "k8s.io/kubernetes/test/images/serve-hostname",
importpath = "k8s.io/kubernetes/test/images/agnhost/serve-hostname",
deps = [
"//vendor/github.com/spf13/cobra:go_default_library",
],
)
filegroup(
@ -24,8 +26,3 @@ filegroup(
srcs = [":package-srcs"],
tags = ["automanaged"],
)
go_binary(
name = "serve-hostname",
embed = [":go_default_library"],
)

View File

@ -15,10 +15,10 @@ limitations under the License.
*/
// A small utility to just serve the hostname on TCP and/or UDP.
package main
package servehostname
import (
"flag"
"fmt"
"log"
"net"
@ -27,19 +27,37 @@ import (
"os/signal"
"syscall"
"time"
"github.com/spf13/cobra"
)
// CmdServeHostname is used by agnhost Cobra.
var CmdServeHostname = &cobra.Command{
Use: "serve-hostname",
Short: "Serves the hostname",
Long: `Serves the hostname through HTTP / TCP / UDP on the given port.`,
Args: cobra.MaximumNArgs(0),
Run: main,
}
var (
doTCP = flag.Bool("tcp", false, "Serve raw over TCP.")
doUDP = flag.Bool("udp", false, "Serve raw over UDP.")
doHTTP = flag.Bool("http", true, "Serve HTTP.")
doClose = flag.Bool("close", false, "Close connection per each HTTP request")
port = flag.Int("port", 9376, "Port number.")
doTCP bool
doUDP bool
doHTTP bool
doClose bool
port int
)
func main() {
flag.Parse()
if *doHTTP && (*doTCP || *doUDP) {
func init() {
CmdServeHostname.Flags().BoolVar(&doTCP, "tcp", false, "Serve raw over TCP.")
CmdServeHostname.Flags().BoolVar(&doUDP, "udp", false, "Serve raw over UDP.")
CmdServeHostname.Flags().BoolVar(&doHTTP, "http", true, "Serve HTTP.")
CmdServeHostname.Flags().BoolVar(&doClose, "close", false, "Close connection per each HTTP request.")
CmdServeHostname.Flags().IntVar(&port, "port", 9376, "Port number.")
}
func main(cmd *cobra.Command, args []string) {
if doHTTP && (doTCP || doUDP) {
log.Fatalf("Can't server TCP/UDP mode and HTTP mode at the same time")
}
@ -48,8 +66,8 @@ func main() {
log.Fatalf("Error from os.Hostname(): %s", err)
}
if *doTCP {
listener, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
if doTCP {
listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
log.Fatalf("Error from net.Listen(): %s", err)
}
@ -65,8 +83,8 @@ func main() {
}
}()
}
if *doUDP {
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", *port))
if doUDP {
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", port))
if err != nil {
log.Fatalf("Error from net.ResolveUDPAddr(): %s", err)
}
@ -86,11 +104,11 @@ func main() {
}
}()
}
if *doHTTP {
if doHTTP {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Printf("HTTP request from %s", r.RemoteAddr)
if *doClose {
if doClose {
// Add this header to force to close the connection after serving the request.
w.Header().Add("Connection", "close")
}
@ -99,10 +117,10 @@ func main() {
})
go func() {
// Run in a closure so http.ListenAndServe doesn't block
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
}()
}
log.Printf("Serving on port %d.\n", *port)
log.Printf("Serving on port %d.\n", port)
signals := make(chan os.Signal)
signal.Notify(signals, syscall.SIGTERM)
sig := <-signals

View File

@ -1,17 +0,0 @@
# Copyright 2019 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 gcr.io/distroless/static:latest
COPY audit-proxy /
ENTRYPOINT ["/audit-proxy"]

View File

@ -1,26 +0,0 @@
# Copyright 2019 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=audit-proxy
ARCH ?= amd64
TARGET ?= $(CURDIR)
GOARM=7
GOLANG_VERSION ?= latest
SRC_DIR = $(notdir $(shell pwd))
export
bin:
../image-util.sh bin $(SRCS)
.PHONY: bin

View File

@ -1,4 +0,0 @@
# Audit Proxy
The audit proxy is used to test dynamic auditing. It listens on port 8080 for incoming audit events and
writes them in a uniform manner to stdout.

View File

@ -1 +0,0 @@
1.1

View File

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

View File

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

View File

@ -1,25 +0,0 @@
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SRCS=crd_conversion_webhook
ARCH ?= amd64
TARGET ?= $(CURDIR)
GOLANG_VERSION ?= latest
SRC_DIR = $(notdir $(shell pwd))
export
bin:
../image-util.sh bin $(SRCS)
.PHONY: bin

View File

@ -1,11 +0,0 @@
# Kubernetes External Admission Webhook Test Image
The image tests CustomResourceConversionWebhook. After deploying it to kubernetes cluster,
administrator needs to create a CustomResourceConversion.Webhook
in kubernetes cluster to use remote webhook for conversions.
## Build the code
```bash
make build
```

View File

@ -1 +0,0 @@
1.13rev2

View File

@ -1,20 +0,0 @@
# 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"]

View File

@ -1,25 +0,0 @@
# 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

View File

@ -1 +0,0 @@
1.0

View File

@ -1,29 +0,0 @@
/*
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)
}

View File

@ -1,18 +0,0 @@
# Copyright 2019 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 gcr.io/distroless/static:latest
ADD inclusterclient /inclusterclient
ENTRYPOINT ["/inclusterclient"]

View File

@ -1,25 +0,0 @@
# Copyright 2019 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 = inclusterclient
ARCH ?= amd64
TARGET ?= $(CURDIR)
GOLANG_VERSION ?= latest
SRC_DIR = $(notdir $(shell pwd))
export
bin:
../image-util.sh bin $(SRCS)
.PHONY: bin

View File

@ -1 +0,0 @@
1.0

View File

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

View File

@ -1,23 +0,0 @@
# 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

View File

@ -1,8 +0,0 @@
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.
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/iperf/README.md?pixel)]()

View File

@ -1 +0,0 @@
1.0

View File

@ -1,2 +0,0 @@
porter
.tag

View File

@ -1,19 +0,0 @@
# 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 localhost.crt localhost.crt
ADD localhost.key localhost.key
ADD porter porter
ENTRYPOINT ["/porter"]

View File

@ -1,25 +0,0 @@
# 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=porter
ARCH ?= amd64
TARGET ?= $(CURDIR)
GOLANG_VERSION ?= latest
SRC_DIR = $(notdir $(shell pwd))
export
bin:
../image-util.sh bin $(SRCS)
.PHONY: bin

View File

@ -1,12 +0,0 @@
This directory contains go source, Dockerfile and Makefile for making a test
container which serves requested data on ports specified in ENV variables.
The included localhost.crt is a PEM-encoded TLS cert with SAN IPs
"127.0.0.1" and "[::1]", expiring in January 2084, generated from
src/crypto/tls:
go run generate_cert.go --rsa-bits 2048 --host 127.0.0.1,::1,example.com --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h
To use a different cert/key, mount them into the pod and set the
CERT_FILE and KEY_FILE environment variables to the desired paths.
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/porter/README.md?pixel)]()

View File

@ -1 +0,0 @@
1.0

View File

@ -1,59 +0,0 @@
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "porter"
},
"spec": {
"containers": [
{
"name": "porter",
"image": "gcr.io/kubernetes-e2e-test-images/porter-amd64:1.0",
"env": [
{
"name": "SERVE_PORT_80",
"value": "foo"
},
{
"name": "SERVE_PORT_81",
"value": "<html><head></head><body><a href=\"/rewriteme\">rewritten link</a></body></html>"
},
{
"name": "SERVE_TLS_PORT_443",
"value": "tls foo"
},
{
"name": "SERVE_TLS_PORT_444",
"value": "<html><head></head><body><a href=\"/tls-rewriteme\">tls rewritten link</a></body></html>"
},
{
"name": "CERT_FILE",
"value": "/localhost.crt"
},
{
"name": "KEY_FILE",
"value": "/localhost.key"
}
],
"ports": [
{
"name": "p80",
"containerPort": 80
},
{
"name": "p81",
"containerPort": 81
},
{
"name": "p443",
"containerPort": 443
},
{
"name": "p444",
"containerPort": 444
}
]
}
]
}
}

View File

@ -1,5 +0,0 @@
amd64=busybox
arm=arm32v6/busybox
arm64=arm64v8/busybox
ppc64le=ppc64le/busybox
s390x=s390x/busybox

View File

@ -1,18 +0,0 @@
# 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 serve_hostname /
EXPOSE 9376
ENTRYPOINT ["/serve_hostname"]

View File

@ -1,25 +0,0 @@
# 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=serve_hostname
ARCH ?= amd64
TARGET ?= $(CURDIR)
GOLANG_VERSION ?= latest
SRC_DIR = $(notdir $(shell pwd))
export
bin:
../image-util.sh bin $(SRCS)
.PHONY: bin

View File

@ -1,39 +0,0 @@
## serve_hostname
This is a small util app to serve your hostname on TCP and/or UDP. Useful for testing.
The `serve_hostname` Makefile supports multiple architectures, which means it may cross-compile and build a docker image easily.
Arch-specific busybox images serve as base images.
If you are releasing a new version, please bump the `TAG` value in the `Makefile` before building the images.
## How to release:
```
# Build cross-platform binaries
$ make all-push
# Build for linux/amd64 (default)
$ make push ARCH=amd64
# ---> staging-k8s.gcr.io/serve_hostname-amd64:TAG
$ make push ARCH=arm
# ---> staging-k8s.gcr.io/serve_hostname-arm:TAG
$ make push ARCH=arm64
# ---> staging-k8s.gcr.io/serve_hostname-arm64:TAG
$ make push ARCH=ppc64le
# ---> staging-k8s.gcr.io/serve_hostname-ppc64le:TAG
$ make push ARCH=s390x
# ---> staging-k8s.gcr.io/serve_hostname-s390x:TAG
```
Of course, if you don't want to push the images, run `make all-container` or `make container ARCH={target_arch}` instead.
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/contrib/for-demos/serve_hostname/README.md?pixel)]()
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/serve_hostname/README.md?pixel)]()

View File

@ -1 +0,0 @@
1.2