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
060cb437
Commit
060cb437
authored
Jun 24, 2015
by
Maxwell Forbes
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10134 from brendandburns/gongysh2004-nodeport
Fix the warning when you create an externalized service
parents
26d3a442
f0ff1927
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
create.go
pkg/kubectl/cmd/create.go
+12
-6
create_test.go
pkg/kubectl/cmd/create_test.go
+17
-1
No files found.
pkg/kubectl/cmd/create.go
View file @
060cb437
...
@@ -126,8 +126,8 @@ func printObjectSpecificMessage(obj runtime.Object, out io.Writer) {
...
@@ -126,8 +126,8 @@ func printObjectSpecificMessage(obj runtime.Object, out io.Writer) {
An external load-balanced service was created. On many platforms (e.g. Google Compute Engine),
An external load-balanced service was created. On many platforms (e.g. Google Compute Engine),
you will also need to explicitly open a Firewall rule for the service port(s) (%s) to serve traffic.
you will also need to explicitly open a Firewall rule for the service port(s) (%s) to serve traffic.
See https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/services-firewall.md for more details.
See https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/services-firewall
s
.md for more details.
`
,
makePortsString
(
obj
.
Spec
.
Ports
))
`
,
makePortsString
(
obj
.
Spec
.
Ports
,
false
))
out
.
Write
([]
byte
(
msg
))
out
.
Write
([]
byte
(
msg
))
}
}
if
obj
.
Spec
.
Type
==
api
.
ServiceTypeNodePort
{
if
obj
.
Spec
.
Type
==
api
.
ServiceTypeNodePort
{
...
@@ -136,17 +136,23 @@ func printObjectSpecificMessage(obj runtime.Object, out io.Writer) {
...
@@ -136,17 +136,23 @@ func printObjectSpecificMessage(obj runtime.Object, out io.Writer) {
If you want to expose this service to the external internet, you may need to set up
If you want to expose this service to the external internet, you may need to set up
firewall rules for the service port(s) (%s) to serve traffic.
firewall rules for the service port(s) (%s) to serve traffic.
See https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/services-firewall.md for more details.
See https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/services-firewall
s
.md for more details.
`
,
makePortsString
(
obj
.
Spec
.
Ports
))
`
,
makePortsString
(
obj
.
Spec
.
Ports
,
true
))
out
.
Write
([]
byte
(
msg
))
out
.
Write
([]
byte
(
msg
))
}
}
}
}
}
}
func
makePortsString
(
ports
[]
api
.
ServicePort
)
string
{
func
makePortsString
(
ports
[]
api
.
ServicePort
,
useNodePort
bool
)
string
{
pieces
:=
make
([]
string
,
len
(
ports
))
pieces
:=
make
([]
string
,
len
(
ports
))
for
ix
:=
range
ports
{
for
ix
:=
range
ports
{
pieces
[
ix
]
=
fmt
.
Sprintf
(
"%s:%d"
,
strings
.
ToLower
(
string
(
ports
[
ix
]
.
Protocol
)),
ports
[
ix
]
.
Port
)
var
port
int
if
useNodePort
{
port
=
ports
[
ix
]
.
NodePort
}
else
{
port
=
ports
[
ix
]
.
Port
}
pieces
[
ix
]
=
fmt
.
Sprintf
(
"%s:%d"
,
strings
.
ToLower
(
string
(
ports
[
ix
]
.
Protocol
)),
port
)
}
}
return
strings
.
Join
(
pieces
,
","
)
return
strings
.
Join
(
pieces
,
","
)
}
}
pkg/kubectl/cmd/create_test.go
View file @
060cb437
...
@@ -169,6 +169,7 @@ func TestPrintObjectSpecificMessage(t *testing.T) {
...
@@ -169,6 +169,7 @@ func TestPrintObjectSpecificMessage(t *testing.T) {
func
TestMakePortsString
(
t
*
testing
.
T
)
{
func
TestMakePortsString
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
ports
[]
api
.
ServicePort
ports
[]
api
.
ServicePort
useNodePort
bool
expectedOutput
string
expectedOutput
string
}{
}{
{
ports
:
nil
,
expectedOutput
:
""
},
{
ports
:
nil
,
expectedOutput
:
""
},
...
@@ -197,9 +198,24 @@ func TestMakePortsString(t *testing.T) {
...
@@ -197,9 +198,24 @@ func TestMakePortsString(t *testing.T) {
},
},
expectedOutput
:
"tcp:80,udp:8080,tcp:9000"
,
expectedOutput
:
"tcp:80,udp:8080,tcp:9000"
,
},
},
{
ports
:
[]
api
.
ServicePort
{
{
Port
:
80
,
NodePort
:
9090
,
Protocol
:
"TCP"
,
},
{
Port
:
8080
,
NodePort
:
80
,
Protocol
:
"UDP"
,
},
},
useNodePort
:
true
,
expectedOutput
:
"tcp:9090,udp:80"
,
},
}
}
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
output
:=
makePortsString
(
test
.
ports
)
output
:=
makePortsString
(
test
.
ports
,
test
.
useNodePort
)
if
output
!=
test
.
expectedOutput
{
if
output
!=
test
.
expectedOutput
{
t
.
Errorf
(
"expected: %s, saw: %s."
,
test
.
expectedOutput
,
output
)
t
.
Errorf
(
"expected: %s, saw: %s."
,
test
.
expectedOutput
,
output
)
}
}
...
...
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