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
18bc98f6
Unverified
Commit
18bc98f6
authored
Jul 19, 2021
by
Luther Monson
Committed by
GitHub
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding startup hooks args to access to Disables and Skips (#3674)
Signed-off-by:
Luther Monson
<
luther.monson@gmail.com
>
parent
bba49ea4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
server.go
pkg/cli/cmds/server.go
+11
-1
server.go
pkg/server/server.go
+10
-3
types.go
pkg/server/types.go
+2
-1
No files found.
pkg/cli/cmds/server.go
View file @
18bc98f6
...
@@ -13,6 +13,16 @@ const (
...
@@ -13,6 +13,16 @@ const (
defaultSnapshotIntervalHours
=
12
defaultSnapshotIntervalHours
=
12
)
)
type
StartupHookArgs
struct
{
Wg
*
sync
.
WaitGroup
APIServerReady
<-
chan
struct
{}
KubeConfigAdmin
string
Skips
map
[
string
]
bool
Disables
map
[
string
]
bool
}
type
StartupHook
func
(
context
.
Context
,
StartupHookArgs
)
error
type
Server
struct
{
type
Server
struct
{
ClusterCIDR
cli
.
StringSlice
ClusterCIDR
cli
.
StringSlice
AgentToken
string
AgentToken
string
...
@@ -64,7 +74,7 @@ type Server struct {
...
@@ -64,7 +74,7 @@ type Server struct {
ClusterResetRestorePath
string
ClusterResetRestorePath
string
EncryptSecrets
bool
EncryptSecrets
bool
SystemDefaultRegistry
string
SystemDefaultRegistry
string
StartupHooks
[]
func
(
context
.
Context
,
*
sync
.
WaitGroup
,
<-
chan
struct
{},
string
)
error
StartupHooks
[]
StartupHook
EtcdSnapshotName
string
EtcdSnapshotName
string
EtcdDisableSnapshots
bool
EtcdDisableSnapshots
bool
EtcdExposeMetrics
bool
EtcdExposeMetrics
bool
...
...
pkg/server/server.go
View file @
18bc98f6
...
@@ -13,11 +13,10 @@ import (
...
@@ -13,11 +13,10 @@ import (
"sync"
"sync"
"time"
"time"
corev1
"k8s.io/api/core/v1"
"github.com/k3s-io/helm-controller/pkg/helm"
"github.com/k3s-io/helm-controller/pkg/helm"
"github.com/pkg/errors"
"github.com/pkg/errors"
"github.com/rancher/k3s/pkg/apiaddresses"
"github.com/rancher/k3s/pkg/apiaddresses"
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/control"
"github.com/rancher/k3s/pkg/daemons/control"
...
@@ -34,6 +33,7 @@ import (
...
@@ -34,6 +33,7 @@ import (
"github.com/rancher/wrangler/pkg/leader"
"github.com/rancher/wrangler/pkg/leader"
"github.com/rancher/wrangler/pkg/resolvehome"
"github.com/rancher/wrangler/pkg/resolvehome"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
corev1
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/net"
)
)
...
@@ -72,8 +72,15 @@ func StartServer(ctx context.Context, config *Config) error {
...
@@ -72,8 +72,15 @@ func StartServer(ctx context.Context, config *Config) error {
config
.
StartupHooksWg
=
&
sync
.
WaitGroup
{}
config
.
StartupHooksWg
=
&
sync
.
WaitGroup
{}
config
.
StartupHooksWg
.
Add
(
len
(
config
.
StartupHooks
))
config
.
StartupHooksWg
.
Add
(
len
(
config
.
StartupHooks
))
shArgs
:=
cmds
.
StartupHookArgs
{
Wg
:
config
.
StartupHooksWg
,
APIServerReady
:
config
.
ControlConfig
.
Runtime
.
APIServerReady
,
KubeConfigAdmin
:
config
.
ControlConfig
.
Runtime
.
KubeConfigAdmin
,
Skips
:
config
.
ControlConfig
.
Skips
,
Disables
:
config
.
ControlConfig
.
Disables
,
}
for
_
,
hook
:=
range
config
.
StartupHooks
{
for
_
,
hook
:=
range
config
.
StartupHooks
{
if
err
:=
hook
(
ctx
,
config
.
StartupHooksWg
,
config
.
ControlConfig
.
Runtime
.
APIServerReady
,
config
.
ControlConfig
.
Runtime
.
KubeConfigAdmin
);
err
!=
nil
{
if
err
:=
hook
(
ctx
,
shArgs
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"startup hook"
)
return
errors
.
Wrap
(
err
,
"startup hook"
)
}
}
}
}
...
...
pkg/server/types.go
View file @
18bc98f6
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"sync"
"sync"
"github.com/rancher/k3s/pkg/cli/cmds"
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/daemons/config"
)
)
...
@@ -13,7 +14,7 @@ type Config struct {
...
@@ -13,7 +14,7 @@ type Config struct {
ControlConfig
config
.
Control
ControlConfig
config
.
Control
Rootless
bool
Rootless
bool
SupervisorPort
int
SupervisorPort
int
StartupHooks
[]
func
(
context
.
Context
,
*
sync
.
WaitGroup
,
<-
chan
struct
{},
string
)
error
StartupHooks
[]
cmds
.
StartupHook
StartupHooksWg
*
sync
.
WaitGroup
StartupHooksWg
*
sync
.
WaitGroup
LeaderControllers
CustomControllers
LeaderControllers
CustomControllers
Controllers
CustomControllers
Controllers
CustomControllers
...
...
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