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
2ec19214
Commit
2ec19214
authored
Dec 20, 2023
by
Manuel Buil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for taint to be gone in the node before starting the netpol controller
Signed-off-by:
Manuel Buil
<
mbuil@suse.com
>
parent
5ecf175f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
netpol.go
pkg/agent/netpol/netpol.go
+27
-0
No files found.
pkg/agent/netpol/netpol.go
View file @
2ec19214
...
@@ -11,6 +11,11 @@ import (
...
@@ -11,6 +11,11 @@ import (
"runtime"
"runtime"
"strings"
"strings"
"sync"
"sync"
"time"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
cloudproviderapi
"k8s.io/cloud-provider/api"
"github.com/cloudnativelabs/kube-router/v2/pkg/version"
"github.com/cloudnativelabs/kube-router/v2/pkg/version"
...
@@ -55,6 +60,28 @@ func Run(ctx context.Context, nodeConfig *config.Node) error {
...
@@ -55,6 +60,28 @@ func Run(ctx context.Context, nodeConfig *config.Node) error {
return
err
return
err
}
}
// As kube-router netpol requires addresses to be available in the node object
// Wait until the node has ready addresses to avoid race conditions (max 1 minute).
// TODO: Replace with non-deprecated PollUntilContextTimeout when our and Kubernetes code migrate to it
if
err
:=
wait
.
PollImmediateWithContext
(
ctx
,
2
*
time
.
Second
,
60
*
time
.
Second
,
func
(
ctx
context
.
Context
)
(
bool
,
error
)
{
// Get the node object
node
,
err
:=
client
.
CoreV1
()
.
Nodes
()
.
Get
(
ctx
,
nodeConfig
.
AgentConfig
.
NodeName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
logrus
.
Errorf
(
"Error getting the node object: %v"
,
err
)
return
false
,
err
}
// Check for the uninitialized taint that should be removed by cloud-provider
// If there is no cloud-provider, the taint will not be there
for
_
,
taint
:=
range
node
.
Spec
.
Taints
{
if
taint
.
Key
==
cloudproviderapi
.
TaintExternalCloudProvider
{
return
false
,
nil
}
}
return
true
,
nil
});
err
!=
nil
{
return
err
}
krConfig
:=
options
.
NewKubeRouterConfig
()
krConfig
:=
options
.
NewKubeRouterConfig
()
var
serviceIPs
[]
string
var
serviceIPs
[]
string
for
_
,
elem
:=
range
nodeConfig
.
AgentConfig
.
ServiceCIDRs
{
for
_
,
elem
:=
range
nodeConfig
.
AgentConfig
.
ServiceCIDRs
{
...
...
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