Skip to content

Commit c368ac6

Browse files
feat(backend): Add CLI flags to support Kubernetes native API implementation (#11907)
Signed-off-by: VaniHaripriya <[email protected]>
1 parent d6c864f commit c368ac6

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

backend/src/apiserver/client_manager/client_manager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ type ClientManager struct {
117117
// Options to pass to Client Manager initialization
118118
type Options struct {
119119
UsePipelineKubernetesStorage bool
120+
GlobalKubernetesWebhookMode bool
120121
Context context.Context
121122
WaitGroup *sync.WaitGroup
122123
}
@@ -210,7 +211,7 @@ func (c *ClientManager) init(options *Options) error {
210211

211212
var pipelineStoreForRef storage.PipelineStoreInterface
212213

213-
if options.UsePipelineKubernetesStorage || common.IsOnlyKubernetesWebhookMode() {
214+
if options.UsePipelineKubernetesStorage || options.GlobalKubernetesWebhookMode {
214215
glog.Info("Initializing controller client...")
215216
restConfig, err := util.GetKubernetesConfig()
216217
if err != nil {
@@ -219,7 +220,7 @@ func (c *ClientManager) init(options *Options) error {
219220

220221
var cacheConfig map[string]cache.Config
221222

222-
if !common.IsMultiUserMode() && common.GetPodNamespace() != "" && !common.IsOnlyKubernetesWebhookMode() {
223+
if !common.IsMultiUserMode() && common.GetPodNamespace() != "" && !options.GlobalKubernetesWebhookMode {
223224
cacheConfig = map[string]cache.Config{common.GetPodNamespace(): {}}
224225
}
225226

@@ -259,7 +260,7 @@ func (c *ClientManager) init(options *Options) error {
259260

260261
c.controllerClient = controllerClient
261262
c.controllerClientNoCache = controllerClientNoCache
262-
if common.IsOnlyKubernetesWebhookMode() {
263+
if options.GlobalKubernetesWebhookMode {
263264
return nil
264265
}
265266

backend/src/apiserver/common/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const (
3232
KubeflowUserIDPrefix string = "KUBEFLOW_USERID_PREFIX"
3333
UpdatePipelineVersionByDefault string = "AUTO_UPDATE_PIPELINE_DEFAULT_VERSION"
3434
TokenReviewAudience string = "TOKEN_REVIEW_AUDIENCE"
35-
GlobalKubernetesWebhookMode string = "GLOBAL_KUBERNETES_WEBHOOK_MODE"
3635
)
3736

3837
func IsPipelineVersionUpdatedByDefault() bool {
@@ -128,7 +127,3 @@ func GetKubeflowUserIDPrefix() string {
128127
func GetTokenReviewAudience() string {
129128
return GetStringConfigWithDefault(TokenReviewAudience, DefaultTokenReviewAudience)
130129
}
131-
132-
func IsOnlyKubernetesWebhookMode() bool {
133-
return GetBoolConfigWithDefault(GlobalKubernetesWebhookMode, false)
134-
}

backend/src/apiserver/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ var (
7070
sampleConfigPath = flag.String("sampleconfig", "", "Path to samples")
7171
collectMetricsFlag = flag.Bool("collectMetricsFlag", true, "Whether to collect Prometheus metrics in API server.")
7272
usePipelinesKubernetesStorage = flag.Bool("pipelinesStoreKubernetes", false, "Store and run pipeline versions in Kubernetes")
73+
disableWebhook = flag.Bool("disableWebhook", false, "Set this if pipelinesStoreKubernetes is on but using a global webhook in a separate pod")
74+
globalKubernetesWebhookMode = flag.Bool("globalKubernetesWebhookMode", false, "Set this to run exclusively in Kubernetes Webhook mode")
7375
)
7476

7577
type RegisterHttpHandlerFromEndpoint func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error
@@ -93,6 +95,7 @@ func main() {
9395

9496
options := &cm.Options{
9597
UsePipelineKubernetesStorage: *usePipelinesKubernetesStorage,
98+
GlobalKubernetesWebhookMode: *globalKubernetesWebhookMode,
9699
Context: backgroundCtx,
97100
WaitGroup: &wg,
98101
}
@@ -122,9 +125,13 @@ func main() {
122125
}
123126

124127
defer clientManager.Close()
125-
webhookOnlyMode := common.IsOnlyKubernetesWebhookMode()
128+
webhookOnlyMode := *globalKubernetesWebhookMode
129+
130+
if (*usePipelinesKubernetesStorage && !*disableWebhook) || webhookOnlyMode {
131+
if *disableWebhook && webhookOnlyMode {
132+
glog.Fatalf("Invalid configuration: globalKubernetesWebhookMode is enabled but the webhook is disabled")
133+
}
126134

127-
if *usePipelinesKubernetesStorage || webhookOnlyMode {
128135
wg.Add(1)
129136
webhookServer, err := startWebhook(
130137
clientManager.ControllerClient(true), clientManager.ControllerClient(false), &wg,
@@ -147,6 +154,7 @@ func main() {
147154
wg.Wait()
148155
return
149156
}
157+
150158
}
151159

152160
resourceManager := resource.NewResourceManager(

0 commit comments

Comments
 (0)