Skip to content

Commit

Permalink
shared process namespace example working
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Oct 16, 2023
1 parent 9fcf881 commit e1d573d
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 11 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha2/minicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ type FluxSpec struct {
// +optional
MinimalService bool `json:"minimalService"`

// Do not wait for the socket
// +optional
NoWaitSocket bool `json:"noWaitSocket"`

// Log level to use for flux logging (only in non TestMode)
// +kubebuilder:default=6
// +default=6
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha2/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@
"type": "string",
"default": ""
},
"noWaitSocket": {
"description": "Do not wait for the socket",
"type": "boolean",
"default": false
},
"optionFlags": {
"description": "Flux option flags, usually provided with -o optional - if needed, default option flags for the server These can also be set in the user interface to override here. This is only valid for a FluxRunner \"runFlux\" true",
"type": "string",
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.

3 changes: 3 additions & 0 deletions chart/templates/minicluster-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ spec:
a munge key. This is intended for bursting. Assumed to be at /etc/munge/munge.key
This is binary data.
type: string
noWaitSocket:
description: Do not wait for the socket
type: boolean
optionFlags:
description: Flux option flags, usually provided with -o optional
- if needed, default option flags for the server These can also
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/flux-framework.org_miniclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ spec:
for a munge key. This is intended for bursting. Assumed to be
at /etc/munge/munge.key This is binary data.
type: string
noWaitSocket:
description: Do not wait for the socket
type: boolean
optionFlags:
description: Flux option flags, usually provided with -o optional
- if needed, default option flags for the server These can also
Expand Down
3 changes: 3 additions & 0 deletions examples/dist/flux-operator-arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ spec:
for a munge key. This is intended for bursting. Assumed to be
at /etc/munge/munge.key This is binary data.
type: string
noWaitSocket:
description: Do not wait for the socket
type: boolean
optionFlags:
description: Flux option flags, usually provided with -o optional
- if needed, default option flags for the server These can also
Expand Down
3 changes: 3 additions & 0 deletions examples/dist/flux-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ spec:
for a munge key. This is intended for bursting. Assumed to be
at /etc/munge/munge.key This is binary data.
type: string
noWaitSocket:
description: Do not wait for the socket
type: boolean
optionFlags:
description: Flux option flags, usually provided with -o optional
- if needed, default option flags for the server These can also
Expand Down
2 changes: 2 additions & 0 deletions examples/experimental/bursting/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Design

**not tested with new design yet, not currently working on**

### What we might need

I expect for this kind of bursting to work I will need to be able to:
Expand Down
10 changes: 7 additions & 3 deletions examples/experimental/shared-process-space/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Testing Communication between Containers

We are going to test running this application in the context of a [shared process namespace between containers in a pod](https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/).
Update:

- This is implemented as an addon to the [metrics-operator](https://converged-computing.github.io/metrics-operator/getting_started/addons.html#workload-flux) and also the design is honored here via an init-container.

## Go Experiment

Expand All @@ -13,9 +16,10 @@ kubectl apply -f ../../dist/flux-operator-dev.yaml

Create the interactive Minicluster. The [goshare](https://github.com/converged-computing/goshare) client and server will
be installed to two containers. The server has the application we want to run, and the client has flux.
Note that it takes a little longer than normal because we run dnf update and install a few things in
the application container.

```bash
$ kubectl create namespace flux-operator
$ kubectl apply -f minicluster.yaml
```

Expand All @@ -28,7 +32,7 @@ We will test this interactively for now. In the future we will want to:
Wait until your pods are all running:

```bash
$ kubectl get pods -n flux-operator
$ kubectl get pods
```
```console
NAME READY STATUS RESTARTS AGE
Expand All @@ -40,7 +44,7 @@ flux-sample-3-jggrg 2/2 Running 0 7m36s

You can then watch the logs of a server container to see the command being run.
```bash
$ kubectl logs -n flux-operator flux-sample-0-wpsnj -c server
$ kubectl logs flux-sample-0-wpsnj -c server
```
```console
task: [build] GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o bin/client cmd/client/client.go
Expand Down
14 changes: 9 additions & 5 deletions examples/experimental/shared-process-space/minicluster.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: flux-framework.org/v1alpha1
apiVersion: flux-framework.org/v1alpha2
kind: MiniCluster
metadata:
name: flux-sample
namespace: flux-operator
spec:
size: 4
shareProcessNamespace: true
Expand All @@ -11,21 +10,26 @@ spec:
flux:
logLevel: 7

# Don't wait for the socket
noWaitSocket: true
container:
image: ghcr.io/converged-computing/flux-view-ubuntu:tag-focal

logging:
zeromq: true

# This is a list because a pod can support multiple containers
containers:

# The client container (issuing commands) has flux
- image: ghcr.io/flux-framework/flux-restful-api
- image: ubuntu
runFlux: true

# This is what we can run in interactive mode
command: goshare-cli -s /proc/$(cat /goshare.pid)/root/dinosaur.sock echo hello world
commands:
# users in both containers need to be same
runFluxAsRoot: true
pre: |
apt-get update && apt-get install -y wget jq
wget https://github.com/converged-computing/goshare/releases/download/2023-07-26-rc2/client
chmod +x ./client
mv ./client /bin/goshare-cli
Expand Down
4 changes: 2 additions & 2 deletions pkg/flux/templates/start.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# A custom startscript can be supported for a non flux runner given that
# the container also provides the entrypoint command to run. To be consitent,
# the container also provides the entrypoint command to run. To be consistent,
# we provide the same blocks of commands as we do to wait.sh.

# If any initCommand logic is defined
Expand All @@ -23,7 +23,7 @@
fluxsocket=${viewroot}/run/flux/local

# Wait for it to exist (application is running)
goshare-wait-fs -p ${fluxsocket} {{ if .Spec.Logging.Quiet }}> /dev/null 2>&1{{ end }}
{{ if .Spec.Flux.NoWaitSocket }}{{ else }}goshare-wait-fs -p ${fluxsocket} {{ if .Spec.Logging.Quiet }}> /dev/null 2>&1{{ end }}{{ end }}

# Ensure fluxsocket has local
fluxsocket="local://$fluxsocket"
Expand Down
1 change: 1 addition & 0 deletions sdk/python/v1alpha2/docs/FluxSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Name | Type | Description | Notes
**log_level** | **int** | Log level to use for flux logging (only in non TestMode) | [optional] [default to 6]
**minimal_service** | **bool** | Only expose the broker service (to reduce load on DNS) | [optional] [default to False]
**munge_secret** | **str** | Expect a secret (named according to this string) for a munge key. This is intended for bursting. Assumed to be at /etc/munge/munge.key This is binary data. | [optional] [default to '']
**no_wait_socket** | **bool** | Do not wait for the socket | [optional] [default to False]
**option_flags** | **str** | Flux option flags, usually provided with -o optional - if needed, default option flags for the server These can also be set in the user interface to override here. This is only valid for a FluxRunner \&quot;runFlux\&quot; true | [optional] [default to '']
**scheduler** | [**FluxScheduler**](FluxScheduler.md) | | [optional]
**submit_command** | **str** | Modify flux submit to be something else | [optional]
Expand Down
30 changes: 29 additions & 1 deletion sdk/python/v1alpha2/fluxoperator/models/flux_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class FluxSpec(object):
'log_level': 'int',
'minimal_service': 'bool',
'munge_secret': 'str',
'no_wait_socket': 'bool',
'option_flags': 'str',
'scheduler': 'FluxScheduler',
'submit_command': 'str',
Expand All @@ -59,13 +60,14 @@ class FluxSpec(object):
'log_level': 'logLevel',
'minimal_service': 'minimalService',
'munge_secret': 'mungeSecret',
'no_wait_socket': 'noWaitSocket',
'option_flags': 'optionFlags',
'scheduler': 'scheduler',
'submit_command': 'submitCommand',
'wrap': 'wrap'
}

def __init__(self, broker_config='', bursting=None, connect_timeout='5s', container=None, curve_cert='', log_level=6, minimal_service=False, munge_secret='', option_flags='', scheduler=None, submit_command=None, wrap=None, local_vars_configuration=None): # noqa: E501
def __init__(self, broker_config='', bursting=None, connect_timeout='5s', container=None, curve_cert='', log_level=6, minimal_service=False, munge_secret='', no_wait_socket=False, option_flags='', scheduler=None, submit_command=None, wrap=None, local_vars_configuration=None): # noqa: E501
"""FluxSpec - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
Expand All @@ -79,6 +81,7 @@ def __init__(self, broker_config='', bursting=None, connect_timeout='5s', contai
self._log_level = None
self._minimal_service = None
self._munge_secret = None
self._no_wait_socket = None
self._option_flags = None
self._scheduler = None
self._submit_command = None
Expand All @@ -101,6 +104,8 @@ def __init__(self, broker_config='', bursting=None, connect_timeout='5s', contai
self.minimal_service = minimal_service
if munge_secret is not None:
self.munge_secret = munge_secret
if no_wait_socket is not None:
self.no_wait_socket = no_wait_socket
if option_flags is not None:
self.option_flags = option_flags
if scheduler is not None:
Expand Down Expand Up @@ -290,6 +295,29 @@ def munge_secret(self, munge_secret):

self._munge_secret = munge_secret

@property
def no_wait_socket(self):
"""Gets the no_wait_socket of this FluxSpec. # noqa: E501
Do not wait for the socket # noqa: E501
:return: The no_wait_socket of this FluxSpec. # noqa: E501
:rtype: bool
"""
return self._no_wait_socket

@no_wait_socket.setter
def no_wait_socket(self, no_wait_socket):
"""Sets the no_wait_socket of this FluxSpec.
Do not wait for the socket # noqa: E501
:param no_wait_socket: The no_wait_socket of this FluxSpec. # noqa: E501
:type no_wait_socket: bool
"""

self._no_wait_socket = no_wait_socket

@property
def option_flags(self):
"""Gets the option_flags of this FluxSpec. # noqa: E501
Expand Down

0 comments on commit e1d573d

Please sign in to comment.