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
1ce4ef82
Commit
1ce4ef82
authored
Nov 20, 2017
by
Kenneth Owens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds the statefulset.kubernetes.io/pod-name label allowing users to
attach a Service to an individual Pod.
parent
98fb71e8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
3 deletions
+21
-3
stateful_set_utils.go
pkg/controller/statefulset/stateful_set_utils.go
+8
-3
stateful_set_utils_test.go
pkg/controller/statefulset/stateful_set_utils_test.go
+10
-0
types.go
staging/src/k8s.io/api/apps/v1/types.go
+1
-0
types.go
staging/src/k8s.io/api/apps/v1beta1/types.go
+1
-0
types.go
staging/src/k8s.io/api/apps/v1beta2/types.go
+1
-0
No files found.
pkg/controller/statefulset/stateful_set_utils.go
View file @
1ce4ef82
...
...
@@ -112,7 +112,8 @@ func identityMatches(set *apps.StatefulSet, pod *v1.Pod) bool {
return
ordinal
>=
0
&&
set
.
Name
==
parent
&&
pod
.
Name
==
getPodName
(
set
,
ordinal
)
&&
pod
.
Namespace
==
set
.
Namespace
pod
.
Namespace
==
set
.
Namespace
&&
pod
.
Labels
[
apps
.
StatefulSetPodNameLabel
]
==
pod
.
Name
}
// storageMatches returns true if pod's Volumes cover the set of PersistentVolumeClaims
...
...
@@ -187,11 +188,15 @@ func initIdentity(set *apps.StatefulSet, pod *v1.Pod) {
pod
.
Spec
.
Subdomain
=
set
.
Spec
.
ServiceName
}
// updateIdentity updates pod's name, hostname, and subdomain to conform to set's name and headless service.
// updateIdentity updates pod's name, hostname, and subdomain, and StatefulSetPodNameLabel to conform to set's name
// and headless service.
func
updateIdentity
(
set
*
apps
.
StatefulSet
,
pod
*
v1
.
Pod
)
{
pod
.
Name
=
getPodName
(
set
,
getOrdinal
(
pod
))
pod
.
Namespace
=
set
.
Namespace
if
pod
.
Labels
==
nil
{
pod
.
Labels
=
make
(
map
[
string
]
string
)
}
pod
.
Labels
[
apps
.
StatefulSetPodNameLabel
]
=
pod
.
Name
}
// isRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady.
...
...
pkg/controller/statefulset/stateful_set_utils_test.go
View file @
1ce4ef82
...
...
@@ -78,6 +78,11 @@ func TestIdentityMatches(t *testing.T) {
if
identityMatches
(
set
,
pod
)
{
t
.
Error
(
"identity matches for a Pod with the wrong namespace"
)
}
pod
=
newStatefulSetPod
(
set
,
1
)
delete
(
pod
.
Labels
,
apps
.
StatefulSetPodNameLabel
)
if
identityMatches
(
set
,
pod
)
{
t
.
Error
(
"identity matches for a Pod with the wrong statefulSetPodNameLabel"
)
}
}
func
TestStorageMatches
(
t
*
testing
.
T
)
{
...
...
@@ -127,6 +132,11 @@ func TestUpdateIdentity(t *testing.T) {
if
!
identityMatches
(
set
,
pod
)
{
t
.
Error
(
"updateIdentity failed to update the Pods namespace"
)
}
delete
(
pod
.
Labels
,
apps
.
StatefulSetPodNameLabel
)
updateIdentity
(
set
,
pod
)
if
!
identityMatches
(
set
,
pod
)
{
t
.
Error
(
"updateIdentity failed to restore the statefulSetPodName label"
)
}
}
func
TestUpdateStorage
(
t
*
testing
.
T
)
{
...
...
staging/src/k8s.io/api/apps/v1/types.go
View file @
1ce4ef82
...
...
@@ -28,6 +28,7 @@ const (
StatefulSetRevisionLabel
=
ControllerRevisionHashLabelKey
DeprecatedRollbackTo
=
"deprecated.deployment.rollback.to"
DeprecatedTemplateGeneration
=
"deprecated.daemonset.template.generation"
StatefulSetPodNameLabel
=
"statefulset.kubernetes.io/pod-name"
)
// +genclient
...
...
staging/src/k8s.io/api/apps/v1beta1/types.go
View file @
1ce4ef82
...
...
@@ -26,6 +26,7 @@ import (
const
(
ControllerRevisionHashLabelKey
=
"controller-revision-hash"
StatefulSetRevisionLabel
=
ControllerRevisionHashLabelKey
StatefulSetPodNameLabel
=
"statefulset.kubernetes.io/pod-name"
)
// ScaleSpec describes the attributes of a scale subresource
...
...
staging/src/k8s.io/api/apps/v1beta2/types.go
View file @
1ce4ef82
...
...
@@ -28,6 +28,7 @@ const (
StatefulSetRevisionLabel
=
ControllerRevisionHashLabelKey
DeprecatedRollbackTo
=
"deprecated.deployment.rollback.to"
DeprecatedTemplateGeneration
=
"deprecated.daemonset.template.generation"
StatefulSetPodNameLabel
=
"statefulset.kubernetes.io/pod-name"
)
// ScaleSpec describes the attributes of a scale subresource
...
...
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