forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of Weighted Clusters and domain based routing (#16)
- Loading branch information
1 parent
8edb4fc
commit 263f775
Showing
22 changed files
with
594 additions
and
342 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
flyteadmin/pkg/executioncluster/impl/cluster_execution_target_provider.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package impl | ||
|
||
import ( | ||
"github.com/lyft/flyteadmin/pkg/executioncluster" | ||
"github.com/lyft/flyteadmin/pkg/flytek8s" | ||
runtime "github.com/lyft/flyteadmin/pkg/runtime/interfaces" | ||
flyteclient "github.com/lyft/flytepropeller/pkg/client/clientset/versioned" | ||
"github.com/lyft/flytestdlib/promutils" | ||
"k8s.io/client-go/rest" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type clusterExecutionTargetProvider struct{} | ||
|
||
// Creates a new Execution target for a cluster based on config passed in. | ||
func (c *clusterExecutionTargetProvider) GetExecutionTarget(scope promutils.Scope, k8sCluster runtime.ClusterConfig) (*executioncluster.ExecutionTarget, error) { | ||
kubeConf, err := flytek8s.GetRestClientConfigForCluster(k8sCluster) | ||
if err != nil { | ||
return nil, err | ||
} | ||
flyteClient, err := getRestClientFromKubeConfig(scope, kubeConf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
client, err := client.New(kubeConf, client.Options{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &executioncluster.ExecutionTarget{ | ||
FlyteClient: flyteClient, | ||
Client: client, | ||
ID: k8sCluster.Name, | ||
Enabled: k8sCluster.Enabled, | ||
}, nil | ||
} | ||
|
||
func getRestClientFromKubeConfig(scope promutils.Scope, kubeConfiguration *rest.Config) (*flyteclient.Clientset, error) { | ||
fc, err := flyteclient.NewForConfig(kubeConfiguration) | ||
if err != nil { | ||
scope.MustNewCounter( | ||
"flyteclient_initialization_error", | ||
"count of errors encountered initializing a flyte client from kube config").Inc() | ||
return nil, err | ||
} | ||
return fc, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package impl | ||
|
||
import ( | ||
executioncluster_interface "github.com/lyft/flyteadmin/pkg/executioncluster/interfaces" | ||
"github.com/lyft/flyteadmin/pkg/runtime/interfaces" | ||
"github.com/lyft/flytestdlib/promutils" | ||
) | ||
|
||
func GetExecutionCluster(scope promutils.Scope, kubeConfig, master string, config interfaces.Configuration) executioncluster_interface.ClusterInterface { | ||
switch len(config.ClusterConfiguration().GetClusterConfigs()) { | ||
case 0: | ||
cluster, err := NewInCluster(scope, kubeConfig, master) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return cluster | ||
default: | ||
cluster, err := NewRandomClusterSelector(scope, config.ClusterConfiguration(), &clusterExecutionTargetProvider{}, config.ApplicationConfiguration().GetDomainsConfig()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return cluster | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.