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
6dfc9961
Unverified
Commit
6dfc9961
authored
May 16, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77423 from apelisse/rollout-restart-other-workloads
Implement rollout restart for statefulset and daemonset
parents
b2760430
145935d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
3 deletions
+56
-3
rollout_restart.go
pkg/kubectl/cmd/rollout/rollout_restart.go
+6
-3
objectrestarter.go
pkg/kubectl/polymorphichelpers/objectrestarter.go
+42
-0
apps.sh
test/cmd/apps.sh
+8
-0
No files found.
pkg/kubectl/cmd/rollout/rollout_restart.go
View file @
6dfc9961
...
...
@@ -54,11 +54,14 @@ var (
restartLong
=
templates
.
LongDesc
(
`
Restart a resource.
A deployment with the "RolloutStrategy" will be rolling
restarted.`
)
Resource will be rollout
restarted.`
)
restartExample
=
templates
.
Examples
(
`
# Restart a deployment
kubectl rollout restart deployment/nginx`
)
kubectl rollout restart deployment/nginx
# Restart a daemonset
kubectl rollout restart daemonset/abc`
)
)
// NewRolloutRestartOptions returns an initialized RestartOptions instance
...
...
@@ -73,7 +76,7 @@ func NewRolloutRestartOptions(streams genericclioptions.IOStreams) *RestartOptio
func
NewCmdRolloutRestart
(
f
cmdutil
.
Factory
,
streams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
o
:=
NewRolloutRestartOptions
(
streams
)
validArgs
:=
[]
string
{
"deployment"
}
validArgs
:=
[]
string
{
"deployment"
,
"daemonset"
,
"statefulset"
}
cmd
:=
&
cobra
.
Command
{
Use
:
"restart RESOURCE"
,
...
...
pkg/kubectl/polymorphichelpers/objectrestarter.go
View file @
6dfc9961
...
...
@@ -71,6 +71,48 @@ func defaultObjectRestarter(obj runtime.Object) ([]byte, error) {
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
appsv1beta1
.
SchemeGroupVersion
),
obj
)
case
*
extensionsv1beta1
.
DaemonSet
:
if
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
extensionsv1beta1
.
SchemeGroupVersion
),
obj
)
case
*
appsv1
.
DaemonSet
:
if
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
appsv1
.
SchemeGroupVersion
),
obj
)
case
*
appsv1beta2
.
DaemonSet
:
if
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
appsv1beta2
.
SchemeGroupVersion
),
obj
)
case
*
appsv1
.
StatefulSet
:
if
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
appsv1
.
SchemeGroupVersion
),
obj
)
case
*
appsv1beta1
.
StatefulSet
:
if
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
appsv1beta1
.
SchemeGroupVersion
),
obj
)
case
*
appsv1beta2
.
StatefulSet
:
if
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
==
nil
{
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
=
make
(
map
[
string
]
string
)
}
obj
.
Spec
.
Template
.
ObjectMeta
.
Annotations
[
"kubectl.kubernetes.io/restartedAt"
]
=
time
.
Now
()
.
Format
(
time
.
RFC3339
)
return
runtime
.
Encode
(
scheme
.
Codecs
.
LegacyCodec
(
appsv1beta2
.
SchemeGroupVersion
),
obj
)
default
:
return
nil
,
fmt
.
Errorf
(
"restarting is not supported"
)
}
...
...
test/cmd/apps.sh
View file @
6dfc9961
...
...
@@ -43,6 +43,10 @@ run_daemonset_tests() {
kubectl
set
resources daemonsets/bind
"
${
kube_flags
[@]
:?
}
"
--limits
=
cpu
=
200m,memory
=
512Mi
kube::test::get_object_assert
'daemonsets bind'
"{{
${
template_generation_field
:?
}
}}"
'4'
# Rollout restart should change generation
kubectl rollout restart daemonset/bind
"
${
kube_flags
[@]
}
"
kube::test::get_object_assert
'daemonsets bind'
"{{
${
template_generation_field
}
}}"
'5'
# Clean up
kubectl delete
-f
hack/testdata/rollingupdate-daemonset.yaml
"
${
kube_flags
[@]
:?
}
"
...
...
@@ -488,6 +492,10 @@ run_stateful_set_tests() {
# TODO: test robust scaling in an e2e.
wait-for-pods-with-label
"app=nginx-statefulset"
"nginx-0"
# Rollout restart should change generation
kubectl rollout restart statefulset nginx
"
${
kube_flags
[@]
}
"
kube::test::get_object_assert
'statefulset nginx'
"{{
$statefulset_observed_generation
}}"
'3'
### Clean up
kubectl delete
-f
hack/testdata/rollingupdate-statefulset.yaml
"
${
kube_flags
[@]
:?
}
"
# Post-condition: no pods from statefulset controller
...
...
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