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
73322af8
Commit
73322af8
authored
Apr 23, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5842 from simon3z/rc-annotation
Replica Controller Name Annotation in Pods
parents
e8b28c59
253ce4b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
replication_controller.go
pkg/controller/replication_controller.go
+16
-0
replication_controller_test.go
pkg/controller/replication_controller_test.go
+4
-0
No files found.
pkg/controller/replication_controller.go
View file @
73322af8
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
controller
package
controller
import
(
import
(
"encoding/json"
"fmt"
"fmt"
"sort"
"sort"
"sync"
"sync"
...
@@ -62,6 +63,7 @@ type RealPodControl struct {
...
@@ -62,6 +63,7 @@ type RealPodControl struct {
// Time period of main replication controller sync loop
// Time period of main replication controller sync loop
const
DefaultSyncPeriod
=
5
*
time
.
Second
const
DefaultSyncPeriod
=
5
*
time
.
Second
const
CreatedByAnnotation
=
"kubernetes.io/created-by"
func
(
r
RealPodControl
)
createReplica
(
namespace
string
,
controller
api
.
ReplicationController
)
{
func
(
r
RealPodControl
)
createReplica
(
namespace
string
,
controller
api
.
ReplicationController
)
{
desiredLabels
:=
make
(
labels
.
Set
)
desiredLabels
:=
make
(
labels
.
Set
)
...
@@ -73,6 +75,20 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
...
@@ -73,6 +75,20 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
desiredAnnotations
[
k
]
=
v
desiredAnnotations
[
k
]
=
v
}
}
createdByRef
,
err
:=
api
.
GetReference
(
&
controller
)
if
err
!=
nil
{
util
.
HandleError
(
fmt
.
Errorf
(
"unable to get controller reference: %v"
,
err
))
return
}
createdByRefJson
,
err
:=
json
.
Marshal
(
createdByRef
)
if
err
!=
nil
{
util
.
HandleError
(
fmt
.
Errorf
(
"unable to serialize controller reference: %v"
,
err
))
return
}
desiredAnnotations
[
CreatedByAnnotation
]
=
string
(
createdByRefJson
)
// use the dash (if the name isn't too long) to make the pod name a bit prettier
// use the dash (if the name isn't too long) to make the pod name a bit prettier
prefix
:=
fmt
.
Sprintf
(
"%s-"
,
controller
.
Name
)
prefix
:=
fmt
.
Sprintf
(
"%s-"
,
controller
.
Name
)
if
ok
,
_
:=
validation
.
ValidatePodName
(
prefix
,
true
);
!
ok
{
if
ok
,
_
:=
validation
.
ValidatePodName
(
prefix
,
true
);
!
ok
{
...
...
pkg/controller/replication_controller_test.go
View file @
73322af8
...
@@ -43,6 +43,10 @@ type FakePodControl struct {
...
@@ -43,6 +43,10 @@ type FakePodControl struct {
lock
sync
.
Mutex
lock
sync
.
Mutex
}
}
func
init
()
{
api
.
ForTesting_ReferencesAllowBlankSelfLinks
=
true
}
func
(
f
*
FakePodControl
)
createReplica
(
namespace
string
,
spec
api
.
ReplicationController
)
{
func
(
f
*
FakePodControl
)
createReplica
(
namespace
string
,
spec
api
.
ReplicationController
)
{
f
.
lock
.
Lock
()
f
.
lock
.
Lock
()
defer
f
.
lock
.
Unlock
()
defer
f
.
lock
.
Unlock
()
...
...
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