pkg/flink/executor.go (33 lines of code) (raw):
// Copyright 2021 Spotify AB.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package flink
import (
"context"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery"
pluginsCore "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/k8s"
"k8s.io/client-go/kubernetes/scheme"
flinkOp "github.com/spotify/flink-on-k8s-operator/apis/flinkcluster/v1beta1"
)
func init() {
if err := flinkOp.AddToScheme(scheme.Scheme); err != nil {
panic(err)
}
pluginmachinery.PluginRegistry().RegisterK8sPlugin(
k8s.PluginEntry{
ID: FlinkTaskType,
RegisteredTaskTypes: []pluginsCore.TaskType{FlinkTaskType},
ResourceToWatch: &flinkOp.FlinkCluster{},
Plugin: flinkResourceHandler{},
IsDefault: false,
CustomKubeClient: func(ctx context.Context) (pluginsCore.KubeClient, error) {
remoteConfig := GetFlinkConfig().RemoteClusterConfig
if !remoteConfig.Enabled {
// use controller-runtime KubeClient
return nil, nil
}
kubeConfig, err := KubeClientConfig(remoteConfig.Endpoint, remoteConfig.Auth)
if err != nil {
return nil, err
}
return k8s.NewDefaultKubeClient(kubeConfig)
},
})
}