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
2148fb78
Commit
2148fb78
authored
Aug 11, 2015
by
Filip Grzadkowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12223 from thockin/srv-hostname
Update serve_hostname
parents
3f7b54cb
384bcbb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
7 deletions
+18
-7
Dockerfile
contrib/for-demos/serve_hostname/Dockerfile
+1
-1
Makefile
contrib/for-demos/serve_hostname/Makefile
+11
-5
serve_hostname.go
contrib/for-demos/serve_hostname/serve_hostname.go
+6
-1
No files found.
contrib/for-demos/serve_hostname/Dockerfile
View file @
2148fb78
FROM
scratch
FROM
busybox
MAINTAINER
Tim Hockin <thockin@google.com>
MAINTAINER
Tim Hockin <thockin@google.com>
ADD
serve_hostname /serve_hostname
ADD
serve_hostname /serve_hostname
ADD
serve_hostname.go /serve_hostname.go
ADD
serve_hostname.go /serve_hostname.go
...
...
contrib/for-demos/serve_hostname/Makefile
View file @
2148fb78
all
:
serve_hostname
all
:
serve_hostname
TAG
=
1.1
TAG
=
v1.2
PREFIX
=
gcr.io/google_containers
TEST_PREFIX
=
gcr.io/_b_k8s_authenticated_test
serve_hostname
:
serve_hostname.go
serve_hostname
:
serve_hostname.go
CGO_ENABLED
=
0 go build
-a
-installsuffix
cgo
--ldflags
'-w'
./serve_hostname.go
CGO_ENABLED
=
0 go build
-a
-installsuffix
cgo
--ldflags
'-w'
./serve_hostname.go
container
:
serve_hostname
container
:
serve_hostname
sudo
docker build
-t
gcr.io/google_containers/serve_hostname:
$(TAG)
.
docker build
-t
$(PREFIX)
/serve_hostname:
$(TAG)
.
sudo
docker tag gcr.io/google_containers/serve_hostname:
$(TAG)
gcr.io/_b_k8s_authenticated_test/serve_hostname:
$(TAG)
if
[
-n
"
$(TEST_PREFIX)
"
]
;
then
\
docker tag
-f
$(PREFIX)
/serve_hostname:
$(TAG)
$(TEST_PREFIX)
/serve_hostname:
$(TAG)
;
\
fi
push
:
push
:
gcloud docker push gcr.io/google_containers/serve_hostname:
$(TAG)
gcloud docker push
$(PREFIX)
/serve_hostname:
$(TAG)
gcloud docker push gcr.io/_b_k8s_authenticated_test/serve_hostname:
$(TAG)
if
[
-n
"
$(TEST_PREFIX)
"
]
;
then
\
gcloud docker push
$(TEST_PREFIX)
/serve_hostname:
$(TAG)
;
\
fi
clean
:
clean
:
rm
-f
serve_hostname
rm
-f
serve_hostname
contrib/for-demos/serve_hostname/serve_hostname.go
View file @
2148fb78
...
@@ -56,6 +56,7 @@ func main() {
...
@@ -56,6 +56,7 @@ func main() {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Error from Accept(): %s"
,
err
)
log
.
Fatalf
(
"Error from Accept(): %s"
,
err
)
}
}
log
.
Printf
(
"TCP request from %s"
,
conn
.
RemoteAddr
()
.
String
())
conn
.
Write
([]
byte
(
hostname
))
conn
.
Write
([]
byte
(
hostname
))
conn
.
Close
()
conn
.
Close
()
}
}
...
@@ -77,12 +78,16 @@ func main() {
...
@@ -77,12 +78,16 @@ func main() {
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Error from ReadFrom(): %s"
,
err
)
log
.
Fatalf
(
"Error from ReadFrom(): %s"
,
err
)
}
}
log
.
Printf
(
"UDP request from %s"
,
cliAddr
.
String
())
sock
.
WriteTo
([]
byte
(
hostname
),
cliAddr
)
sock
.
WriteTo
([]
byte
(
hostname
),
cliAddr
)
}
}
}()
}()
}
}
if
*
doHttp
{
if
*
doHttp
{
http
.
HandleFunc
(
"/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
fmt
.
Fprintf
(
w
,
"%s"
,
hostname
)
})
http
.
HandleFunc
(
"/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
log
.
Printf
(
"HTTP request from %s"
,
r
.
RemoteAddr
)
fmt
.
Fprintf
(
w
,
"%s"
,
hostname
)
})
go
log
.
Fatal
(
http
.
ListenAndServe
(
fmt
.
Sprintf
(
":%d"
,
*
port
),
nil
))
go
log
.
Fatal
(
http
.
ListenAndServe
(
fmt
.
Sprintf
(
":%d"
,
*
port
),
nil
))
}
}
...
...
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