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
08d8843a
Commit
08d8843a
authored
Jan 15, 2016
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubectl: Support exposing deployments
parent
ab93bbb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
test-cmd.sh
hack/test-cmd.sh
+13
-0
factory.go
pkg/kubectl/cmd/util/factory.go
+5
-1
No files found.
hack/test-cmd.sh
View file @
08d8843a
...
@@ -946,6 +946,19 @@ __EOF__
...
@@ -946,6 +946,19 @@ __EOF__
# TODO: Remove once deployment reaping is implemented
# TODO: Remove once deployment reaping is implemented
kubectl delete rc
--all
"
${
kube_flags
[@]
}
"
kubectl delete rc
--all
"
${
kube_flags
[@]
}
"
### Expose a deployment as a service
kubectl create
-f
examples/extensions/deployment.yaml
"
${
kube_flags
[@]
}
"
# Pre-condition: 3 replicas
kube::test::get_object_assert
'deployment nginx-deployment'
"{{
$deployment_replicas
}}"
'3'
# Command
kubectl expose deployment/nginx-deployment
# Post-condition: service exists and exposes deployment port (80)
kube::test::get_object_assert
'service nginx-deployment'
"{{
$port_field
}}"
'80'
# Clean-up
kubectl delete deployment/nginx-deployment service/nginx-deployment
"
${
kube_flags
[@]
}
"
# TODO: Remove once deployment reaping is implemented
kubectl delete rc
--all
"
${
kube_flags
[@]
}
"
### Expose replication controller as service
### Expose replication controller as service
kubectl create
-f
examples/guestbook/frontend-controller.yaml
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/frontend-controller.yaml
"
${
kube_flags
[@]
}
"
# Pre-condition: 3 replicas
# Pre-condition: 3 replicas
...
...
pkg/kubectl/cmd/util/factory.go
View file @
08d8843a
...
@@ -228,6 +228,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
...
@@ -228,6 +228,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
return
""
,
fmt
.
Errorf
(
"the service has no pod selector set"
)
return
""
,
fmt
.
Errorf
(
"the service has no pod selector set"
)
}
}
return
kubectl
.
MakeLabels
(
t
.
Spec
.
Selector
),
nil
return
kubectl
.
MakeLabels
(
t
.
Spec
.
Selector
),
nil
case
*
extensions
.
Deployment
:
return
kubectl
.
MakeLabels
(
t
.
Spec
.
Selector
),
nil
default
:
default
:
gvk
,
err
:=
api
.
Scheme
.
ObjectKind
(
object
)
gvk
,
err
:=
api
.
Scheme
.
ObjectKind
(
object
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -245,6 +247,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
...
@@ -245,6 +247,8 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
return
getPorts
(
t
.
Spec
),
nil
return
getPorts
(
t
.
Spec
),
nil
case
*
api
.
Service
:
case
*
api
.
Service
:
return
getServicePorts
(
t
.
Spec
),
nil
return
getServicePorts
(
t
.
Spec
),
nil
case
*
extensions
.
Deployment
:
return
getPorts
(
t
.
Spec
.
Template
.
Spec
),
nil
default
:
default
:
gvk
,
err
:=
api
.
Scheme
.
ObjectKind
(
object
)
gvk
,
err
:=
api
.
Scheme
.
ObjectKind
(
object
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -330,7 +334,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
...
@@ -330,7 +334,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
},
},
CanBeExposed
:
func
(
kind
unversioned
.
GroupKind
)
error
{
CanBeExposed
:
func
(
kind
unversioned
.
GroupKind
)
error
{
switch
kind
{
switch
kind
{
case
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"Service"
),
api
.
Kind
(
"Pod"
)
:
case
api
.
Kind
(
"ReplicationController"
),
api
.
Kind
(
"Service"
),
api
.
Kind
(
"Pod"
)
,
extensions
.
Kind
(
"Deployment"
)
:
// nothing to do here
// nothing to do here
default
:
default
:
return
fmt
.
Errorf
(
"cannot expose a %s"
,
kind
)
return
fmt
.
Errorf
(
"cannot expose a %s"
,
kind
)
...
...
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