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
cef8315a
Commit
cef8315a
authored
Nov 01, 2016
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add constants for node role labels
Rather than sharing well-known strings, we should be declaring these in the API.
parent
a52ad987
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
apiclient.go
cmd/kubeadm/app/master/apiclient.go
+4
-2
well_known_labels.go
pkg/api/unversioned/well_known_labels.go
+37
-0
No files found.
cmd/kubeadm/app/master/apiclient.go
View file @
cef8315a
...
@@ -170,7 +170,7 @@ func attemptToUpdateMasterRoleLabelsAndTaints(client *clientset.Clientset, sched
...
@@ -170,7 +170,7 @@ func attemptToUpdateMasterRoleLabelsAndTaints(client *clientset.Clientset, sched
return
err
return
err
}
}
n
.
ObjectMeta
.
Labels
[
"kubeadm.alpha.kubernetes.io/role"
]
=
"master"
n
.
ObjectMeta
.
Labels
[
unversionedapi
.
NodeLabelKubeadmAlphaRole
]
=
unversionedapi
.
NodeLabelRoleMaster
if
!
schedulable
{
if
!
schedulable
{
taintsAnnotation
,
_
:=
json
.
Marshal
([]
api
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"master"
,
Effect
:
"NoSchedule"
}})
taintsAnnotation
,
_
:=
json
.
Marshal
([]
api
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"master"
,
Effect
:
"NoSchedule"
}})
...
@@ -224,7 +224,9 @@ func SetNodeAffinity(meta *api.ObjectMeta, expr ...api.NodeSelectorRequirement)
...
@@ -224,7 +224,9 @@ func SetNodeAffinity(meta *api.ObjectMeta, expr ...api.NodeSelectorRequirement)
// MasterNodeAffinity returns api.NodeSelectorRequirement to be used with SetNodeAffinity to set affinity to master node
// MasterNodeAffinity returns api.NodeSelectorRequirement to be used with SetNodeAffinity to set affinity to master node
func
MasterNodeAffinity
()
api
.
NodeSelectorRequirement
{
func
MasterNodeAffinity
()
api
.
NodeSelectorRequirement
{
return
api
.
NodeSelectorRequirement
{
return
api
.
NodeSelectorRequirement
{
Key
:
"kubeadm.alpha.kubernetes.io/role"
,
Operator
:
api
.
NodeSelectorOpIn
,
Values
:
[]
string
{
"master"
},
Key
:
unversionedapi
.
NodeLabelKubeadmAlphaRole
,
Operator
:
api
.
NodeSelectorOpIn
,
Values
:
[]
string
{
unversionedapi
.
NodeLabelRoleMaster
},
}
}
}
}
...
...
pkg/api/unversioned/well_known_labels.go
View file @
cef8315a
...
@@ -28,3 +28,40 @@ const (
...
@@ -28,3 +28,40 @@ const (
LabelOS
=
"beta.kubernetes.io/os"
LabelOS
=
"beta.kubernetes.io/os"
LabelArch
=
"beta.kubernetes.io/arch"
LabelArch
=
"beta.kubernetes.io/arch"
)
)
// Role labels are applied to Nodes to mark their purpose. In particular, we
// usually want to distinguish the master, so that we can isolate privileged
// pods and operations.
//
// Originally we relied on not registering the master, on the fact that the
// master was Unschedulable, and on static manifests for master components.
// But we now do register masters in many environments, are generally moving
// away from static manifests (for better manageability), and working towards
// deprecating the unschedulable field (replacing it with taints & tolerations
// instead).
//
// Even with tainting, a label remains the easiest way of making a positive
// selection, so that pods can schedule only to master nodes for example, and
// thus installations will likely define a label for their master nodes.
//
// So that we can recognize master nodes in consequent places though (such as
// kubectl get nodes), we encourage installations to use the well-known labels.
// We define NodeLabelRole, which is the preferred form, but we will also recognize
// other forms that are known to be in widespread use (NodeLabelKubeadmAlphaRole).
const
(
// NodeLabelRole is the preferred label applied to a Node as a hint that it has a particular purpose (defined by the value).
NodeLabelRole
=
"kubernetes.io/role"
// NodeLabelKubeadmAlphaRole is a label that kubeadm applies to a Node as a hint that it has a particular purpose.
// Use of NodeLabelRole is preferred.
NodeLabelKubeadmAlphaRole
=
"kubeadm.alpha.kubernetes.io/role"
// NodeLabelRoleMaster is the value of a NodeLabelRole or NodeLabelKubeadmAlphaRole label, indicating a master node.
// A master node typically runs kubernetes system components and will not typically run user workloads.
NodeLabelRoleMaster
=
"master"
// NodeLabelRoleNode is the value of a NodeLabelRole or NodeLabelKubeadmAlphaRole label, indicating a "normal" node,
// as opposed to a RoleMaster node.
NodeLabelRoleNode
=
"node"
)
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