Centralizes images into agnhost (part 3)

Centralizes the following images into agnhost:

- audit-proxy
- crd-conversion-webhook
- entrypoint-tester
- inclusterclient
- iperf
- porter
- serve-hostname
This commit is contained in:
Claudiu Belu 2019-05-20 14:15:10 -07:00
parent 8245461a8d
commit af5c0c9e09
56 changed files with 324 additions and 556 deletions

View File

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

View File

@ -16,8 +16,12 @@ go_library(
srcs = ["agnhost.go"], srcs = ["agnhost.go"],
importpath = "k8s.io/kubernetes/test/images/agnhost", importpath = "k8s.io/kubernetes/test/images/agnhost",
deps = [ 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/dns:go_default_library",
"//test/images/agnhost/entrypoint-tester:go_default_library",
"//test/images/agnhost/fakegitserver: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/liveness:go_default_library",
"//test/images/agnhost/logs-generator:go_default_library", "//test/images/agnhost/logs-generator:go_default_library",
"//test/images/agnhost/net: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/no-snat-test-proxy:go_default_library",
"//test/images/agnhost/pause:go_default_library", "//test/images/agnhost/pause:go_default_library",
"//test/images/agnhost/port-forward-tester: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", "//test/images/agnhost/webhook:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library", "//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/klog:go_default_library",
@ -44,8 +50,12 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [ srcs = [
":package-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/dns:all-srcs",
"//test/images/agnhost/entrypoint-tester:all-srcs",
"//test/images/agnhost/fakegitserver:all-srcs", "//test/images/agnhost/fakegitserver:all-srcs",
"//test/images/agnhost/inclusterclient:all-srcs",
"//test/images/agnhost/liveness:all-srcs", "//test/images/agnhost/liveness:all-srcs",
"//test/images/agnhost/logs-generator:all-srcs", "//test/images/agnhost/logs-generator:all-srcs",
"//test/images/agnhost/net: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/no-snat-test-proxy:all-srcs",
"//test/images/agnhost/pause:all-srcs", "//test/images/agnhost/pause:all-srcs",
"//test/images/agnhost/port-forward-tester: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", "//test/images/agnhost/webhook:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],

View File

@ -20,15 +20,28 @@ CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/
# install necessary packages: # install necessary packages:
# - curl, nc: used by a lot of e2e tests # - curl, nc: used by a lot of e2e tests
# - iproute2: includes ss used in NodePort 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 8080 needed by: netexec, nettest
# PORT 8081 needed by: netexec # PORT 8081 needed by: netexec
EXPOSE 8080 8081 # PORT 9376 needed by: serve-hostname
EXPOSE 8080 8081 9376
# from netexec # from netexec
RUN mkdir /uploads RUN mkdir /uploads
# from porter
ADD porter/localhost.crt localhost.crt
ADD porter/localhost.key localhost.key
ADD agnhost agnhost ADD agnhost agnhost
# needed for the entrypoint-tester related tests.
RUN ln -s agnhost agnhost-2
ENTRYPOINT ["/agnhost"] ENTRYPOINT ["/agnhost"]
CMD ["pause"] CMD ["pause"]

View File

@ -31,7 +31,7 @@ For example, let's consider the following `pod.yaml` file:
containers: containers:
- args: - args:
- dns-suffix - dns-suffix
image: gcr.io/kubernetes-e2e-test-images/agnhost:2.1 image: gcr.io/kubernetes-e2e-test-images/agnhost:2.2
name: agnhost name: agnhost
dnsConfig: dnsConfig:
nameservers: 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: 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 ### dns-server-list
It will output the host's configured DNS servers, separated by commas. 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 ### etc-hosts
It will output the contents of host's `hosts` file. This file's location is `/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 ### liveness
Starts a simple server that is alive for 10 seconds, then reports unhealthy for the rest Starts a simple server that is alive for 10 seconds, then reports unhealthy for the rest
@ -165,14 +221,14 @@ Examples:
```console ```console
docker run -i \ 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 logs-generator --log-lines-total 10 --run-duration 1s
``` ```
```console ```console
kubectl run logs-generator \ kubectl run logs-generator \
--generator=run-pod/v1 \ --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 \ --restart=Never \
-- logs-generator -t 10 -d 1s -- logs-generator -t 10 -d 1s
``` ```
@ -299,7 +355,7 @@ Usage:
```console ```console
kubectl run test-agnhost \ kubectl run test-agnhost \
--generator=run-pod/v1 \ --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 \ --restart=Never \
--env "POD_IP=<POD_IP>" \ --env "POD_IP=<POD_IP>" \
--env "NODE_IP=<NODE_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) ### webhook (Kubernetes External Admission Webhook)
The subcommand tests MutatingAdmissionWebhook and ValidatingAdmissionWebhook. After deploying 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>] kubectl exec test-agnhost -- /agnhost webhook [--tls-cert-file <key-file>] [--tls-private-key-file <cert-file>]
``` ```
## Other tools
The image contains `iperf`.
## Image ## Image
The image can be found at `gcr.io/kubernetes-e2e-test-images/agnhost:2.1` for Linux The image can be found at `gcr.io/kubernetes-e2e-test-images/agnhost:2.2` for Linux
containers, and `e2eteam/agnhost:2.1` for Windows containers. In the future, the same containers, and `e2eteam/agnhost:2.2` for Windows containers. In the future, the same
repository can be used for both OSes. 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" "github.com/spf13/cobra"
"k8s.io/klog" "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/dns"
"k8s.io/kubernetes/test/images/agnhost/entrypoint-tester"
"k8s.io/kubernetes/test/images/agnhost/fakegitserver" "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/liveness"
"k8s.io/kubernetes/test/images/agnhost/logs-generator" "k8s.io/kubernetes/test/images/agnhost/logs-generator"
"k8s.io/kubernetes/test/images/agnhost/net" "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/no-snat-test-proxy"
"k8s.io/kubernetes/test/images/agnhost/pause" "k8s.io/kubernetes/test/images/agnhost/pause"
"k8s.io/kubernetes/test/images/agnhost/port-forward-tester" "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" "k8s.io/kubernetes/test/images/agnhost/webhook"
) )
func main() { func main() {
rootCmd := &cobra.Command{Use: "app"} rootCmd := &cobra.Command{Use: "app"}
rootCmd.AddCommand(auditproxy.CmdAuditProxy)
rootCmd.AddCommand(crdconvwebhook.CmdCrdConversionWebhook)
rootCmd.AddCommand(dns.CmdDNSSuffix) rootCmd.AddCommand(dns.CmdDNSSuffix)
rootCmd.AddCommand(dns.CmdDNSServerList) rootCmd.AddCommand(dns.CmdDNSServerList)
rootCmd.AddCommand(dns.CmdEtcHosts) rootCmd.AddCommand(dns.CmdEtcHosts)
rootCmd.AddCommand(entrypoint.CmdEntrypointTester)
rootCmd.AddCommand(fakegitserver.CmdFakeGitServer) rootCmd.AddCommand(fakegitserver.CmdFakeGitServer)
rootCmd.AddCommand(inclusterclient.CmdInClusterClient)
rootCmd.AddCommand(liveness.CmdLiveness) rootCmd.AddCommand(liveness.CmdLiveness)
rootCmd.AddCommand(logsgen.CmdLogsGenerator) rootCmd.AddCommand(logsgen.CmdLogsGenerator)
rootCmd.AddCommand(net.CmdNet) rootCmd.AddCommand(net.CmdNet)
@ -50,7 +60,9 @@ func main() {
rootCmd.AddCommand(nosnat.CmdNoSnatTest) rootCmd.AddCommand(nosnat.CmdNoSnatTest)
rootCmd.AddCommand(nosnatproxy.CmdNoSnatTestProxy) rootCmd.AddCommand(nosnatproxy.CmdNoSnatTestProxy)
rootCmd.AddCommand(pause.CmdPause) rootCmd.AddCommand(pause.CmdPause)
rootCmd.AddCommand(porter.CmdPorter)
rootCmd.AddCommand(portforwardtester.CmdPortForwardTester) rootCmd.AddCommand(portforwardtester.CmdPortForwardTester)
rootCmd.AddCommand(servehostname.CmdServeHostname)
rootCmd.AddCommand(webhook.CmdWebhook) rootCmd.AddCommand(webhook.CmdWebhook)
// NOTE(claudiub): Some tests are passing logging related flags, so we need to be able to // 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( go_library(
name = "go_default_library", name = "go_default_library",
srcs = ["main.go"], srcs = ["main.go"],
importpath = "k8s.io/kubernetes/test/images/audit-proxy", importpath = "k8s.io/kubernetes/test/images/agnhost/audit-proxy",
visibility = ["//visibility:private"], visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//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/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/install:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/audit/v1: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", "//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( filegroup(
name = "package-srcs", name = "package-srcs",
srcs = glob(["**"]), srcs = glob(["**"]),

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package main package auditproxy
import ( import (
"io/ioutil" "io/ioutil"
@ -22,6 +22,8 @@ import (
"net/http" "net/http"
"os" "os"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/apimachinery/pkg/runtime/serializer/json"
auditinstall "k8s.io/apiserver/pkg/apis/audit/install" auditinstall "k8s.io/apiserver/pkg/apis/audit/install"
@ -29,12 +31,21 @@ import (
"k8s.io/apiserver/pkg/audit" "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 ( var (
encoder runtime.Encoder encoder runtime.Encoder
decoder runtime.Decoder decoder runtime.Decoder
) )
func main() { func main(cmd *cobra.Command, args []string) {
scheme := runtime.NewScheme() scheme := runtime.NewScheme()
auditinstall.Install(scheme) auditinstall.Install(scheme)
serializer := json.NewSerializer(json.DefaultMetaFactory, scheme, scheme, false) 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( go_library(
name = "go_default_library", name = "go_default_library",
@ -6,22 +6,17 @@ go_library(
"config.go", "config.go",
"main.go", "main.go",
], ],
importpath = "k8s.io/kubernetes/test/images/crd-conversion-webhook", importpath = "k8s.io/kubernetes/test/images/agnhost/crd-conversion-webhook",
visibility = ["//visibility:private"], visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/rest: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", "//vendor/k8s.io/klog:go_default_library",
], ],
) )
go_binary(
name = "crd-conversion-webhook",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup( filegroup(
name = "package-srcs", name = "package-srcs",
srcs = glob(["**"]), srcs = glob(["**"]),
@ -33,7 +28,7 @@ filegroup(
name = "all-srcs", name = "all-srcs",
srcs = [ srcs = [
":package-srcs", ":package-srcs",
"//test/images/crd-conversion-webhook/converter:all-srcs", "//test/images/agnhost/crd-conversion-webhook/converter:all-srcs",
], ],
tags = ["automanaged"], tags = ["automanaged"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],

View File

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

View File

@ -6,7 +6,7 @@ go_library(
"example_converter.go", "example_converter.go",
"framework.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"], visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library", "//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. limitations under the License.
*/ */
package main package crdconvwebhook
import ( import (
"flag"
"net/http" "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. // Config contains the server (the webhook) cert and key.
type Config struct { type Config struct {
CertFile string CertFile string
KeyFile string KeyFile string
} }
func (c *Config) addFlags() { func main(cmd *cobra.Command, args []string) {
flag.StringVar(&c.CertFile, "tls-cert-file", c.CertFile, ""+ config := Config{CertFile: certFile, KeyFile: keyFile}
"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()
http.HandleFunc("/crdconvert", converter.ServeExampleConvert) http.HandleFunc("/crdconvert", converter.ServeExampleConvert)
clientset := getClient() clientset := getClient()

View File

@ -1,20 +1,12 @@
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load( load("@io_bazel_rules_go//go:def.bzl", "go_library")
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "entrypoint-tester",
embed = [":go_default_library"],
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = ["ep.go"], 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( filegroup(

View File

@ -14,16 +14,25 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package main package entrypoint
import ( import (
"fmt" "fmt"
"os" "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 the arguments it's passed and exits. // This program prints the arguments it's passed and exits.
func main() { func main(cmd *cobra.Command, args []string) {
args := os.Args fmt.Printf("%v\n", os.Args)
fmt.Printf("%v\n", args)
os.Exit(0) 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( go_library(
name = "go_default_library", name = "go_default_library",
srcs = ["main.go"], srcs = ["main.go"],
importpath = "k8s.io/kubernetes/test/images/inclusterclient", importpath = "k8s.io/kubernetes/test/images/agnhost/inclusterclient",
visibility = ["//visibility:private"], visibility = ["//visibility:public"],
deps = [ deps = [
"//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library",
"//staging/src/k8s.io/client-go/rest:go_default_library", "//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/component-base/logs: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", "//vendor/k8s.io/klog:go_default_library",
], ],
) )
go_binary(
name = "inclusterconfig",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
filegroup( filegroup(
name = "package-srcs", name = "package-srcs",
srcs = glob(["**"]), srcs = glob(["**"]),

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package main package inclusterclient
import ( import (
"crypto/sha256" "crypto/sha256"
@ -25,19 +25,37 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/component-base/logs" "k8s.io/component-base/logs"
"k8s.io/klog" "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() logs.InitLogs()
defer logs.FlushLogs() defer logs.FlushLogs()
pollInterval := flag.Int("poll-interval", 30, "poll interval of call to /healhtz in seconds")
flag.Set("logtostderr", "true") flag.Set("logtostderr", "true")
flag.Parse()
klog.Infof("started") klog.Infof("started")
@ -54,7 +72,7 @@ func main() {
c := kubernetes.NewForConfigOrDie(cfg).RESTClient() c := kubernetes.NewForConfigOrDie(cfg).RESTClient()
t := time.Tick(time.Duration(*pollInterval) * time.Second) t := time.Tick(time.Duration(pollInterval) * time.Second)
for { for {
<-t <-t
klog.Infof("calling /healthz") klog.Infof("calling /healthz")

View File

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

View File

@ -2,19 +2,14 @@ package(default_visibility = ["//visibility:public"])
load( load(
"@io_bazel_rules_go//go:def.bzl", "@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library", "go_library",
) )
go_binary(
name = "porter",
embed = [":go_default_library"],
)
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = ["porter.go"], 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( 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 // 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 // port number, porter starts an HTTP server which serves the env var's value
// in response to any query. // in response to any query.
package main
package porter
import ( import (
"fmt" "fmt"
@ -27,12 +28,29 @@ import (
"net/http" "net/http"
"os" "os"
"strings" "strings"
"github.com/spf13/cobra"
) )
const prefix = "SERVE_PORT_" const prefix = "SERVE_PORT_"
const tlsPrefix = "SERVE_TLS_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() { for _, vk := range os.Environ() {
// Put everything before the first = sign in parts[0], and // Put everything before the first = sign in parts[0], and
// everything else in parts[1] (even if there are multiple = // everything else in parts[1] (even if there are multiple =

View File

@ -2,14 +2,16 @@ package(default_visibility = ["//visibility:public"])
load( load(
"@io_bazel_rules_go//go:def.bzl", "@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library", "go_library",
) )
go_library( go_library(
name = "go_default_library", name = "go_default_library",
srcs = ["serve_hostname.go"], 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( filegroup(
@ -24,8 +26,3 @@ filegroup(
srcs = [":package-srcs"], srcs = [":package-srcs"],
tags = ["automanaged"], 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. // A small utility to just serve the hostname on TCP and/or UDP.
package main
package servehostname
import ( import (
"flag"
"fmt" "fmt"
"log" "log"
"net" "net"
@ -27,19 +27,37 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"time" "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 ( var (
doTCP = flag.Bool("tcp", false, "Serve raw over TCP.") doTCP bool
doUDP = flag.Bool("udp", false, "Serve raw over UDP.") doUDP bool
doHTTP = flag.Bool("http", true, "Serve HTTP.") doHTTP bool
doClose = flag.Bool("close", false, "Close connection per each HTTP request") doClose bool
port = flag.Int("port", 9376, "Port number.") port int
) )
func main() { func init() {
flag.Parse() CmdServeHostname.Flags().BoolVar(&doTCP, "tcp", false, "Serve raw over TCP.")
if *doHTTP && (*doTCP || *doUDP) { 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") 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) log.Fatalf("Error from os.Hostname(): %s", err)
} }
if *doTCP { if doTCP {
listener, err := net.Listen("tcp", fmt.Sprintf(":%d", *port)) listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil { if err != nil {
log.Fatalf("Error from net.Listen(): %s", err) log.Fatalf("Error from net.Listen(): %s", err)
} }
@ -65,8 +83,8 @@ func main() {
} }
}() }()
} }
if *doUDP { if doUDP {
addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", *port)) addr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", port))
if err != nil { if err != nil {
log.Fatalf("Error from net.ResolveUDPAddr(): %s", err) 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) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Printf("HTTP request from %s", r.RemoteAddr) 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. // Add this header to force to close the connection after serving the request.
w.Header().Add("Connection", "close") w.Header().Add("Connection", "close")
} }
@ -99,10 +117,10 @@ func main() {
}) })
go func() { go func() {
// Run in a closure so http.ListenAndServe doesn't block // 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) signals := make(chan os.Signal)
signal.Notify(signals, syscall.SIGTERM) signal.Notify(signals, syscall.SIGTERM)
sig := <-signals 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,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