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
37f97b33
Commit
37f97b33
authored
Apr 29, 2024
by
Brad Davidson
Committed by
Brad Davidson
May 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for svclb pod PriorityClassName
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
b4536304
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
cloudprovider.go
pkg/cloudprovider/cloudprovider.go
+11
-9
servicelb.go
pkg/cloudprovider/servicelb.go
+17
-2
deps.go
pkg/daemons/control/deps/deps.go
+6
-5
No files found.
pkg/cloudprovider/cloudprovider.go
View file @
37f97b33
...
@@ -28,11 +28,12 @@ import (
...
@@ -28,11 +28,12 @@ import (
// Config describes externally-configurable cloud provider configuration.
// Config describes externally-configurable cloud provider configuration.
// This is normally unmarshalled from a JSON config file.
// This is normally unmarshalled from a JSON config file.
type
Config
struct
{
type
Config
struct
{
LBEnabled
bool
`json:"lbEnabled"`
LBDefaultPriorityClassName
string
`json:"lbDefaultPriorityClassName"`
LBImage
string
`json:"lbImage"`
LBEnabled
bool
`json:"lbEnabled"`
LBNamespace
string
`json:"lbNamespace"`
LBImage
string
`json:"lbImage"`
NodeEnabled
bool
`json:"nodeEnabled"`
LBNamespace
string
`json:"lbNamespace"`
Rootless
bool
`json:"rootless"`
NodeEnabled
bool
`json:"nodeEnabled"`
Rootless
bool
`json:"rootless"`
}
}
type
k3s
struct
{
type
k3s
struct
{
...
@@ -56,10 +57,11 @@ func init() {
...
@@ -56,10 +57,11 @@ func init() {
var
err
error
var
err
error
k
:=
k3s
{
k
:=
k3s
{
Config
:
Config
{
Config
:
Config
{
LBEnabled
:
true
,
LBDefaultPriorityClassName
:
DefaultLBPriorityClassName
,
LBImage
:
DefaultLBImage
,
LBEnabled
:
true
,
LBNamespace
:
DefaultLBNS
,
LBImage
:
DefaultLBImage
,
NodeEnabled
:
true
,
LBNamespace
:
DefaultLBNS
,
NodeEnabled
:
true
,
},
},
}
}
...
...
pkg/cloudprovider/servicelb.go
View file @
37f97b33
...
@@ -41,12 +41,14 @@ var (
...
@@ -41,12 +41,14 @@ var (
daemonsetNodeLabel
=
"svccontroller."
+
version
.
Program
+
".cattle.io/enablelb"
daemonsetNodeLabel
=
"svccontroller."
+
version
.
Program
+
".cattle.io/enablelb"
daemonsetNodePoolLabel
=
"svccontroller."
+
version
.
Program
+
".cattle.io/lbpool"
daemonsetNodePoolLabel
=
"svccontroller."
+
version
.
Program
+
".cattle.io/lbpool"
nodeSelectorLabel
=
"svccontroller."
+
version
.
Program
+
".cattle.io/nodeselector"
nodeSelectorLabel
=
"svccontroller."
+
version
.
Program
+
".cattle.io/nodeselector"
priorityAnnotation
=
"svccontroller."
+
version
.
Program
+
".cattle.io/priorityclassname"
controllerName
=
ccmapp
.
DefaultInitFuncConstructors
[
"service"
]
.
InitContext
.
ClientName
controllerName
=
ccmapp
.
DefaultInitFuncConstructors
[
"service"
]
.
InitContext
.
ClientName
)
)
const
(
const
(
Ready
=
condition
.
Cond
(
"Ready"
)
Ready
=
condition
.
Cond
(
"Ready"
)
DefaultLBNS
=
meta
.
NamespaceSystem
DefaultLBNS
=
meta
.
NamespaceSystem
DefaultLBPriorityClassName
=
"system-node-critical"
)
)
var
(
var
(
...
@@ -428,6 +430,7 @@ func (k *k3s) deleteDaemonSet(ctx context.Context, svc *core.Service) error {
...
@@ -428,6 +430,7 @@ func (k *k3s) deleteDaemonSet(ctx context.Context, svc *core.Service) error {
func
(
k
*
k3s
)
newDaemonSet
(
svc
*
core
.
Service
)
(
*
apps
.
DaemonSet
,
error
)
{
func
(
k
*
k3s
)
newDaemonSet
(
svc
*
core
.
Service
)
(
*
apps
.
DaemonSet
,
error
)
{
name
:=
generateName
(
svc
)
name
:=
generateName
(
svc
)
oneInt
:=
intstr
.
FromInt
(
1
)
oneInt
:=
intstr
.
FromInt
(
1
)
priorityClassName
:=
k
.
getPriorityClassName
(
svc
)
localTraffic
:=
servicehelper
.
RequestsOnlyLocalTraffic
(
svc
)
localTraffic
:=
servicehelper
.
RequestsOnlyLocalTraffic
(
svc
)
sourceRangesSet
,
err
:=
servicehelper
.
GetLoadBalancerSourceRanges
(
svc
)
sourceRangesSet
,
err
:=
servicehelper
.
GetLoadBalancerSourceRanges
(
svc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -472,6 +475,7 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
...
@@ -472,6 +475,7 @@ func (k *k3s) newDaemonSet(svc *core.Service) (*apps.DaemonSet, error) {
},
},
},
},
Spec
:
core
.
PodSpec
{
Spec
:
core
.
PodSpec
{
PriorityClassName
:
priorityClassName
,
ServiceAccountName
:
"svclb"
,
ServiceAccountName
:
"svclb"
,
AutomountServiceAccountToken
:
utilsptr
.
To
(
false
),
AutomountServiceAccountToken
:
utilsptr
.
To
(
false
),
SecurityContext
:
&
core
.
PodSecurityContext
{
SecurityContext
:
&
core
.
PodSecurityContext
{
...
@@ -682,6 +686,17 @@ func (k *k3s) removeFinalizer(ctx context.Context, svc *core.Service) (*core.Ser
...
@@ -682,6 +686,17 @@ func (k *k3s) removeFinalizer(ctx context.Context, svc *core.Service) (*core.Ser
return
svc
,
nil
return
svc
,
nil
}
}
// getPriorityClassName returns the value of the priority class name annotation on the service,
// or the system default priority class name.
func
(
k
*
k3s
)
getPriorityClassName
(
svc
*
core
.
Service
)
string
{
if
svc
!=
nil
{
if
v
,
ok
:=
svc
.
Annotations
[
priorityAnnotation
];
ok
{
return
v
}
}
return
k
.
LBDefaultPriorityClassName
}
// generateName generates a distinct name for the DaemonSet based on the service name and UID
// generateName generates a distinct name for the DaemonSet based on the service name and UID
func
generateName
(
svc
*
core
.
Service
)
string
{
func
generateName
(
svc
*
core
.
Service
)
string
{
return
fmt
.
Sprintf
(
"svclb-%s-%s"
,
svc
.
Name
,
svc
.
UID
[
:
8
])
return
fmt
.
Sprintf
(
"svclb-%s-%s"
,
svc
.
Name
,
svc
.
UID
[
:
8
])
...
...
pkg/daemons/control/deps/deps.go
View file @
37f97b33
...
@@ -829,11 +829,12 @@ func genEgressSelectorConfig(controlConfig *config.Control) error {
...
@@ -829,11 +829,12 @@ func genEgressSelectorConfig(controlConfig *config.Control) error {
func
genCloudConfig
(
controlConfig
*
config
.
Control
)
error
{
func
genCloudConfig
(
controlConfig
*
config
.
Control
)
error
{
cloudConfig
:=
cloudprovider
.
Config
{
cloudConfig
:=
cloudprovider
.
Config
{
LBEnabled
:
!
controlConfig
.
DisableServiceLB
,
LBDefaultPriorityClassName
:
cloudprovider
.
DefaultLBPriorityClassName
,
LBNamespace
:
controlConfig
.
ServiceLBNamespace
,
LBEnabled
:
!
controlConfig
.
DisableServiceLB
,
LBImage
:
cloudprovider
.
DefaultLBImage
,
LBNamespace
:
controlConfig
.
ServiceLBNamespace
,
Rootless
:
controlConfig
.
Rootless
,
LBImage
:
cloudprovider
.
DefaultLBImage
,
NodeEnabled
:
!
controlConfig
.
DisableCCM
,
Rootless
:
controlConfig
.
Rootless
,
NodeEnabled
:
!
controlConfig
.
DisableCCM
,
}
}
if
controlConfig
.
SystemDefaultRegistry
!=
""
{
if
controlConfig
.
SystemDefaultRegistry
!=
""
{
cloudConfig
.
LBImage
=
controlConfig
.
SystemDefaultRegistry
+
"/"
+
cloudConfig
.
LBImage
cloudConfig
.
LBImage
=
controlConfig
.
SystemDefaultRegistry
+
"/"
+
cloudConfig
.
LBImage
...
...
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