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
3043ae91
Commit
3043ae91
authored
Feb 17, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4492 from jlowdermilk/e2e
Cleanup resources after services/guestbook e2e tests.
parents
47622092
8ad671b0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
25 deletions
+51
-25
util.sh
cluster/gce/util.sh
+1
-1
kubectl.md
docs/kubectl.md
+11
-3
guestbook.sh
hack/e2e-suite/guestbook.sh
+3
-4
services.sh
hack/e2e-suite/services.sh
+1
-2
stop.go
pkg/kubectl/cmd/stop.go
+35
-15
No files found.
cluster/gce/util.sh
View file @
3043ae91
...
@@ -571,7 +571,7 @@ function kube-up {
...
@@ -571,7 +571,7 @@ function kube-up {
local
kubectl
=
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
local
kubectl
=
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
local
context
=
"
${
PROJECT
}
_
${
INSTANCE_PREFIX
}
"
local
context
=
"
${
PROJECT
}
_
${
INSTANCE_PREFIX
}
"
local
user
=
"
${
INSTANCE_PREFIX
}
-admin"
local
user
=
"
${
context
}
-admin"
local
config_dir
=
"
${
HOME
}
/.kube/
${
context
}
"
local
config_dir
=
"
${
HOME
}
/.kube/
${
context
}
"
# TODO: generate ADMIN (and KUBELET) tokens and put those in the master's
# TODO: generate ADMIN (and KUBELET) tokens and put those in the master's
...
...
docs/kubectl.md
View file @
3043ae91
...
@@ -416,7 +416,7 @@ Additional help topics:
...
@@ -416,7 +416,7 @@ Additional help topics:
kubectl rollingupdate Perform a rolling update of the given ReplicationController.
kubectl rollingupdate Perform a rolling update of the given ReplicationController.
kubectl resize Set a new size for a Replication Controller.
kubectl resize Set a new size for a Replication Controller.
kubectl run-container Run a particular image on the cluster.
kubectl run-container Run a particular image on the cluster.
kubectl stop Gracefully shut down a resource.
kubectl stop Gracefully shut down a resource
by id or filename
.
kubectl expose Take a replicated application and expose it as Kubernetes Service
kubectl expose Take a replicated application and expose it as Kubernetes Service
kubectl label Update the labels on a resource
kubectl label Update the labels on a resource
...
@@ -986,7 +986,7 @@ Global Flags:
...
@@ -986,7 +986,7 @@ Global Flags:
```
```
#### stop
#### stop
Gracefully shut down a resource.
Gracefully shut down a resource
by id or filename
.
Attempts to shut down and delete a resource that supports graceful termination.
Attempts to shut down and delete a resource that supports graceful termination.
If the resource is resizable it will be resized to 0 before deletion.
If the resource is resizable it will be resized to 0 before deletion.
...
@@ -996,10 +996,18 @@ Examples:
...
@@ -996,10 +996,18 @@ Examples:
// Shut down foo.
// Shut down foo.
$ kubectl stop replicationcontroller foo
$ kubectl stop replicationcontroller foo
// Shut down the service defined in service.json
$ kubectl stop -f service.json
// Shut down all resources in the path/to/resources directory
$ kubectl stop -f path/to/resources
Usage:
Usage:
```
```
kubectl stop
<resource> <id>
[flags]
kubectl stop
(<resource> <id>|-f filename)
[flags]
Flags:
-f, --filename=[]: Filename, directory, or URL to file of resource(s) to be stopped
Global Flags:
Global Flags:
--alsologtostderr=false: log to standard error as well as files
--alsologtostderr=false: log to standard error as well as files
...
...
hack/e2e-suite/guestbook.sh
View file @
3043ae91
...
@@ -37,8 +37,9 @@ prepare-e2e
...
@@ -37,8 +37,9 @@ prepare-e2e
GUESTBOOK
=
"
${
KUBE_ROOT
}
/examples/guestbook"
GUESTBOOK
=
"
${
KUBE_ROOT
}
/examples/guestbook"
echo
"WARNING: this test is a no op that only attempts to launch guestbook resources."
# Launch the guestbook example
# Launch the guestbook example
${
KUBECTL
}
create
-f
"
${
GUESTBOOK
}
"
${
KUBECTL
}
create
-f
"
${
GUESTBOOK
}
"
sleep
15
sleep
15
...
@@ -48,9 +49,7 @@ echo "Pods running: ${POD_LIST_1}"
...
@@ -48,9 +49,7 @@ echo "Pods running: ${POD_LIST_1}"
# TODO make this an actual test. Open up a firewall and use curl to post and
# TODO make this an actual test. Open up a firewall and use curl to post and
# read a message via the frontend
# read a message via the frontend
${
KUBECTL
}
stop rc redis-slave-controller
${
KUBECTL
}
stop
-f
"
${
GUESTBOOK
}
"
${
KUBECTL
}
delete services redis-master
${
KUBECTL
}
delete pods redis-master
POD_LIST_2
=
$(${
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
)
POD_LIST_2
=
$(${
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
)
echo
"Pods running after shutdown:
${
POD_LIST_2
}
"
echo
"Pods running after shutdown:
${
POD_LIST_2
}
"
...
...
hack/e2e-suite/services.sh
View file @
3043ae91
...
@@ -59,7 +59,6 @@ function join() {
...
@@ -59,7 +59,6 @@ function join() {
svcs_to_clean
=()
svcs_to_clean
=()
function
do_teardown
()
{
function
do_teardown
()
{
local
svc
local
svc
return
for
svc
in
"
${
svcs_to_clean
[@]
:+
${
svcs_to_clean
[@]
}}
"
;
do
for
svc
in
"
${
svcs_to_clean
[@]
:+
${
svcs_to_clean
[@]
}}
"
;
do
stop_service
"
${
svc
}
"
stop_service
"
${
svc
}
"
done
done
...
@@ -284,7 +283,7 @@ function verify_from_container() {
...
@@ -284,7 +283,7 @@ function verify_from_container() {
fi
fi
}
}
trap
"do_teardown"
EXIT
trap
do_teardown
EXIT
# Get node IP addresses and pick one as our test point.
# Get node IP addresses and pick one as our test point.
detect-minions
detect-minions
...
...
pkg/kubectl/cmd/stop.go
View file @
3043ae91
...
@@ -20,15 +20,19 @@ import (
...
@@ -20,15 +20,19 @@ import (
"fmt"
"fmt"
"io"
"io"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
func
(
f
*
Factory
)
NewCmdStop
(
out
io
.
Writer
)
*
cobra
.
Command
{
func
(
f
*
Factory
)
NewCmdStop
(
out
io
.
Writer
)
*
cobra
.
Command
{
flags
:=
&
struct
{
Filenames
util
.
StringList
}{}
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"stop
<resource> <id>
"
,
Use
:
"stop
(<resource> <id>|-f filename)
"
,
Short
:
"Gracefully shut down a resource."
,
Short
:
"Gracefully shut down a resource
by id or filename
."
,
Long
:
`Gracefully shut down a resource.
Long
:
`Gracefully shut down a resource
by id or filename
.
Attempts to shut down and delete a resource that supports graceful termination.
Attempts to shut down and delete a resource that supports graceful termination.
If the resource is resizable it will be resized to 0 before deletion.
If the resource is resizable it will be resized to 0 before deletion.
...
@@ -36,22 +40,38 @@ If the resource is resizable it will be resized to 0 before deletion.
...
@@ -36,22 +40,38 @@ If the resource is resizable it will be resized to 0 before deletion.
Examples:
Examples:
// Shut down foo.
// Shut down foo.
$ kubectl stop replicationcontroller foo`
,
$ kubectl stop replicationcontroller foo
// Shut down the service defined in service.json
$ kubectl stop -f service.json
// Shut down all resources in the path/to/resources directory
$ kubectl stop -f path/to/resources`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
len
(
args
)
!=
2
{
usageError
(
cmd
,
"<resource> <id>"
)
}
cmdNamespace
,
err
:=
f
.
DefaultNamespace
(
cmd
)
cmdNamespace
,
err
:=
f
.
DefaultNamespace
(
cmd
)
mapper
,
_
:=
f
.
Object
(
cmd
)
mapping
,
namespace
,
name
:=
util
.
ResourceFromArgs
(
cmd
,
args
,
mapper
,
cmdNamespace
)
reaper
,
err
:=
f
.
Reaper
(
cmd
,
mapping
)
checkErr
(
err
)
checkErr
(
err
)
mapper
,
typer
:=
f
.
Object
(
cmd
)
r
:=
resource
.
NewBuilder
(
mapper
,
typer
,
f
.
ClientMapperForCommand
(
cmd
))
.
ContinueOnError
()
.
NamespaceParam
(
cmdNamespace
)
.
RequireNamespace
()
.
ResourceTypeOrNameArgs
(
false
,
args
...
)
.
FilenameParam
(
flags
.
Filenames
...
)
.
Flatten
()
.
Do
()
checkErr
(
r
.
Err
())
s
,
err
:=
reaper
.
Stop
(
namespace
,
name
)
r
.
Visit
(
func
(
info
*
resource
.
Info
)
error
{
checkErr
(
err
)
reaper
,
err
:=
f
.
Reaper
(
cmd
,
info
.
Mapping
)
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
s
)
checkErr
(
err
)
s
,
err
:=
reaper
.
Stop
(
info
.
Namespace
,
info
.
Name
)
if
err
!=
nil
{
return
err
}
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
s
)
return
nil
})
},
},
}
}
cmd
.
Flags
()
.
VarP
(
&
flags
.
Filenames
,
"filename"
,
"f"
,
"Filename, directory, or URL to file of resource(s) to be stopped"
)
return
cmd
return
cmd
}
}
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