Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hepto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACIDES
Hepto
Commits
12312f38
Commit
12312f38
authored
7 months ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Enable the admission post-start-hook
parent
3b1150c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#32619
canceled
7 months ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/apiserver.go
+13
-5
13 additions, 5 deletions
services/apiserver.go
with
13 additions
and
5 deletions
services/apiserver.go
+
13
−
5
View file @
12312f38
...
...
@@ -91,7 +91,7 @@ var kubeApiserver = &Unit{
Name
:
"kube-apiserver"
,
Dependencies
:
[]
*
Unit
{
etcd
,
pkiMaster
,
vpn
,
memberlist
,
kubeLogger
},
Run
:
func
(
u
*
Unit
,
c
*
Cluster
,
ctx
context
.
Context
)
error
{
config
,
clients
,
err
:=
buildConfig
(
c
)
config
,
clients
,
hooks
,
err
:=
buildConfig
(
c
)
if
err
!=
nil
{
return
err
}
...
...
@@ -111,6 +111,12 @@ var kubeApiserver = &Unit{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not build apiserver config: %w"
,
err
)
}
for
name
,
hook
:=
range
hooks
{
err
=
apiConfig
.
GenericConfig
.
AddPostStartHook
(
name
,
hook
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not add a post-start-hook: %w"
,
err
)
}
}
apiServer
,
err
:=
apiConfig
.
Complete
()
.
New
(
extensionServer
.
GenericAPIServer
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not initialize generic apiserver: %w"
,
err
)
...
...
@@ -176,10 +182,12 @@ var kubeApiserver = &Unit{
// Build a generic apiserver config, that is used and tweaked for various instanciated servers (native, extensions, etc.)
// Be careful, config is returned as a pointer, so it must be explicitely shallow copied before tweaking
func
buildConfig
(
c
*
Cluster
)
(
config
*
server
.
Config
,
clients
*
k8s
.
Clients
,
err
error
)
{
func
buildConfig
(
c
*
Cluster
)
(
config
*
server
.
Config
,
clients
*
k8s
.
Clients
,
hooks
map
[
string
]
server
.
PostStartHookFunc
,
err
error
)
{
// Initialize return values
config
=
server
.
NewConfig
(
legacyscheme
.
Codecs
)
hooks
=
map
[
string
]
server
.
PostStartHookFunc
{}
// Initialize a basic configuration object
ver
:=
version
.
Get
()
config
=
server
.
NewConfig
(
legacyscheme
.
Codecs
)
config
.
Version
=
&
ver
config
.
Serializer
=
legacyscheme
.
Codecs
config
.
LongRunningFunc
=
filters
.
BasicLongRunningRequestCheck
(
...
...
@@ -316,12 +324,12 @@ func buildConfig(c *Cluster) (config *server.Config, clients *k8s.Clients, err e
LoopbackClientConfig
:
config
.
LoopbackClientConfig
,
}
schemaResolver
:=
resolver
.
NewDefinitionsSchemaResolver
(
scheme
.
Scheme
,
config
.
OpenAPIConfig
.
GetDefinitions
)
// TODO: do something with the post start hook
heperInitializers
,
_
,
err
:=
admissionConfig
.
New
(
nil
,
nil
,
clients
.
ServiceResolver
(),
nil
,
schemaResolver
)
heperInitializers
,
admissionHook
,
err
:=
admissionConfig
.
New
(
nil
,
nil
,
clients
.
ServiceResolver
(),
nil
,
schemaResolver
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"could not prepare the admission config: %w"
,
err
)
return
}
hooks
[
"initialize-admission"
]
=
admissionHook
initializersChain
=
append
(
initializersChain
,
heperInitializers
...
)
// Actually build the admission chain
// The plugins config is an instance that just returns nil for every plugin, the decorators instance does nothing
...
...
This diff is collapsed.
Click to expand it.
kaiyou
@kaiyou
mentioned in commit
a6f3089e
·
7 months ago
mentioned in commit
a6f3089e
mentioned in commit a6f3089eedeb8d3c0fdc650a244802ba34c75f5f
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment