Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple applications per pod #229

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20 as builder
FROM golang:1.20 AS builder

WORKDIR /workspace

Expand Down
23 changes: 15 additions & 8 deletions api/v1alpha2/minicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ type MiniClusterSpec struct {
// +optional
Interactive bool `json:"interactive"`

// Allow >1 Flux running (oversubscribing resources)
// +kubebuilder:default=false
// +optional
Oversubscribe bool `json:"oversubscribe"`

// Flux options for the broker, shared across cluster
// +optional
Flux FluxSpec `json:"flux"`
Expand Down Expand Up @@ -825,13 +830,6 @@ func (f *MiniCluster) Validate() bool {
// Count the FluxRunners
if container.RunFlux {
fluxRunners += 1

// Non flux-runners are required to have a name
} else {
if container.Name == "" {
fmt.Printf("😥️ %s is missing a name\n", name)
return false
}
}

// If a custom script is provided AND a command, no go
Expand All @@ -840,7 +838,16 @@ func (f *MiniCluster) Validate() bool {
return false
}
}
if fluxRunners != 1 {

// If we have more than one flux runner, must explicitly oversubscribe
if fluxRunners > 1 && !f.Spec.Oversubscribe {
fmt.Printf("😥️ More than one flux runner requires oversubscribe: true\n")
valid = false
}

// More than one container can run Flux (and the brokers see the same resources)
// But we need at least one!
if fluxRunners < 1 {
valid = false
}

Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha2/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@
"default": {},
"$ref": "#/definitions/Network"
},
"oversubscribe": {
"description": "Allow \u003e1 Flux running (oversubscribing resources)",
"type": "boolean",
"default": false
},
"pod": {
"description": "Pod spec details",
"default": {},
Expand Down
8 changes: 8 additions & 0 deletions api/v1alpha2/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions chart/templates/minicluster-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ spec:
description: Name for cluster headless service
type: string
type: object
oversubscribe:
default: false
description: Allow >1 Flux running (oversubscribing resources)
type: boolean
pod:
description: Pod spec details
properties:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/flux-framework.org_miniclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ spec:
description: Name for cluster headless service
type: string
type: object
oversubscribe:
default: false
description: Allow >1 Flux running (oversubscribing resources)
type: boolean
pod:
description: Pod spec details
properties:
Expand Down
16 changes: 11 additions & 5 deletions controllers/flux/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func getFluxContainer(

func getContainers(
specs []api.MiniClusterContainer,
defaultName string,
customName string,
mounts []corev1.VolumeMount,
serviceContainer bool,
) ([]corev1.Container, error) {
Expand All @@ -70,8 +70,15 @@ func getContainers(
pullPolicy = corev1.PullAlways
}

// Fluxrunner will use the namespace name
containerName := container.Name
// Give all flux containers a name, if not provided
if container.Name == "" {
// Maintain previous behavior to have name == main flux runner
if i == 0 {
container.Name = customName
} else {
container.Name = fmt.Sprintf("%s-%d", container.Name, i)
}
}
command := []string{}

// A Flux runner will have a wait.sh script that waits for the flux view
Expand All @@ -82,7 +89,6 @@ func getContainers(
// wait.sh path corresponds to container identifier
waitScript := fmt.Sprintf("/flux_operator/wait-%d.sh", i)
command = []string{"/bin/bash", waitScript}
containerName = defaultName
}

// A container not running flux can only have pre/post sections
Expand Down Expand Up @@ -140,7 +146,7 @@ func getContainers(
newContainer := corev1.Container{

// Call this the driver container, number 0
Name: containerName,
Name: container.Name,
Image: container.Image,
ImagePullPolicy: pullPolicy,
WorkingDir: container.WorkingDir,
Expand Down
2 changes: 2 additions & 0 deletions controllers/flux/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func NewMiniClusterJob(cluster *api.MiniCluster) (*batchv1.Job, error) {
}

// Prepare listing of containers for the MiniCluster
// We don't provide a default name because defaults are provided in Validate()
// Only service containers have a custom name here
containers, err := getContainers(
cluster.Spec.Containers,
cluster.Name,
Expand Down
10 changes: 10 additions & 0 deletions docs/getting_started/custom-resource-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ This would be equivalent to giving a start command of `sleep infinity` however o
(e.g., if there is a flux shutdown from within the Flux instance) the sleep command would
not exit with a failed code.

### oversubscribe

By default, we treat your single application container _or_ the single container in a MiniCluster pod designated to "runFlux" as the only Flux broker. When oversubscribe is set to true, you are allowed to define more than one "runFlux" container, meaning that multiple brokers will be sharing the same resources.

```yaml
oversubscribe: true
```

We created this use case with the intention of having a service container running fluxion alongside the MiniCluster to orchestrate the N containers. This is consiedered an advanced use case and you should use it with caution!

### launcher

If you are using an executor that launches Flux Jobs (e.g., workflow managers such as Snakemake and Nextflow do!)
Expand Down
1 change: 1 addition & 0 deletions docs/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The following tutorials are provided from their respective directories (and are

These examples show how to interact with your flux queue from a sidecar container (that has access to the flux broker of the pod):

- [multiple-applications-per-pod](https://github.com/flux-framework/flux-operator/tree/main/examples/experimental/multiple-applications-per-pod): Allow multiple applications to run in a single pod aided by a Fluxion service orchestrator.
- [flux-sidecar](https://github.com/flux-framework/flux-operator/blob/main/examples/tests/flux-sidecar) to see a sleep job in the main application queue

### Services
Expand Down
4 changes: 4 additions & 0 deletions examples/dist/flux-operator-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ spec:
description: Name for cluster headless service
type: string
type: object
oversubscribe:
default: false
description: Allow >1 Flux running (oversubscribing resources)
type: boolean
pod:
description: Pod spec details
properties:
Expand Down
4 changes: 4 additions & 0 deletions examples/dist/flux-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ spec:
description: Name for cluster headless service
type: string
type: object
oversubscribe:
default: false
description: Allow >1 Flux running (oversubscribing resources)
type: boolean
pod:
description: Pod spec details
properties:
Expand Down
Loading
Loading