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
6a20487b
Unverified
Commit
6a20487b
authored
Sep 15, 2016
by
Evgeny L
Committed by
Ilya Dmitrichenko
Sep 24, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a flag to allow to schedule workload to the master node
parent
798bbaa8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
8 deletions
+20
-8
types.go
pkg/kubeadm/api/types.go
+1
-0
init.go
pkg/kubeadm/cmd/init.go
+5
-1
manual.go
pkg/kubeadm/cmd/manual.go
+5
-1
apiclient.go
pkg/kubeadm/master/apiclient.go
+9
-6
No files found.
pkg/kubeadm/api/types.go
View file @
6a20487b
...
@@ -45,6 +45,7 @@ type InitFlags struct {
...
@@ -45,6 +45,7 @@ type InitFlags struct {
DNSDomain
string
DNSDomain
string
}
}
CloudProvider
string
CloudProvider
string
Schedulable
bool
}
}
const
(
const
(
...
...
pkg/kubeadm/cmd/init.go
View file @
6a20487b
...
@@ -77,6 +77,10 @@ func NewCmdInit(out io.Writer, s *kubeadmapi.KubeadmConfig) *cobra.Command {
...
@@ -77,6 +77,10 @@ func NewCmdInit(out io.Writer, s *kubeadmapi.KubeadmConfig) *cobra.Command {
&
s
.
InitFlags
.
CloudProvider
,
"cloud-provider"
,
""
,
&
s
.
InitFlags
.
CloudProvider
,
"cloud-provider"
,
""
,
`(optional) enable cloud proiver features (external load-balancers, storage, etc)`
,
`(optional) enable cloud proiver features (external load-balancers, storage, etc)`
,
)
)
cmd
.
PersistentFlags
()
.
BoolVar
(
&
s
.
InitFlags
.
Schedulable
,
"schedule-workload"
,
false
,
`(optional) allow to schedule workload to the node`
,
)
return
cmd
return
cmd
}
}
...
@@ -135,7 +139,7 @@ func RunInit(out io.Writer, cmd *cobra.Command, args []string, s *kubeadmapi.Kub
...
@@ -135,7 +139,7 @@ func RunInit(out io.Writer, cmd *cobra.Command, args []string, s *kubeadmapi.Kub
return
err
return
err
}
}
if
err
:=
kubemaster
.
UpdateMasterRoleLabelsAndTaints
(
client
);
err
!=
nil
{
if
err
:=
kubemaster
.
UpdateMasterRoleLabelsAndTaints
(
client
,
s
.
Schedulable
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubeadm/cmd/manual.go
View file @
6a20487b
...
@@ -129,6 +129,10 @@ func NewCmdManualBootstrapInitMaster(out io.Writer, s *kubeadmapi.KubeadmConfig)
...
@@ -129,6 +129,10 @@ func NewCmdManualBootstrapInitMaster(out io.Writer, s *kubeadmapi.KubeadmConfig)
&
s
.
InitFlags
.
Services
.
DNSDomain
,
"service-dns-domain"
,
"cluster.local"
,
&
s
.
InitFlags
.
Services
.
DNSDomain
,
"service-dns-domain"
,
"cluster.local"
,
`(optional) use alterantive domain name for services, e.g. "myorg.internal"`
,
`(optional) use alterantive domain name for services, e.g. "myorg.internal"`
,
)
)
cmd
.
PersistentFlags
()
.
BoolVar
(
&
s
.
InitFlags
.
Schedulable
,
"schedule-workload"
,
false
,
`(optional) allow to schedule workload to the node`
,
)
return
cmd
return
cmd
}
}
...
@@ -181,7 +185,7 @@ func RunManualBootstrapInitMaster(out io.Writer, cmd *cobra.Command, args []stri
...
@@ -181,7 +185,7 @@ func RunManualBootstrapInitMaster(out io.Writer, cmd *cobra.Command, args []stri
return
err
return
err
}
}
if
err
:=
kubemaster
.
UpdateMasterRoleLabelsAndTaints
(
client
);
err
!=
nil
{
if
err
:=
kubemaster
.
UpdateMasterRoleLabelsAndTaints
(
client
,
s
.
Schedulable
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubeadm/master/apiclient.go
View file @
6a20487b
...
@@ -159,21 +159,24 @@ func findMyself(client *clientset.Clientset) (*api.Node, error) {
...
@@ -159,21 +159,24 @@ func findMyself(client *clientset.Clientset) (*api.Node, error) {
return
node
,
nil
return
node
,
nil
}
}
func
attemptToUpdateMasterRoleLabelsAndTaints
(
client
*
clientset
.
Clientset
)
error
{
func
attemptToUpdateMasterRoleLabelsAndTaints
(
client
*
clientset
.
Clientset
,
schedulable
bool
)
error
{
n
,
err
:=
findMyself
(
client
)
n
,
err
:=
findMyself
(
client
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
n
.
ObjectMeta
.
Labels
[
"kubeadm.alpha.kubernetes.io/role"
]
=
"master"
n
.
ObjectMeta
.
Labels
[
"kubeadm.alpha.kubernetes.io/role"
]
=
"master"
taintsAnnotation
,
_
:=
json
.
Marshal
([]
api
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"master"
,
Effect
:
"NoSchedule"
}})
n
.
ObjectMeta
.
Annotations
[
api
.
TaintsAnnotationKey
]
=
string
(
taintsAnnotation
)
if
!
schedulable
{
taintsAnnotation
,
_
:=
json
.
Marshal
([]
api
.
Taint
{{
Key
:
"dedicated"
,
Value
:
"master"
,
Effect
:
"NoSchedule"
}})
n
.
ObjectMeta
.
Annotations
[
api
.
TaintsAnnotationKey
]
=
string
(
taintsAnnotation
)
}
if
_
,
err
:=
client
.
Nodes
()
.
Update
(
n
);
err
!=
nil
{
if
_
,
err
:=
client
.
Nodes
()
.
Update
(
n
);
err
!=
nil
{
if
apierrs
.
IsConflict
(
err
)
{
if
apierrs
.
IsConflict
(
err
)
{
fmt
.
Println
(
"<master/apiclient> temporarily unable to update master node metadata due to conflict (will retry)"
)
fmt
.
Println
(
"<master/apiclient> temporarily unable to update master node metadata due to conflict (will retry)"
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
time
.
Sleep
(
500
*
time
.
Millisecond
)
attemptToUpdateMasterRoleLabelsAndTaints
(
client
)
attemptToUpdateMasterRoleLabelsAndTaints
(
client
,
schedulable
)
}
else
{
}
else
{
return
err
return
err
}
}
...
@@ -182,8 +185,8 @@ func attemptToUpdateMasterRoleLabelsAndTaints(client *clientset.Clientset) error
...
@@ -182,8 +185,8 @@ func attemptToUpdateMasterRoleLabelsAndTaints(client *clientset.Clientset) error
return
nil
return
nil
}
}
func
UpdateMasterRoleLabelsAndTaints
(
client
*
clientset
.
Clientset
)
error
{
func
UpdateMasterRoleLabelsAndTaints
(
client
*
clientset
.
Clientset
,
schedulable
bool
)
error
{
err
:=
attemptToUpdateMasterRoleLabelsAndTaints
(
client
)
err
:=
attemptToUpdateMasterRoleLabelsAndTaints
(
client
,
schedulable
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"<master/apiclient> failed to update master node - %s"
,
err
)
return
fmt
.
Errorf
(
"<master/apiclient> failed to update master node - %s"
,
err
)
}
}
...
...
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