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
242910e5
Commit
242910e5
authored
Jul 16, 2015
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubectl expose should extract ports from service
parent
d397d884
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
test-cmd.sh
hack/test-cmd.sh
+5
-1
factory.go
pkg/kubectl/cmd/util/factory.go
+11
-2
No files found.
hack/test-cmd.sh
View file @
242910e5
...
...
@@ -634,9 +634,13 @@ __EOF__
kubectl expose rc frontend
--port
=
80
--name
=
frontend-4
--generator
=
service/v1
"
${
kube_flags
[@]
}
"
# Post-condition: service exists and the port is named default.
kube::test::get_object_assert
'service frontend-4'
"{{
$port_name
}} {{
$port_field
}}"
'default 80'
# Verify that expose service works without specifying a port.
kubectl expose service frontend
--name
=
frontend-5
"
${
kube_flags
[@]
}
"
# Post-condition: service exists with the same port as the original service.
kube::test::get_object_assert
'service frontend-5'
"{{
$port_field
}}"
'80'
# Cleanup services
kubectl delete pod valid-pod
"
${
kube_flags
[@]
}
"
kubectl delete service frontend
{
,-2,-3,-4
}
"
${
kube_flags
[@]
}
"
kubectl delete service frontend
{
,-2,-3,-4
,-5
}
"
${
kube_flags
[@]
}
"
### Perform a rolling update with --image
# Command
...
...
pkg/kubectl/cmd/util/factory.go
View file @
242910e5
...
...
@@ -177,9 +177,9 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
return
getPorts
(
t
.
Spec
.
Template
.
Spec
),
nil
case
*
api
.
Pod
:
return
getPorts
(
t
.
Spec
),
nil
case
*
api
.
Service
:
return
getServicePorts
(
t
.
Spec
),
nil
default
:
// TODO: support extracting ports from service:
// https://github.com/GoogleCloudPlatform/kubernetes/issues/11392
_
,
kind
,
err
:=
api
.
Scheme
.
ObjectVersionAndKind
(
object
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -263,6 +263,15 @@ func getPorts(spec api.PodSpec) []string {
return
result
}
// Extracts the ports exposed by a service from the given service spec.
func
getServicePorts
(
spec
api
.
ServiceSpec
)
[]
string
{
result
:=
[]
string
{}
for
_
,
servicePort
:=
range
spec
.
Ports
{
result
=
append
(
result
,
strconv
.
Itoa
(
servicePort
.
Port
))
}
return
result
}
type
clientSwaggerSchema
struct
{
c
*
client
.
Client
t
runtime
.
ObjectTyper
...
...
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