From 99e26460674b1ad881cb5b96c56a9b3219003305 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Mon, 20 May 2019 08:24:35 -0700 Subject: [PATCH 1/5] test images: Refactors agnhost image Refactors the functions used in agnhost into different modules, based on their functionality, leaving only the main in the base folder. Future commits will add several functionalities to agnhost, so this change will be necessary to keep it clean. --- test/images/agnhost/BUILD | 11 ++-- test/images/agnhost/agnhost.go | 43 ++------------ test/images/agnhost/dns/BUILD | 32 ++++++++++ test/images/agnhost/{ => dns}/common.go | 56 +++++++++--------- test/images/agnhost/{utils.go => dns/dns.go} | 2 +- .../{utils_windows.go => dns/dns_windows.go} | 2 +- test/images/agnhost/pause/BUILD | 28 +++++++++ test/images/agnhost/pause/pause.go | 59 +++++++++++++++++++ 8 files changed, 160 insertions(+), 73 deletions(-) create mode 100644 test/images/agnhost/dns/BUILD rename test/images/agnhost/{ => dns}/common.go (64%) rename test/images/agnhost/{utils.go => dns/dns.go} (99%) rename test/images/agnhost/{utils_windows.go => dns/dns_windows.go} (98%) create mode 100644 test/images/agnhost/pause/BUILD create mode 100644 test/images/agnhost/pause/pause.go diff --git a/test/images/agnhost/BUILD b/test/images/agnhost/BUILD index afe2df5d582..c11a32865e7 100644 --- a/test/images/agnhost/BUILD +++ b/test/images/agnhost/BUILD @@ -13,17 +13,14 @@ go_binary( go_library( name = "go_default_library", - srcs = [ - "agnhost.go", - "common.go", - "utils.go", - "utils_windows.go", - ], + srcs = ["agnhost.go"], importpath = "k8s.io/kubernetes/test/images/agnhost", deps = [ + "//test/images/agnhost/dns:go_default_library", "//test/images/agnhost/net:go_default_library", "//test/images/agnhost/netexec:go_default_library", "//test/images/agnhost/nettest:go_default_library", + "//test/images/agnhost/pause: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", @@ -41,9 +38,11 @@ filegroup( name = "all-srcs", srcs = [ ":package-srcs", + "//test/images/agnhost/dns:all-srcs", "//test/images/agnhost/net:all-srcs", "//test/images/agnhost/netexec:all-srcs", "//test/images/agnhost/nettest:all-srcs", + "//test/images/agnhost/pause:all-srcs", "//test/images/agnhost/webhook:all-srcs", ], tags = ["automanaged"], diff --git a/test/images/agnhost/agnhost.go b/test/images/agnhost/agnhost.go index 5e9a4c15f1c..0f1a7809767 100644 --- a/test/images/agnhost/agnhost.go +++ b/test/images/agnhost/agnhost.go @@ -22,54 +22,23 @@ import ( "github.com/spf13/cobra" "k8s.io/klog" + "k8s.io/kubernetes/test/images/agnhost/dns" "k8s.io/kubernetes/test/images/agnhost/net" "k8s.io/kubernetes/test/images/agnhost/netexec" "k8s.io/kubernetes/test/images/agnhost/nettest" + "k8s.io/kubernetes/test/images/agnhost/pause" "k8s.io/kubernetes/test/images/agnhost/webhook" ) func main() { - cmdDNSSuffix := &cobra.Command{ - Use: "dns-suffix", - Short: "Prints the host's DNS suffix list", - Long: `Prints the DNS suffixes of this host.`, - Args: cobra.MaximumNArgs(0), - Run: printDNSSuffixList, - } - - cmdDNSServerList := &cobra.Command{ - Use: "dns-server-list", - Short: "Prints the host's DNS Server list", - Long: `Prints the DNS Server list of this host.`, - Args: cobra.MaximumNArgs(0), - Run: printDNSServerList, - } - - cmdEtcHosts := &cobra.Command{ - Use: "etc-hosts", - Short: "Prints the host's /etc/hosts file", - Long: `Prints the "hosts" file of this host."`, - Args: cobra.MaximumNArgs(0), - Run: printHostsFile, - } - - cmdPause := &cobra.Command{ - Use: "pause", - Short: "Pauses", - Long: `Pauses the execution. Useful for keeping the containers running, so other commands can be executed.`, - Args: cobra.MaximumNArgs(0), - Run: pause, - } - rootCmd := &cobra.Command{Use: "app"} - rootCmd.AddCommand(cmdDNSSuffix) - rootCmd.AddCommand(cmdDNSServerList) - rootCmd.AddCommand(cmdEtcHosts) - rootCmd.AddCommand(cmdPause) - + rootCmd.AddCommand(dns.CmdDNSSuffix) + rootCmd.AddCommand(dns.CmdDNSServerList) + rootCmd.AddCommand(dns.CmdEtcHosts) rootCmd.AddCommand(net.CmdNet) rootCmd.AddCommand(netexec.CmdNetexec) rootCmd.AddCommand(nettest.CmdNettest) + rootCmd.AddCommand(pause.CmdPause) rootCmd.AddCommand(webhook.CmdWebhook) // NOTE(claudiub): Some tests are passing logging related flags, so we need to be able to diff --git a/test/images/agnhost/dns/BUILD b/test/images/agnhost/dns/BUILD new file mode 100644 index 00000000000..193173737f1 --- /dev/null +++ b/test/images/agnhost/dns/BUILD @@ -0,0 +1,32 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = [ + "common.go", + "dns.go", + "dns_windows.go", + ], + importpath = "k8s.io/kubernetes/test/images/agnhost/dns", + deps = [ + "//vendor/github.com/spf13/cobra:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/test/images/agnhost/common.go b/test/images/agnhost/dns/common.go similarity index 64% rename from test/images/agnhost/common.go rename to test/images/agnhost/dns/common.go index 9d168025434..06166e9c229 100644 --- a/test/images/agnhost/common.go +++ b/test/images/agnhost/dns/common.go @@ -14,21 +14,45 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package dns import ( "bytes" "fmt" "io/ioutil" - "os" "os/exec" - "os/signal" "strings" - "syscall" "github.com/spf13/cobra" ) +// CmdDNSSuffix is used by agnhost Cobra. +var CmdDNSSuffix = &cobra.Command{ + Use: "dns-suffix", + Short: "Prints the host's DNS suffix list", + Long: `Prints the DNS suffixes of this host.`, + Args: cobra.MaximumNArgs(0), + Run: printDNSSuffixList, +} + +// CmdDNSServerList is used by agnhost Cobra. +var CmdDNSServerList = &cobra.Command{ + Use: "dns-server-list", + Short: "Prints the host's DNS Server list", + Long: `Prints the DNS Server list of this host.`, + Args: cobra.MaximumNArgs(0), + Run: printDNSServerList, +} + +// CmdEtcHosts is used by agnhost Cobra. +var CmdEtcHosts = &cobra.Command{ + Use: "etc-hosts", + Short: "Prints the host's /etc/hosts file", + Long: `Prints the "hosts" file of this host."`, + Args: cobra.MaximumNArgs(0), + Run: printHostsFile, +} + func printDNSSuffixList(cmd *cobra.Command, args []string) { dnsSuffixList := getDNSSuffixList() fmt.Println(strings.Join(dnsSuffixList, ",")) @@ -43,30 +67,6 @@ func printHostsFile(cmd *cobra.Command, args []string) { fmt.Println(readFile(etcHostsFile)) } -func pause(cmd *cobra.Command, args []string) { - sigCh := make(chan os.Signal) - done := make(chan int, 1) - signal.Notify(sigCh, syscall.SIGINT) - signal.Notify(sigCh, syscall.SIGTERM) - signal.Notify(sigCh, syscall.SIGKILL) - go func() { - sig := <-sigCh - switch sig { - case syscall.SIGINT: - done <- 1 - os.Exit(1) - case syscall.SIGTERM: - done <- 2 - os.Exit(2) - case syscall.SIGKILL: - done <- 0 - os.Exit(0) - } - }() - result := <-done - fmt.Printf("exiting %d\n", result) -} - func readFile(fileName string) string { fileData, err := ioutil.ReadFile(fileName) if err != nil { diff --git a/test/images/agnhost/utils.go b/test/images/agnhost/dns/dns.go similarity index 99% rename from test/images/agnhost/utils.go rename to test/images/agnhost/dns/dns.go index 26cab3ce62c..6908dbfa0c9 100644 --- a/test/images/agnhost/utils.go +++ b/test/images/agnhost/dns/dns.go @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package dns import ( "strings" diff --git a/test/images/agnhost/utils_windows.go b/test/images/agnhost/dns/dns_windows.go similarity index 98% rename from test/images/agnhost/utils_windows.go rename to test/images/agnhost/dns/dns_windows.go index 0012fe7e6cf..68fbf51926c 100644 --- a/test/images/agnhost/utils_windows.go +++ b/test/images/agnhost/dns/dns_windows.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package dns import ( "strings" diff --git a/test/images/agnhost/pause/BUILD b/test/images/agnhost/pause/BUILD new file mode 100644 index 00000000000..c03ff568f8f --- /dev/null +++ b/test/images/agnhost/pause/BUILD @@ -0,0 +1,28 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["pause.go"], + importpath = "k8s.io/kubernetes/test/images/agnhost/pause", + deps = [ + "//vendor/github.com/spf13/cobra:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/test/images/agnhost/pause/pause.go b/test/images/agnhost/pause/pause.go new file mode 100644 index 00000000000..1f93037a66b --- /dev/null +++ b/test/images/agnhost/pause/pause.go @@ -0,0 +1,59 @@ +/* +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. +*/ + +package pause + +import ( + "fmt" + "os" + "os/signal" + "syscall" + + "github.com/spf13/cobra" +) + +// CmdPause is used by agnhost Cobra. +var CmdPause = &cobra.Command{ + Use: "pause", + Short: "Pauses the execution", + Long: `Pauses the execution. Useful for keeping the containers running, so other commands can be executed.`, + Args: cobra.MaximumNArgs(0), + Run: pause, +} + +func pause(cmd *cobra.Command, args []string) { + sigCh := make(chan os.Signal) + done := make(chan int, 1) + signal.Notify(sigCh, syscall.SIGINT) + signal.Notify(sigCh, syscall.SIGTERM) + signal.Notify(sigCh, syscall.SIGKILL) + go func() { + sig := <-sigCh + switch sig { + case syscall.SIGINT: + done <- 1 + os.Exit(1) + case syscall.SIGTERM: + done <- 2 + os.Exit(2) + case syscall.SIGKILL: + done <- 0 + os.Exit(0) + } + }() + result := <-done + fmt.Printf("exiting %d\n", result) +} From 76550ea8b87c953a16ee031df56049968c98195d Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Mon, 20 May 2019 14:15:10 -0700 Subject: [PATCH 2/5] test images: Centralizes images into agnhost (part 1) Centralizes the following images into agnhost: - fakegitserver - hostexec - liveness - logs-generator - no-snat-test - no-snat-test-proxy - port-forward-tester --- test/images/BUILD | 6 - test/images/agnhost/BUILD | 12 + test/images/agnhost/Dockerfile | 5 + test/images/agnhost/README.md | 222 ++++++++++++++++-- test/images/agnhost/agnhost.go | 12 + test/images/{ => agnhost}/fakegitserver/BUILD | 9 +- .../{ => agnhost}/fakegitserver/gitserver.go | 16 +- test/images/{ => agnhost}/liveness/BUILD | 11 +- test/images/{ => agnhost}/liveness/server.go | 16 +- .../images/{ => agnhost}/logs-generator/BUILD | 9 +- .../logs-generator/logs_generator.go | 43 ++-- .../no-snat-test-proxy}/BUILD | 11 +- .../{ => agnhost}/no-snat-test-proxy/main.go | 36 +-- .../no-snat-test}/BUILD | 11 +- .../images/{ => agnhost}/no-snat-test/main.go | 40 ++-- .../{ => agnhost}/port-forward-tester/BUILD | 9 +- .../port-forward-tester/portforwardtester.go | 26 +- test/images/fakegitserver/Dockerfile | 19 -- test/images/fakegitserver/Makefile | 27 --- test/images/fakegitserver/VERSION | 1 - test/images/hostexec/BASEIMAGE | 5 - test/images/hostexec/Dockerfile | 25 -- test/images/hostexec/VERSION | 1 - test/images/hostexec/pod.yaml | 12 - test/images/liveness/Dockerfile | 17 -- test/images/liveness/Makefile | 25 -- test/images/liveness/VERSION | 1 - test/images/logs-generator/BASEIMAGE | 4 - test/images/logs-generator/Dockerfile | 22 -- test/images/logs-generator/Makefile | 25 -- test/images/logs-generator/README.md | 57 ----- test/images/logs-generator/VERSION | 1 - test/images/no-snat-test-proxy/BASEIMAGE | 4 - test/images/no-snat-test-proxy/Dockerfile | 19 -- test/images/no-snat-test-proxy/Makefile | 25 -- test/images/no-snat-test-proxy/VERSION | 1 - test/images/no-snat-test/BASEIMAGE | 4 - test/images/no-snat-test/Dockerfile | 19 -- test/images/no-snat-test/Makefile | 25 -- test/images/no-snat-test/VERSION | 1 - test/images/port-forward-tester/.gitignore | 1 - test/images/port-forward-tester/Dockerfile | 18 -- test/images/port-forward-tester/Makefile | 25 -- test/images/port-forward-tester/VERSION | 1 - 44 files changed, 373 insertions(+), 506 deletions(-) rename test/images/{ => agnhost}/fakegitserver/BUILD (72%) rename test/images/{ => agnhost}/fakegitserver/gitserver.go (67%) rename test/images/{ => agnhost}/liveness/BUILD (73%) rename test/images/{ => agnhost}/liveness/server.go (79%) rename test/images/{ => agnhost}/logs-generator/BUILD (78%) rename test/images/{ => agnhost}/logs-generator/logs_generator.go (63%) rename test/images/{no-snat-test => agnhost/no-snat-test-proxy}/BUILD (63%) rename test/images/{ => agnhost}/no-snat-test-proxy/main.go (73%) rename test/images/{no-snat-test-proxy => agnhost/no-snat-test}/BUILD (62%) rename test/images/{ => agnhost}/no-snat-test/main.go (82%) rename test/images/{ => agnhost}/port-forward-tester/BUILD (71%) rename test/images/{ => agnhost}/port-forward-tester/portforwardtester.go (79%) delete mode 100644 test/images/fakegitserver/Dockerfile delete mode 100644 test/images/fakegitserver/Makefile delete mode 100644 test/images/fakegitserver/VERSION delete mode 100644 test/images/hostexec/BASEIMAGE delete mode 100644 test/images/hostexec/Dockerfile delete mode 100644 test/images/hostexec/VERSION delete mode 100644 test/images/hostexec/pod.yaml delete mode 100644 test/images/liveness/Dockerfile delete mode 100644 test/images/liveness/Makefile delete mode 100644 test/images/liveness/VERSION delete mode 100644 test/images/logs-generator/BASEIMAGE delete mode 100644 test/images/logs-generator/Dockerfile delete mode 100644 test/images/logs-generator/Makefile delete mode 100644 test/images/logs-generator/README.md delete mode 100644 test/images/logs-generator/VERSION delete mode 100644 test/images/no-snat-test-proxy/BASEIMAGE delete mode 100644 test/images/no-snat-test-proxy/Dockerfile delete mode 100644 test/images/no-snat-test-proxy/Makefile delete mode 100644 test/images/no-snat-test-proxy/VERSION delete mode 100644 test/images/no-snat-test/BASEIMAGE delete mode 100644 test/images/no-snat-test/Dockerfile delete mode 100644 test/images/no-snat-test/Makefile delete mode 100644 test/images/no-snat-test/VERSION delete mode 100644 test/images/port-forward-tester/.gitignore delete mode 100644 test/images/port-forward-tester/Dockerfile delete mode 100644 test/images/port-forward-tester/Makefile delete mode 100644 test/images/port-forward-tester/VERSION diff --git a/test/images/BUILD b/test/images/BUILD index e10c35de236..d40deb53b7e 100644 --- a/test/images/BUILD +++ b/test/images/BUILD @@ -17,17 +17,11 @@ filegroup( "//test/images/crd-conversion-webhook:all-srcs", "//test/images/echoserver:all-srcs", "//test/images/entrypoint-tester:all-srcs", - "//test/images/fakegitserver:all-srcs", "//test/images/inclusterclient:all-srcs", - "//test/images/liveness:all-srcs", - "//test/images/logs-generator:all-srcs", "//test/images/metadata-concealment:all-srcs", "//test/images/mounttest: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/regression-issue-74839:all-srcs", "//test/images/resource-consumer:all-srcs", diff --git a/test/images/agnhost/BUILD b/test/images/agnhost/BUILD index c11a32865e7..3a711c4cf7f 100644 --- a/test/images/agnhost/BUILD +++ b/test/images/agnhost/BUILD @@ -17,10 +17,16 @@ go_library( importpath = "k8s.io/kubernetes/test/images/agnhost", deps = [ "//test/images/agnhost/dns:go_default_library", + "//test/images/agnhost/fakegitserver: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", "//test/images/agnhost/netexec:go_default_library", "//test/images/agnhost/nettest:go_default_library", + "//test/images/agnhost/no-snat-test:go_default_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/webhook:go_default_library", "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/k8s.io/klog:go_default_library", @@ -39,10 +45,16 @@ filegroup( srcs = [ ":package-srcs", "//test/images/agnhost/dns:all-srcs", + "//test/images/agnhost/fakegitserver:all-srcs", + "//test/images/agnhost/liveness:all-srcs", + "//test/images/agnhost/logs-generator:all-srcs", "//test/images/agnhost/net:all-srcs", "//test/images/agnhost/netexec:all-srcs", "//test/images/agnhost/nettest:all-srcs", + "//test/images/agnhost/no-snat-test:all-srcs", + "//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/webhook:all-srcs", ], tags = ["automanaged"], diff --git a/test/images/agnhost/Dockerfile b/test/images/agnhost/Dockerfile index 24cf5abbd69..1bd66a2190b 100644 --- a/test/images/agnhost/Dockerfile +++ b/test/images/agnhost/Dockerfile @@ -22,6 +22,10 @@ CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/ # - iproute2: includes ss used in NodePort tests RUN apk --update add curl netcat-openbsd iproute2 && rm -rf /var/cache/apk/* +# from logs-generator +ENV LOGS_GENERATOR_LINES_TOTAL 1 +ENV LOGS_GENERATOR_DURATION 1s + # PORT 8080 needed by: netexec, nettest # PORT 8081 needed by: netexec EXPOSE 8080 8081 @@ -31,3 +35,4 @@ RUN mkdir /uploads ADD agnhost agnhost ENTRYPOINT ["/agnhost"] +CMD ["pause"] diff --git a/test/images/agnhost/README.md b/test/images/agnhost/README.md index 93d3929d5ce..039617940d2 100644 --- a/test/images/agnhost/README.md +++ b/test/images/agnhost/README.md @@ -17,18 +17,8 @@ cases for the same tested behaviour. ## Usage -The `agnhost` binary is a CLI with the following subcommands: - -- `dns-suffix`: It will output the host's configured DNS suffix list, separated by commas. -- `dns-server-list`: It will output the host's configured DNS servers, separated by commas. -- `etc-hosts`: It will output the contents of host's `hosts` file. This file's location - is `/etc/hosts` on Linux, while on Windows it is `C:/Windows/System32/drivers/etc/hosts`. -- `pause`: It will pause the execution of the binary. This can be used for containers - which have to be kept in a `Running` state for various purposes, including executing - other `agnhost` commands. -- `help`: Prints the binary's help menu. Additionally, it can be followed by another - subcommand in order to get more information about that subcommand, including its - possible arguments. +The `agnhost` binary has several subcommands which are can be used to test different +Kubernetes features; their behaviour and output is not affected by the underlying OS. For example, let's consider the following `pod.yaml` file: @@ -74,6 +64,123 @@ created with the `pause` argument instead, allowing us execute multiple commands The `agnhost` binary is a CLI with the following subcommands: + +### dns-server-list + +It will output the host's configured DNS servers, separated by commas. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost dns-server-list +``` + + +### dns-suffix + +It will output the host's configured DNS suffix list, separated by commas. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost dns-suffix +``` + + +### etc-hosts + +It will output the contents of host's `hosts` file. This file's location is `/etc/hosts` +on Linux, while on Windows it is `C:/Windows/System32/drivers/etc/hosts`. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost etc-hosts +``` + + +### fake-gitserver + +Fakes a 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. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost fake-gitserver +``` + + +### help + +Prints the binary's help menu. Additionally, it can be followed by another subcommand +in order to get more information about that subcommand, including its possible arguments. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost help +``` + + +### liveness + +Starts a simple server that is alive for 10 seconds, then reports unhealthy for the rest +of its (hopefully) short existence. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost liveness +``` + + +### logs-generator + +The `logs-generator` subcommand is a tool to create predictable load on the logs delivery system. +It generates random lines with predictable format and predictable average length. +Each line can be later uniquely identified to ensure logs delivery. + +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 /api/v1/namespaces//endpoints/ +``` + +Where `` refers to the number from 0 to `total_lines - 1`, which is unique for each +line in a given run of the container. + +Examples: + +```console +docker run -i \ + gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ + logs-generator --log-lines-total 10 --run-duration 1 +``` + +```console +kubectl run logs-generator \ + --generator=run-pod/v1 \ + --image=gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ + --restart=Never \ + -- logs-generator -t 10 -d 1 +``` + +[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/logs-generator/README.md?pixel)]() + + ### net The goal of this Go project is to consolidate all low-level @@ -173,6 +280,93 @@ Usage: kubectl exec test-agnhost -- /agnhost nettest [--port ] [--peers ] [--service ] [--namespace ] [--delay-shutdown ] ``` + +### no-snat-test + +The subcommand requires the following environment variables to be set, and they should be +valid IP addresses: + +- `POD_IP` +- `NODE_IP` + +Serves the following endpoints on the given port (defaults to `8080`). + +- `/whoami` - returns the request's IP address. +- `/checknosnat` - queries `ip/whoami` for each provided IP (`/checknosnat?ips=ip1,ip2`), + and if all the response bodies match the `POD_IP`, it will return a 200 response, 500 otherwise. + +Usage: + +```console + kubectl run test-agnhost \ + --generator=run-pod/v1 \ + --image=gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ + --restart=Never \ + --env "POD_IP=" \ + --env "NODE_IP=" \ + -- no-snat-test [--port ] +``` + + +### no-snat-test-proxy + +Serves the `/checknosnat` endpoint on the given port (defaults to `31235`). The endpoint +proxies the request to the given `target` (`/checknosnat?target=target_ip&ips=ip1,ip2` +-> `target_ip/checknosnat?ips=ip1,ip2`) and will return the same status as the status +as the proxied request, or 500 on error. + + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost no-snat-test-proxy [--port ] +``` + + +### pause + +It will pause the execution of the binary. This can be used for containers +which have to be kept in a `Running` state for various purposes, including +executing other `agnhost` commands. + +Usage: + +```console + kubectl exec test-agnhost -- /agnhost pause +``` + + +### port-forward-tester + +Listens for TCP connections on a given address and port, optionally checks the data received, +and sends a configurable number of data chunks, with a configurable interval between chunks. + +The subcommand is using the following environment variables: + +- `BIND_ADDRESS` (optional): The address on which it will start listening for TCP connections (default value: `localhost`) +- `BIND_PORT`: The port on which it will start listening for TCP connections. +- `EXPECTED_CLIENT_DATA` (optional): If set, it will check that the request sends the same exact data. +- `CHUNKS`: How many chunks of data to write in the response. +- `CHUNK_SIZE`: The expected size of each written chunk of data. If it does not match the actual size of the written data, it will exit with the exit code `4`. +- `CHUNK_INTERVAL`: The amount of time to wait in between chunks. + +Usage: + +```console + kubectl run test-agnhost \ + --generator=run-pod/v1 \ + --image=gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ + --restart=Never \ + --env "BIND_ADDRESS=localhost" \ + --env "BIND_PORT=8080" \ + --env "EXPECTED_CLIENT_DATA='Hello there!'" \ + --env "CHUNKS=1" \ + --env "CHUNK_SIZE=10" \ + --env "CHUNK_INTERVAL=1" \ + -- port-forward-tester +``` + + ### webhook (Kubernetes External Admission Webhook) The subcommand tests MutatingAdmissionWebhook and ValidatingAdmissionWebhook. After deploying @@ -191,6 +385,6 @@ Usage: ## 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:1.1` for Linux +containers, and `e2eteam/agnhost:1.1` for Windows containers. In the future, the same repository can be used for both OSes. diff --git a/test/images/agnhost/agnhost.go b/test/images/agnhost/agnhost.go index 0f1a7809767..3db8f7c9093 100644 --- a/test/images/agnhost/agnhost.go +++ b/test/images/agnhost/agnhost.go @@ -23,10 +23,16 @@ import ( "k8s.io/klog" "k8s.io/kubernetes/test/images/agnhost/dns" + "k8s.io/kubernetes/test/images/agnhost/fakegitserver" + "k8s.io/kubernetes/test/images/agnhost/liveness" + "k8s.io/kubernetes/test/images/agnhost/logs-generator" "k8s.io/kubernetes/test/images/agnhost/net" "k8s.io/kubernetes/test/images/agnhost/netexec" "k8s.io/kubernetes/test/images/agnhost/nettest" + "k8s.io/kubernetes/test/images/agnhost/no-snat-test" + "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/webhook" ) @@ -35,10 +41,16 @@ func main() { rootCmd.AddCommand(dns.CmdDNSSuffix) rootCmd.AddCommand(dns.CmdDNSServerList) rootCmd.AddCommand(dns.CmdEtcHosts) + rootCmd.AddCommand(fakegitserver.CmdFakeGitServer) + rootCmd.AddCommand(liveness.CmdLiveness) + rootCmd.AddCommand(logsgen.CmdLogsGenerator) rootCmd.AddCommand(net.CmdNet) rootCmd.AddCommand(netexec.CmdNetexec) rootCmd.AddCommand(nettest.CmdNettest) + rootCmd.AddCommand(nosnat.CmdNoSnatTest) + rootCmd.AddCommand(nosnatproxy.CmdNoSnatTestProxy) rootCmd.AddCommand(pause.CmdPause) + rootCmd.AddCommand(portforwardtester.CmdPortForwardTester) rootCmd.AddCommand(webhook.CmdWebhook) // NOTE(claudiub): Some tests are passing logging related flags, so we need to be able to diff --git a/test/images/fakegitserver/BUILD b/test/images/agnhost/fakegitserver/BUILD similarity index 72% rename from test/images/fakegitserver/BUILD rename to test/images/agnhost/fakegitserver/BUILD index 17d78b163e2..70a2db097f8 100644 --- a/test/images/fakegitserver/BUILD +++ b/test/images/agnhost/fakegitserver/BUILD @@ -2,19 +2,14 @@ package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", - "go_binary", "go_library", ) -go_binary( - name = "fakegitserver", - embed = [":go_default_library"], -) - go_library( name = "go_default_library", srcs = ["gitserver.go"], - importpath = "k8s.io/kubernetes/test/images/fakegitserver", + importpath = "k8s.io/kubernetes/test/images/agnhost/fakegitserver", + deps = ["//vendor/github.com/spf13/cobra:go_default_library"], ) filegroup( diff --git a/test/images/fakegitserver/gitserver.go b/test/images/agnhost/fakegitserver/gitserver.go similarity index 67% rename from test/images/fakegitserver/gitserver.go rename to test/images/agnhost/fakegitserver/gitserver.go index 6077fb661c9..6ae1d67404e 100644 --- a/test/images/fakegitserver/gitserver.go +++ b/test/images/agnhost/fakegitserver/gitserver.go @@ -14,13 +14,25 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package fakegitserver import ( "io" "net/http" + + "github.com/spf13/cobra" ) +// CmdFakeGitServer is used by agnhost Cobra. +var CmdFakeGitServer = &cobra.Command{ + Use: "fake-gitserver", + Short: "Fakes a git server", + Long: `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.`, + Args: cobra.MaximumNArgs(0), + Run: main, +} + func hello(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "I am a fake git server") @@ -28,7 +40,7 @@ func hello(w http.ResponseWriter, r *http.Request) { // 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() { +func main(cmd *cobra.Command, args []string) { http.HandleFunc("/", hello) http.ListenAndServe(":8000", nil) } diff --git a/test/images/liveness/BUILD b/test/images/agnhost/liveness/BUILD similarity index 73% rename from test/images/liveness/BUILD rename to test/images/agnhost/liveness/BUILD index 47e6dd7d984..1d92ef6ca00 100644 --- a/test/images/liveness/BUILD +++ b/test/images/agnhost/liveness/BUILD @@ -2,19 +2,16 @@ package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", - "go_binary", "go_library", ) -go_binary( - name = "liveness", - embed = [":go_default_library"], -) - go_library( name = "go_default_library", srcs = ["server.go"], - importpath = "k8s.io/kubernetes/test/images/liveness", + importpath = "k8s.io/kubernetes/test/images/agnhost/liveness", + deps = [ + "//vendor/github.com/spf13/cobra:go_default_library", + ], ) filegroup( diff --git a/test/images/liveness/server.go b/test/images/agnhost/liveness/server.go similarity index 79% rename from test/images/liveness/server.go rename to test/images/agnhost/liveness/server.go index 7b6d7118a10..3ec2669df43 100644 --- a/test/images/liveness/server.go +++ b/test/images/agnhost/liveness/server.go @@ -16,7 +16,8 @@ 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 + +package liveness import ( "fmt" @@ -24,9 +25,20 @@ import ( "net/http" "net/url" "time" + + "github.com/spf13/cobra" ) -func main() { +// CmdLiveness is used by agnhost Cobra. +var CmdLiveness = &cobra.Command{ + Use: "liveness", + Short: "Starts a server that is alive for 10 seconds", + Long: "A simple server that is alive for 10 seconds, then reports unhealthy for the rest of its (hopefully) short existence", + Args: cobra.MaximumNArgs(0), + Run: main, +} + +func main(cmd *cobra.Command, args []string) { started := time.Now() http.HandleFunc("/started", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) diff --git a/test/images/logs-generator/BUILD b/test/images/agnhost/logs-generator/BUILD similarity index 78% rename from test/images/logs-generator/BUILD rename to test/images/agnhost/logs-generator/BUILD index c632d7d1533..1036a0cdd58 100644 --- a/test/images/logs-generator/BUILD +++ b/test/images/agnhost/logs-generator/BUILD @@ -2,21 +2,16 @@ package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", - "go_binary", "go_library", ) -go_binary( - name = "logs-generator", - embed = [":go_default_library"], -) - go_library( name = "go_default_library", srcs = ["logs_generator.go"], - importpath = "k8s.io/kubernetes/test/images/logs-generator", + importpath = "k8s.io/kubernetes/test/images/agnhost/logs-generator", deps = [ "//staging/src/k8s.io/apimachinery/pkg/util/rand:go_default_library", + "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/test/images/logs-generator/logs_generator.go b/test/images/agnhost/logs-generator/logs_generator.go similarity index 63% rename from test/images/logs-generator/logs_generator.go rename to test/images/agnhost/logs-generator/logs_generator.go index 27a65c3b798..9ff6120bacd 100644 --- a/test/images/logs-generator/logs_generator.go +++ b/test/images/agnhost/logs-generator/logs_generator.go @@ -14,13 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package logsgen import ( - "flag" "fmt" "time" + "github.com/spf13/cobra" + "k8s.io/apimachinery/pkg/util/rand" "k8s.io/klog" ) @@ -38,27 +39,35 @@ var ( } ) +// CmdLogsGenerator is used by agnhost Cobra. +var CmdLogsGenerator = &cobra.Command{ + Use: "logs-generator", + Short: "Outputs lines of logs to stdout uniformly", + Long: "Outputs lines of logs to stdout uniformly for ", + Args: cobra.MaximumNArgs(2), + Run: generateLogs, +} + 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") + linesTotal int + duration time.Duration ) -func main() { - flag.Parse() - - if *linesTotal <= 0 { - klog.Fatalf("Invalid total number of lines: %d", *linesTotal) - } - - if *duration <= 0 { - klog.Fatalf("Invalid duration: %v", *duration) - } - - generateLogs(*linesTotal, *duration) +func init() { + CmdLogsGenerator.Flags().IntVarP(&linesTotal, "log-lines-total", "t", 0, "Total lines that should be generated by the end of the run") + CmdLogsGenerator.Flags().DurationVarP(&duration, "run-duration", "d", 0, "Total duration of the run") } // Outputs linesTotal lines of logs to stdout uniformly for duration -func generateLogs(linesTotal int, duration time.Duration) { +func generateLogs(cmd *cobra.Command, args []string) { + if linesTotal <= 0 { + klog.Fatalf("Invalid total number of lines: %d", linesTotal) + } + + if duration <= 0 { + klog.Fatalf("Invalid duration: %v", duration) + } + delay := duration / time.Duration(linesTotal) ticker := time.NewTicker(delay) diff --git a/test/images/no-snat-test/BUILD b/test/images/agnhost/no-snat-test-proxy/BUILD similarity index 63% rename from test/images/no-snat-test/BUILD rename to test/images/agnhost/no-snat-test-proxy/BUILD index 9d8811d3c26..e68a8d1e5f4 100644 --- a/test/images/no-snat-test/BUILD +++ b/test/images/agnhost/no-snat-test-proxy/BUILD @@ -2,23 +2,16 @@ package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", - "go_binary", "go_library", ) -go_binary( - name = "no-snat-test", - embed = [":go_default_library"], -) - go_library( name = "go_default_library", srcs = ["main.go"], - importpath = "k8s.io/kubernetes/test/images/no-snat-test", + importpath = "k8s.io/kubernetes/test/images/agnhost/no-snat-test-proxy", deps = [ - "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", - "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/github.com/spf13/cobra:go_default_library", ], ) diff --git a/test/images/no-snat-test-proxy/main.go b/test/images/agnhost/no-snat-test-proxy/main.go similarity index 73% rename from test/images/no-snat-test-proxy/main.go rename to test/images/agnhost/no-snat-test-proxy/main.go index 7b2c9547964..1a3febf5c59 100644 --- a/test/images/no-snat-test-proxy/main.go +++ b/test/images/agnhost/no-snat-test-proxy/main.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package nosnatproxy import ( "fmt" @@ -22,32 +22,36 @@ import ( "net/http" "os" - "github.com/spf13/pflag" - cliflag "k8s.io/component-base/cli/flag" + "github.com/spf13/cobra" "k8s.io/component-base/logs" ) +// CmdNoSnatTestProxy is used by agnhost Cobra. +var CmdNoSnatTestProxy = &cobra.Command{ + Use: "no-snat-test-proxy", + Short: "Creates a proxy for the /checknosnat endpoint", + Long: `Creates the /checknosnat endpoint which proxies the request to the given target (/checknosnat?target=target_ip&ips=ip1,ip2) and returns its response, or a 500 response on error.`, + Args: cobra.MaximumNArgs(1), + Run: main, +} + +var port string + +func init() { + CmdNoSnatTestProxy.Flags().StringVar(&port, "port", "31235", "The port to serve /checknosnat endpoint on.") +} + // This Pod's /checknosnat takes `target` and `ips` arguments, and queries {target}/checknosnat?ips={ips} type masqTestProxy struct { Port string } -func newMasqTestProxy() *masqTestProxy { - return &masqTestProxy{ - Port: "31235", +func main(cmd *cobra.Command, args []string) { + m := &masqTestProxy{ + Port: port, } -} -func (m *masqTestProxy) AddFlags(fs *pflag.FlagSet) { - fs.StringVar(&m.Port, "port", m.Port, "The port to serve /checknosnat endpoint on.") -} - -func main() { - m := newMasqTestProxy() - m.AddFlags(pflag.CommandLine) - - cliflag.InitFlags() logs.InitLogs() defer logs.FlushLogs() diff --git a/test/images/no-snat-test-proxy/BUILD b/test/images/agnhost/no-snat-test/BUILD similarity index 62% rename from test/images/no-snat-test-proxy/BUILD rename to test/images/agnhost/no-snat-test/BUILD index 4e27ee6cbb8..69c927803f5 100644 --- a/test/images/no-snat-test-proxy/BUILD +++ b/test/images/agnhost/no-snat-test/BUILD @@ -2,23 +2,16 @@ package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", - "go_binary", "go_library", ) -go_binary( - name = "no-snat-test-proxy", - embed = [":go_default_library"], -) - go_library( name = "go_default_library", srcs = ["main.go"], - importpath = "k8s.io/kubernetes/test/images/no-snat-test-proxy", + importpath = "k8s.io/kubernetes/test/images/agnhost/no-snat-test", deps = [ - "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", - "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/github.com/spf13/cobra:go_default_library", ], ) diff --git a/test/images/no-snat-test/main.go b/test/images/agnhost/no-snat-test/main.go similarity index 82% rename from test/images/no-snat-test/main.go rename to test/images/agnhost/no-snat-test/main.go index bb94daf1a29..e77b53a34f6 100644 --- a/test/images/no-snat-test/main.go +++ b/test/images/agnhost/no-snat-test/main.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package nosnat import ( "fmt" @@ -24,11 +24,29 @@ import ( "os" "strings" - "github.com/spf13/pflag" - cliflag "k8s.io/component-base/cli/flag" + "github.com/spf13/cobra" "k8s.io/component-base/logs" ) +// CmdNoSnatTest is used by agnhost Cobra. +var CmdNoSnatTest = &cobra.Command{ + Use: "no-snat-test", + Short: "Creates the /checknosnat and /whoami endpoints", + Long: `Serves the following endpoints on the given port (defaults to "8080"). + +- /whoami - returns the request's IP address. +- /checknosnat - queries "ip/whoami" for each provided IP ("/checknosnat?ips=ip1,ip2"), + and if all the response bodies match the "POD_IP" environment variable, it will return a 200 response, 500 otherwise.`, + Args: cobra.MaximumNArgs(1), + Run: main, +} + +var port string + +func init() { + CmdNoSnatTest.Flags().StringVar(&port, "port", "8080", "The port to serve /checknosnat and /whoami endpoints on.") +} + // ip = target for /whoami query // rip = returned ip // pip = this pod's ip @@ -38,21 +56,11 @@ type masqTester struct { Port string } -func newMasqTester() *masqTester { - return &masqTester{ - Port: "8080", +func main(cmd *cobra.Command, args []string) { + m := &masqTester{ + Port: port, } -} -func (m *masqTester) AddFlags(fs *pflag.FlagSet) { - fs.StringVar(&m.Port, "port", m.Port, "The port to serve /checknosnat and /whoami endpoints on.") -} - -func main() { - m := newMasqTester() - m.AddFlags(pflag.CommandLine) - - cliflag.InitFlags() logs.InitLogs() defer logs.FlushLogs() diff --git a/test/images/port-forward-tester/BUILD b/test/images/agnhost/port-forward-tester/BUILD similarity index 71% rename from test/images/port-forward-tester/BUILD rename to test/images/agnhost/port-forward-tester/BUILD index d9833751314..68d4338e943 100644 --- a/test/images/port-forward-tester/BUILD +++ b/test/images/agnhost/port-forward-tester/BUILD @@ -2,19 +2,14 @@ package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", - "go_binary", "go_library", ) -go_binary( - name = "port-forward-tester", - embed = [":go_default_library"], -) - go_library( name = "go_default_library", srcs = ["portforwardtester.go"], - importpath = "k8s.io/kubernetes/test/images/port-forward-tester", + importpath = "k8s.io/kubernetes/test/images/agnhost/port-forward-tester", + deps = ["//vendor/github.com/spf13/cobra:go_default_library"], ) filegroup( diff --git a/test/images/port-forward-tester/portforwardtester.go b/test/images/agnhost/port-forward-tester/portforwardtester.go similarity index 79% rename from test/images/port-forward-tester/portforwardtester.go rename to test/images/agnhost/port-forward-tester/portforwardtester.go index 6131edc6582..9cff3ba5ea2 100644 --- a/test/images/port-forward-tester/portforwardtester.go +++ b/test/images/agnhost/port-forward-tester/portforwardtester.go @@ -26,7 +26,8 @@ limitations under the License. // Log messages are written to stdout at various stages of the binary's execution. // Test code can retrieve this container's log and validate that the expected // behavior is taking place. -package main + +package portforwardtester import ( "fmt" @@ -35,6 +36,8 @@ import ( "strconv" "strings" "time" + + "github.com/spf13/cobra" ) func getEnvInt(name string) int { @@ -58,7 +61,26 @@ func getEnvInt(name string) int { // This timeout is somewhat arbitrary (~latency around the planet). const rstAvoidanceDelay = 500 * time.Millisecond -func main() { +// CmdPortForwardTester is used by agnhost Cobra. +var CmdPortForwardTester = &cobra.Command{ + Use: "port-forward-tester", + Short: "Creates a TCP server that sends chunks of data", + Long: `Listens for TCP connections on a given address and port, optionally checks the data received, +and sends a configurable number of data chunks, with a configurable interval between chunks. + +The subcommand is using the following environment variables: + +- BIND_ADDRESS (optional): The address on which it will start listening for TCP connections (default value: localhost) +- BIND_PORT: The port on which it will start listening for TCP connections. +- EXPECTED_CLIENT_DATA (optional): If set, it will check that the request sends the same exact data. +- CHUNKS: How many chunks of data to write in the response. +- CHUNK_SIZE: The expected size of each written chunk of data. If it does not match the actual size of the written data, it will exit with the exit code 4. +- CHUNK_INTERVAL: The amount of time to wait in between chunks.`, + Args: cobra.MaximumNArgs(0), + Run: main, +} + +func main(cmd *cobra.Command, args []string) { bindAddress := os.Getenv("BIND_ADDRESS") if bindAddress == "" { bindAddress = "localhost" diff --git a/test/images/fakegitserver/Dockerfile b/test/images/fakegitserver/Dockerfile deleted file mode 100644 index e25b13e1d6a..00000000000 --- a/test/images/fakegitserver/Dockerfile +++ /dev/null @@ -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 -COPY GITHASH.txt / -COPY fakegitserver / -ENTRYPOINT ["/fakegitserver"] - diff --git a/test/images/fakegitserver/Makefile b/test/images/fakegitserver/Makefile deleted file mode 100644 index 34f07dc9da3..00000000000 --- a/test/images/fakegitserver/Makefile +++ /dev/null @@ -1,27 +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 = 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 diff --git a/test/images/fakegitserver/VERSION b/test/images/fakegitserver/VERSION deleted file mode 100644 index d3827e75a5c..00000000000 --- a/test/images/fakegitserver/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/test/images/hostexec/BASEIMAGE b/test/images/hostexec/BASEIMAGE deleted file mode 100644 index 7bad7a6d3a2..00000000000 --- a/test/images/hostexec/BASEIMAGE +++ /dev/null @@ -1,5 +0,0 @@ -amd64=alpine:3.6 -arm=arm32v6/alpine:3.6 -arm64=arm64v8/alpine:3.6 -ppc64le=ppc64le/alpine:3.6 -s390x=s390x/alpine:3.6 diff --git a/test/images/hostexec/Dockerfile b/test/images/hostexec/Dockerfile deleted file mode 100644 index f7edf8391a3..00000000000 --- a/test/images/hostexec/Dockerfile +++ /dev/null @@ -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. - -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 while true; do sleep 1d; done diff --git a/test/images/hostexec/VERSION b/test/images/hostexec/VERSION deleted file mode 100644 index 9459d4ba2a0..00000000000 --- a/test/images/hostexec/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.1 diff --git a/test/images/hostexec/pod.yaml b/test/images/hostexec/pod.yaml deleted file mode 100644 index 733d4273f75..00000000000 --- a/test/images/hostexec/pod.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: hostexec - labels: - app: hostexec -spec: - containers: - - name: hostexec - image: gcr.io/kubernetes-e2e-test-images/hostexec-amd64:1.1 - securityContext: - hostNetwork: true diff --git a/test/images/liveness/Dockerfile b/test/images/liveness/Dockerfile deleted file mode 100644 index fe022752c82..00000000000 --- a/test/images/liveness/Dockerfile +++ /dev/null @@ -1,17 +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 - -COPY liveness /server diff --git a/test/images/liveness/Makefile b/test/images/liveness/Makefile deleted file mode 100644 index e23182351bd..00000000000 --- a/test/images/liveness/Makefile +++ /dev/null @@ -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 = liveness -ARCH ?= amd64 -TARGET ?= $(CURDIR) -GOLANG_VERSION ?= latest -SRC_DIR = $(notdir $(shell pwd)) -export - -bin: - ../image-util.sh bin $(SRCS) - -.PHONY: bin diff --git a/test/images/liveness/VERSION b/test/images/liveness/VERSION deleted file mode 100644 index 9459d4ba2a0..00000000000 --- a/test/images/liveness/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.1 diff --git a/test/images/logs-generator/BASEIMAGE b/test/images/logs-generator/BASEIMAGE deleted file mode 100644 index 18f002a5e6f..00000000000 --- a/test/images/logs-generator/BASEIMAGE +++ /dev/null @@ -1,4 +0,0 @@ -amd64=busybox -arm=arm32v6/busybox -arm64=arm64v8/busybox -ppc64le=ppc64le/busybox diff --git a/test/images/logs-generator/Dockerfile b/test/images/logs-generator/Dockerfile deleted file mode 100644 index d3f091d447c..00000000000 --- a/test/images/logs-generator/Dockerfile +++ /dev/null @@ -1,22 +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 - -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}"] diff --git a/test/images/logs-generator/Makefile b/test/images/logs-generator/Makefile deleted file mode 100644 index 86902a2dac6..00000000000 --- a/test/images/logs-generator/Makefile +++ /dev/null @@ -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=logs-generator -ARCH ?= amd64 -TARGET ?= $(CURDIR) -GOLANG_VERSION ?= latest -SRC_DIR = $(notdir $(shell pwd)) -export - -bin: - ../image-util.sh bin $(SRCS) - -.PHONY: bin diff --git a/test/images/logs-generator/README.md b/test/images/logs-generator/README.md deleted file mode 100644 index b70b820756c..00000000000 --- a/test/images/logs-generator/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Logs Generator - -## Overview - -Logs generator is a tool to create predictable load on the logs delivery system. -It 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 /api/v1/namespaces//endpoints/ -``` - -Where `` 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 - -``` -k8s.gcr.io/logs-generator:v0.1.1 -``` - -## Examples - -``` -docker run -i \ - -e "LOGS_GENERATOR_LINES_TOTAL=10" \ - -e "LOGS_GENERATOR_DURATION=1s" \ - k8s.gcr.io/logs-generator:v0.1.1 -``` - -``` -kubectl run logs-generator \ - --generator=run-pod/v1 \ - --image=k8s.gcr.io/logs-generator:v0.1.1 \ - --restart=Never \ - --env "LOGS_GENERATOR_LINES_TOTAL=1000" \ - --env "LOGS_GENERATOR_DURATION=1m" -``` - -[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/logs-generator/README.md?pixel)]() diff --git a/test/images/logs-generator/VERSION b/test/images/logs-generator/VERSION deleted file mode 100644 index d3827e75a5c..00000000000 --- a/test/images/logs-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/test/images/no-snat-test-proxy/BASEIMAGE b/test/images/no-snat-test-proxy/BASEIMAGE deleted file mode 100644 index 114844f395e..00000000000 --- a/test/images/no-snat-test-proxy/BASEIMAGE +++ /dev/null @@ -1,4 +0,0 @@ -amd64=alpine:3.6 -arm=arm32v6/alpine:3.6 -arm64=arm64v8/alpine:3.6 -ppc64le=ppc64le/alpine:3.6 diff --git a/test/images/no-snat-test-proxy/Dockerfile b/test/images/no-snat-test-proxy/Dockerfile deleted file mode 100644 index 04a89a96bc0..00000000000 --- a/test/images/no-snat-test-proxy/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# 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 - -COPY no-snat-test-proxy / - -ENTRYPOINT ["/no-snat-test-proxy"] diff --git a/test/images/no-snat-test-proxy/Makefile b/test/images/no-snat-test-proxy/Makefile deleted file mode 100644 index 882b56fd090..00000000000 --- a/test/images/no-snat-test-proxy/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# 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. - -SRCS=no-snat-test-proxy -ARCH ?= amd64 -TARGET ?= $(CURDIR) -GOLANG_VERSION ?= latest -SRC_DIR = $(notdir $(shell pwd)) -export - -bin: - ../image-util.sh bin $(SRCS) - -.PHONY: bin diff --git a/test/images/no-snat-test-proxy/VERSION b/test/images/no-snat-test-proxy/VERSION deleted file mode 100644 index d3827e75a5c..00000000000 --- a/test/images/no-snat-test-proxy/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/test/images/no-snat-test/BASEIMAGE b/test/images/no-snat-test/BASEIMAGE deleted file mode 100644 index 114844f395e..00000000000 --- a/test/images/no-snat-test/BASEIMAGE +++ /dev/null @@ -1,4 +0,0 @@ -amd64=alpine:3.6 -arm=arm32v6/alpine:3.6 -arm64=arm64v8/alpine:3.6 -ppc64le=ppc64le/alpine:3.6 diff --git a/test/images/no-snat-test/Dockerfile b/test/images/no-snat-test/Dockerfile deleted file mode 100644 index b56749dbfa9..00000000000 --- a/test/images/no-snat-test/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -# 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 - -COPY no-snat-test / - -ENTRYPOINT ["/no-snat-test"] diff --git a/test/images/no-snat-test/Makefile b/test/images/no-snat-test/Makefile deleted file mode 100644 index 3c257410da3..00000000000 --- a/test/images/no-snat-test/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# 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. - -SRCS=no-snat-test -ARCH ?= amd64 -TARGET ?= $(CURDIR) -GOLANG_VERSION ?= latest -SRC_DIR = $(notdir $(shell pwd)) -export - -bin: - ../image-util.sh bin $(SRCS) - -.PHONY: bin diff --git a/test/images/no-snat-test/VERSION b/test/images/no-snat-test/VERSION deleted file mode 100644 index d3827e75a5c..00000000000 --- a/test/images/no-snat-test/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/test/images/port-forward-tester/.gitignore b/test/images/port-forward-tester/.gitignore deleted file mode 100644 index b43a4aae6d0..00000000000 --- a/test/images/port-forward-tester/.gitignore +++ /dev/null @@ -1 +0,0 @@ -portforwardtester diff --git a/test/images/port-forward-tester/Dockerfile b/test/images/port-forward-tester/Dockerfile deleted file mode 100644 index 3d27fc50fb7..00000000000 --- a/test/images/port-forward-tester/Dockerfile +++ /dev/null @@ -1,18 +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. - -FROM scratch -ADD portforwardtester portforwardtester -ADD portforwardtester.go portforwardtester.go -ENTRYPOINT ["/portforwardtester"] diff --git a/test/images/port-forward-tester/Makefile b/test/images/port-forward-tester/Makefile deleted file mode 100644 index 576ef5173ff..00000000000 --- a/test/images/port-forward-tester/Makefile +++ /dev/null @@ -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=portforwardtester -ARCH ?= amd64 -TARGET ?= $(CURDIR) -GOLANG_VERSION ?= latest -SRC_DIR = $(notdir $(shell pwd)) -export - -bin: - ../image-util.sh bin $(SRCS) - -.PHONY: bin diff --git a/test/images/port-forward-tester/VERSION b/test/images/port-forward-tester/VERSION deleted file mode 100644 index d3827e75a5c..00000000000 --- a/test/images/port-forward-tester/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.0 From 64c69094d3a4430115459d8fc424c7c8997ccff0 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Thu, 13 Jun 2019 14:58:22 -0700 Subject: [PATCH 3/5] Updates agnhost image version in documentation The version was bumped to 2.1, not 1.1. Co-Authored-By: Aaron Crickenberger --- test/images/agnhost/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/images/agnhost/README.md b/test/images/agnhost/README.md index 039617940d2..894592d1643 100644 --- a/test/images/agnhost/README.md +++ b/test/images/agnhost/README.md @@ -385,6 +385,6 @@ Usage: ## Image -The image can be found at `gcr.io/kubernetes-e2e-test-images/agnhost:1.1` for Linux -containers, and `e2eteam/agnhost:1.1` for Windows containers. In the future, the same +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 repository can be used for both OSes. From bad9e15509ec63a12c1edb7ea2c47bbe3dfcc4cb Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Mon, 10 Jun 2019 02:26:44 -0700 Subject: [PATCH 4/5] Updates agnhost README and Dockerfile files logs-generator used to be configured through env variables, but with the image centralization, that changed to flags. This commit updates the agnhost README to reflect that. --- test/images/agnhost/Dockerfile | 4 ---- test/images/agnhost/README.md | 19 +++++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/test/images/agnhost/Dockerfile b/test/images/agnhost/Dockerfile index 1bd66a2190b..e88050a6d57 100644 --- a/test/images/agnhost/Dockerfile +++ b/test/images/agnhost/Dockerfile @@ -22,10 +22,6 @@ CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/ # - iproute2: includes ss used in NodePort tests RUN apk --update add curl netcat-openbsd iproute2 && rm -rf /var/cache/apk/* -# from logs-generator -ENV LOGS_GENERATOR_LINES_TOTAL 1 -ENV LOGS_GENERATOR_DURATION 1s - # PORT 8080 needed by: netexec, nettest # PORT 8081 needed by: netexec EXPOSE 8080 8081 diff --git a/test/images/agnhost/README.md b/test/images/agnhost/README.md index 894592d1643..c1b47c0cc58 100644 --- a/test/images/agnhost/README.md +++ b/test/images/agnhost/README.md @@ -146,10 +146,9 @@ Tool is parametrized with the total number of number that should be generated an 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`. +Parameters are passed through CLI flags. There are no defaults, you should always pass the flags +to the container. Total number of line is parametrized through the flag `--log-lines-total` +and duration in go format is parametrized through the flag `--run-duration`. Inside the container all log lines are written to the stdout. @@ -166,16 +165,16 @@ Examples: ```console docker run -i \ - gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ - logs-generator --log-lines-total 10 --run-duration 1 + gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \ + 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:1.1 \ + --image=gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \ --restart=Never \ - -- logs-generator -t 10 -d 1 + -- logs-generator -t 10 -d 1s ``` [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/test/images/logs-generator/README.md?pixel)]() @@ -300,7 +299,7 @@ Usage: ```console kubectl run test-agnhost \ --generator=run-pod/v1 \ - --image=gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ + --image=gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \ --restart=Never \ --env "POD_IP=" \ --env "NODE_IP=" \ @@ -355,7 +354,7 @@ Usage: ```console kubectl run test-agnhost \ --generator=run-pod/v1 \ - --image=gcr.io/kubernetes-e2e-test-images/agnhost:1.1 \ + --image=gcr.io/kubernetes-e2e-test-images/agnhost:2.1 \ --restart=Never \ --env "BIND_ADDRESS=localhost" \ --env "BIND_PORT=8080" \ From b633031ec540b0bec4d65dea86a31b2220737bdb Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Wed, 12 Jun 2019 20:37:56 -0700 Subject: [PATCH 5/5] tests: Sets MaximumNArgs for agnhost subcommands to 0 The subcommands rely on flags, not args. Because of this, the cobra.MaximumNArgs should be set 0. --- test/images/agnhost/logs-generator/logs_generator.go | 2 +- test/images/agnhost/no-snat-test-proxy/main.go | 2 +- test/images/agnhost/no-snat-test/main.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/images/agnhost/logs-generator/logs_generator.go b/test/images/agnhost/logs-generator/logs_generator.go index 9ff6120bacd..edce35b2859 100644 --- a/test/images/agnhost/logs-generator/logs_generator.go +++ b/test/images/agnhost/logs-generator/logs_generator.go @@ -44,7 +44,7 @@ var CmdLogsGenerator = &cobra.Command{ Use: "logs-generator", Short: "Outputs lines of logs to stdout uniformly", Long: "Outputs lines of logs to stdout uniformly for ", - Args: cobra.MaximumNArgs(2), + Args: cobra.MaximumNArgs(0), Run: generateLogs, } diff --git a/test/images/agnhost/no-snat-test-proxy/main.go b/test/images/agnhost/no-snat-test-proxy/main.go index 1a3febf5c59..1065ad579b4 100644 --- a/test/images/agnhost/no-snat-test-proxy/main.go +++ b/test/images/agnhost/no-snat-test-proxy/main.go @@ -31,7 +31,7 @@ var CmdNoSnatTestProxy = &cobra.Command{ Use: "no-snat-test-proxy", Short: "Creates a proxy for the /checknosnat endpoint", Long: `Creates the /checknosnat endpoint which proxies the request to the given target (/checknosnat?target=target_ip&ips=ip1,ip2) and returns its response, or a 500 response on error.`, - Args: cobra.MaximumNArgs(1), + Args: cobra.MaximumNArgs(0), Run: main, } diff --git a/test/images/agnhost/no-snat-test/main.go b/test/images/agnhost/no-snat-test/main.go index e77b53a34f6..da534743c4d 100644 --- a/test/images/agnhost/no-snat-test/main.go +++ b/test/images/agnhost/no-snat-test/main.go @@ -37,7 +37,7 @@ var CmdNoSnatTest = &cobra.Command{ - /whoami - returns the request's IP address. - /checknosnat - queries "ip/whoami" for each provided IP ("/checknosnat?ips=ip1,ip2"), and if all the response bodies match the "POD_IP" environment variable, it will return a 200 response, 500 otherwise.`, - Args: cobra.MaximumNArgs(1), + Args: cobra.MaximumNArgs(0), Run: main, }