Skip to content

Commit ae89c43

Browse files
committed
fixup! fixing k8s core arguments
1 parent 8622f1e commit ae89c43

4 files changed

Lines changed: 17 additions & 26 deletions

File tree

‎core/config.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func setDefaults() error {
129129
viper.SetDefault("enableKafka", true)
130130
viper.SetDefault("logAllIL", false)
131131
viper.SetDefault("metricsEndpoint", "8088/ecsmetrics")
132+
viper.SetDefault("enableKubernetes", false)
132133
viper.SetDefault("kubeNamespace", "alice-tasks")
133134
viper.SetDefault("kubeConfig", "/home/aliecs/.kube/config")
134135
return nil
@@ -202,7 +203,8 @@ func setFlags() error {
202203
pflag.Bool("enableKafka", viper.GetBool("enableKafka"), "Turn on the kafka messaging")
203204
pflag.Bool("logAllIL", viper.GetBool("logAllIL"), "Send all the logs into IL, including Debug and Trace messages")
204205
pflag.String("metricsEndpoint", viper.GetString("metricsEndpoint"), "Http endpoint from which metrics can be scraped: [port/endpoint]")
205-
pflag.String("kubeNamespace", viper.GetString("kubeNamespace"), "Kubernetes namespace in which ECS creates Task and Environment objects (empty disables Kubernetes support)")
206+
pflag.Bool("enableKubernetes", viper.GetBool("enableKubernetes"), "Turn on Kubernetes support (requires valid kubeNamespace and kubeConfig)")
207+
pflag.String("kubeNamespace", viper.GetString("kubeNamespace"), "Kubernetes namespace in which ECS creates Task and Environment objects")
206208
pflag.String("kubeConfig", viper.GetString("kubeConfig"), "Path to the kubeconfig used to access the Kubernetes cluster (empty uses in-cluster config)")
207209

208210
pflag.Parse()

‎core/task/manager.go‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,15 @@ func NewManager(shutdown func(), internalEventCh chan<- event.Event) (taskman *M
150150
taskman.reviveOffersTrg = taskman.schedulerState.reviveOffersTrg
151151
taskman.ackKilledTasks = safeacks.NewAcks()
152152
taskman.k8sEnvs = newK8sEnvRegistry()
153-
if k8sClient, k8sErr := newK8sClientFromViper(); k8sErr != nil {
154-
log.WithField("level", infologger.IL_Devel).WithError(k8sErr).Warn("K8s client init failed, K8s tasks disabled")
155-
} else if k8sClient == nil {
156-
log.Info("kubeNamespace not set, K8s tasks disabled")
157-
} else {
153+
if viper.GetBool("enableKubernetes") {
154+
k8sClient, k8sErr := newK8sClientFromViper()
155+
if k8sErr != nil {
156+
return nil, fmt.Errorf("failed to initialize K8s client: %w", k8sErr)
157+
}
158158
log.Info("K8s client initiated")
159159
taskman.k8sClient = k8sClient
160+
} else {
161+
log.Info("enableKubernetes not set, K8s tasks disabled")
160162
}
161163

162164
schedState.setupCli()

‎core/task/managerk8s.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ func (r *k8sEnvRegistry) delete(envId uid.ID) {
8484
}
8585

8686
// newK8sClientFromViper creates a K8s client from viper config.
87-
// Returns nil, nil if kubeNamespace is not configured (K8s disabled).
8887
func newK8sClientFromViper() (*k8sclient.Client, error) {
8988
namespace := viper.GetString("kubeNamespace")
9089
if namespace == "" {
91-
return nil, nil
90+
return nil, fmt.Errorf("kubeNamespace is empty")
9291
}
9392
kubeconfig := viper.GetString("kubeConfig")
9493
return k8sclient.New(kubeconfig, namespace)

‎docs/kubernetes_ecs.md‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,12 @@ To deploy a Kubernetes task you can in principle reuse existing control-workflow
5151

5252
### Core configuration
5353

54-
The Kubernetes client in ECS core is configured with the following parameters. Like any other core parameter they can be passed as CLI arguments
55-
| Parameter | Default | Description |
56-
|-----------------|-----------------------------|-------------|
57-
| `kubeNamespace` | `alice-tasks` | Namespace in which ECS creates custom Task and Environment objects. Setting it to an empty string disables Kubernetes support in core. |
58-
| `kubeConfig` | `/home/aliecs/.kube/config` | Path to the kubeconfig used to access the cluster. If empty, core tries to use the in-cluster config, which works only when core itself runs inside the cluster. |
59-
60-
If the Kubernetes client cannot be created (e.g. the kubeconfig file doesn't exist), core logs a warning `K8s client init failed, K8s tasks disabled`
61-
and continues running with Mesos only. Deploying a task with a Kubernetes control mode then fails.
62-
63-
### TaskTemplates
64-
65-
Since some tasks are deployed with known values ahead of time (image, env vars, ...), we added the `TaskTemplate` CR, which stores this data in the cluster so the user doesn't have to define everything every time. You can find all the `TaskTemplate`s in the `ecs-manifests/task-templates` folder. Currently we have templates for DPL, Readout, and StfBuilder/Sender. These templates must be applied to the cluster for the ECS bridge to work.
66-
67-
### DPL and JIT
68-
69-
DPL tasks work similarly to those mentioned before: they use `kubernetes_fairmq` in their workflow YAML manifests. However, there is a problem: JIT tasks' manifests are created the moment they are run. So for now you need to first run the workflow to generate those tasks, then change the control mode after they've been generated. This will be changed in the future.
70-
71-
### Worflow templates
54+
The Kubernetes client in ECS core is configured with the following parameters, passed as CLI arguments or in placed in `o2/components/aliecs/ANY/any/settings` consul file:
55+
| Parameter | Default | Description |
56+
|--------------------|-----------------------------|-------------|
57+
| `enableKubernetes` | `false` | Turns on Kubernetes support in core. When disabled, the other parameters are ignored and core runs with Mesos only. |
58+
| `kubeNamespace` | `alice-tasks` | Namespace in which ECS creates custom Task and Environment objects. Must not be empty when `enableKubernetes` is set. |
59+
| `kubeConfig` | `/home/aliecs/.kube/config` | Path to the kubeconfig used to access the cluster. If empty, core tries to use the in-cluster config, which works only when core itself runs inside the cluster. |
7260

7361
## Running tasks (`KubectlTask`)
7462

0 commit comments

Comments
 (0)