Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1a130776
Commit
1a130776
authored
Jun 11, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 'porter' test container
parent
cdef8ae8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
0 deletions
+166
-0
.gitignore
contrib/for-tests/porter/.gitignore
+2
-0
Dockerfile
contrib/for-tests/porter/Dockerfile
+18
-0
Makefile
contrib/for-tests/porter/Makefile
+32
-0
README.md
contrib/for-tests/porter/README.md
+5
-0
pod.json
contrib/for-tests/porter/pod.json
+53
-0
porter
contrib/for-tests/porter/porter
+0
-0
porter.go
contrib/for-tests/porter/porter.go
+56
-0
No files found.
contrib/for-tests/porter/.gitignore
0 → 100644
View file @
1a130776
porter
.tag
contrib/for-tests/porter/Dockerfile
0 → 100644
View file @
1a130776
# Copyright 2015 Google Inc. All rights reserved.
#
# 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
MAINTAINER
Daniel Smith <dbsmith@google.com>
ADD
porter porter
ENTRYPOINT
["/porter"]
contrib/for-tests/porter/Makefile
0 → 100644
View file @
1a130776
# Use:
#
# `make porter` will build porter.
# `make tag` will suggest a tag.
# `make container` will build a container-- you must supply a tag.
# `make push` will push the container-- you must supply a tag.
REPO
?=
gcr.io/google_containers
porter
:
porter.go
CGO_ENABLED
=
0
GOOS
=
linux go build
-a
-installsuffix
cgo
-ldflags
'-w'
./porter.go
.tag
:
porter
md5sum
porter |
cut
-d
" "
-f
1
>
.tag
tag
:
.tag
@
echo
"Suggest using TAG=
$(
shell
cat .tag
)
"
@
echo
"
$$
make container TAG=
$(
shell
cat .tag
)
"
@
echo
"or"
@
echo
"
$$
make push TAG=
$(
shell
cat .tag
)
"
container
:
$
(
if
$(TAG)
,,
$
(
error TAG is not defined. Use
'make tag'
to see a suggestion
))
docker build
-t
$(REPO)
/porter:
$(TAG)
.
push
:
$
(
if
$(TAG)
,,
$
(
error TAG is not defined. Use
'make tag'
to see a suggestion
))
gcloud preview docker push
$(REPO)
/porter:
$(TAG)
clean
:
rm
-f
porter
rm
-f
.tag
contrib/for-tests/porter/README.md
0 → 100644
View file @
1a130776
This directory contains go source, Dockerfile and Makefile for making a test
container which serves requested data on ports specified in ENV variables.
[

]()
contrib/for-tests/porter/pod.json
0 → 100644
View file @
1a130776
{
"kind"
:
"Pod"
,
"apiVersion"
:
"v1"
,
"metadata"
:
{
"name"
:
"kubectl-tester"
},
"spec"
:
{
"containers"
:
[
{
"name"
:
"bb"
,
"image"
:
"gcr.io/google_containers/busybox"
,
"command"
:
[
"sh"
,
"-c"
,
"sleep 5; wget -O - ${KUBERNETES_RO_SERVICE_HOST}:${KUBERNETES_RO_SERVICE_PORT}/api/v1/pods/; sleep 10000"
],
"ports"
:
[
{
"containerPort"
:
8080
}
],
"env"
:
[
{
"name"
:
"KUBERNETES_RO_SERVICE_HOST"
,
"value"
:
"127.0.0.1"
},
{
"name"
:
"KUBERNETES_RO_SERVICE_PORT"
,
"value"
:
"8001"
}
],
"volumeMounts"
:
[
{
"name"
:
"test-volume"
,
"mountPath"
:
"/mount/test-volume"
}
]
},
{
"name"
:
"kubectl"
,
"image"
:
"gcr.io/google_containers/kubectl:v0.18.0-120-gaeb4ac55ad12b1-dirty"
,
"imagePullPolicy"
:
"Always"
,
"args"
:
[
"proxy"
,
"-p"
,
"8001"
]
}
],
"volumes"
:
[
{
"name"
:
"test-volume"
,
"emptyDir"
:
{}
}
]
}
}
contrib/for-tests/porter/porter
0 → 100755
View file @
1a130776
File added
contrib/for-tests/porter/porter.go
0 → 100644
View file @
1a130776
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// A tiny binary for testing ports.
//
// Reads env vars; for every var of the form SERVE_PORT_X, where X is a valid
// port number, porter starts an HTTP server which serves the env var's value
// in response to any query.
package
main
import
(
"fmt"
"log"
"net/http"
"os"
"strings"
)
const
prefix
=
"SERVE_PORT_"
func
main
()
{
for
_
,
vk
:=
range
os
.
Environ
()
{
parts
:=
strings
.
Split
(
vk
,
"="
)
key
:=
parts
[
0
]
value
:=
parts
[
1
]
if
strings
.
HasPrefix
(
key
,
prefix
)
{
port
:=
strings
.
TrimPrefix
(
key
,
prefix
)
go
servePort
(
port
,
value
)
}
}
select
{}
}
func
servePort
(
port
,
value
string
)
{
s
:=
&
http
.
Server
{
Addr
:
"0.0.0.0:"
+
port
,
Handler
:
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
fmt
.
Fprint
(
w
,
value
)
}),
}
log
.
Printf
(
"server on port %q failed: %v"
,
port
,
s
.
ListenAndServe
())
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment