Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ actions/github/webhook/common
.direnv/
.idea/**
.vscode/**
profile_default/history.sqlite
2 changes: 1 addition & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ header:
- '**/license-eye'
- '**/id_rsa*'
- '**/.gitkeep'
- 'poetry.lock'
- 'uv.lock'
- '**/__*'
- '.github/ngrok'
- 'ngrok'
Expand Down
105 changes: 48 additions & 57 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN groupadd --gid 1001 nuvolaris && \

USER nuvolaris
WORKDIR /home/nuvolaris

# install the operator
ADD --chown=nuvolaris:nuvolaris nuvolaris/*.py /home/nuvolaris/nuvolaris/
ADD --chown=nuvolaris:nuvolaris nuvolaris/files /home/nuvolaris/nuvolaris/files
Expand Down Expand Up @@ -52,11 +53,10 @@ ADD --chown=nuvolaris:nuvolaris deploy/postgres-operator-deploy /home/nuvolaris/
ADD --chown=nuvolaris:nuvolaris deploy/ferretdb /home/nuvolaris/deploy/ferretdb
ADD --chown=nuvolaris:nuvolaris deploy/runtimes /home/nuvolaris/deploy/runtimes
ADD --chown=nuvolaris:nuvolaris deploy/postgres-backup /home/nuvolaris/deploy/postgres-backup
ADD --chown=nuvolaris:nuvolaris run.sh dbinit.sh cron.sh pyproject.toml poetry.lock whisk-system.sh /home/nuvolaris/

# prepares the required folders to deploy the whisk-system actions
RUN mkdir /home/nuvolaris/deploy/whisk-system
ADD --chown=nuvolaris:nuvolaris run.sh dbinit.sh cron.sh whisk-system.sh pyproject.toml uv.lock opsfile.yml prereq.yml /home/nuvolaris/
RUN mkdir -p /home/nuvolaris/deploy/whisk-system /home/nuvolaris/profile_default/startup
ADD --chown=nuvolaris:nuvolaris actions /home/nuvolaris/actions
ADD --chown=nuvolaris:nuvolaris profile_default/startup/00-init.ipy /home/nuvolaris/profile_default/startup

# enterprise specific
ADD --chown=nuvolaris:nuvolaris deploy/openwhisk-enterprise /home/nuvolaris/deploy/openwhisk-enterprise
Expand All @@ -72,31 +72,6 @@ ADD --chown=nuvolaris:nuvolaris deploy/milvus-slim /home/nuvolaris/deploy/milvus
ADD --chown=nuvolaris:nuvolaris deploy/registry /home/nuvolaris/deploy/registry
ADD --chown=nuvolaris:nuvolaris quota.sh /home/nuvolaris/

#------------------------------------------------------------------------------
# Python dependencies
FROM python:3.12-slim-bullseye AS deps

# --- Install Poetry ---
ARG POETRY_VERSION=1.8.5
ENV POETRY_HOME=/opt/poetry
ENV POETRY_NO_INTERACTION=1
ENV POETRY_VIRTUALENVS_IN_PROJECT=1
ENV POETRY_VIRTUALENVS_CREATE=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV POETRY_CACHE_DIR=/opt/.cache
ENV PATH=${POETRY_HOME}/bin:$PATH

WORKDIR /home/nuvolaris
COPY --chown=nuvolaris:nuvolaris pyproject.toml poetry.lock /home/nuvolaris/
RUN echo "Installing poetry" && \
# Install minimal dependencies
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update && apt-get install -y --no-install-recommends \
curl gnupg zip unzip && \
curl -sSL https://install.python-poetry.org | python - && \
cd /home/nuvolaris && poetry install --no-root --no-interaction --no-ansi && rm -rf $POETRY_CACHE_DIR

#------------------------------------------------------------------------------
# Final stage
FROM python:3.12-slim-bullseye
Expand All @@ -109,13 +84,10 @@ ENV INVOKER_IMAGE=ghcr.io/nuvolaris/openwhisk-invoker
ENV INVOKER_TAG=3.1.0-mastrogpt.2402101445
ENV OPERATOR_IMAGE=${OPERATOR_IMAGE_DEFAULT}
ENV OPERATOR_TAG=${OPERATOR_TAG_DEFAULT}

# configure dpkg && timezone
ENV TZ=Europe/London
ENV HOME=/home/nuvolaris
ENV VIRTUAL_ENV=/home/nuvolaris/.venv
ENV POETRY_HOME=/opt/poetry
ENV POETRY_CACHE_DIR=/opt/.cache
ENV PATH=$POETRY_HOME/bin:$HOME/.venv/bin:$HOME/.local/bin:/usr/local/bin:/usr/bin:/sbin:/bin:/usr/sbin/
# configure dpkg && timezone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
# add nuvolaris user
groupadd --gid 1001 nuvolaris && \
Expand All @@ -124,36 +96,55 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
# Install minimal dependencies
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update && apt-get install -y --no-install-recommends \
curl gnupg zip unzip && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
# install kubectl
KVER="v1.23.0" && \
ARCH="$(dpkg --print-architecture)" && \
curl -sL "https://dl.k8s.io/release/$KVER/bin/linux/$ARCH/kubectl" -o /usr/bin/kubectl && chmod +x /usr/bin/kubectl && \
VER="v4.5.7" && \
curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F$VER/kustomize_${VER}_linux_${ARCH}.tar.gz" | tar xzvf - -C /usr/bin && \
# openwhisk cli
WSK_VERSION=1.2.0 && \
WSK_BASE=https://github.com/apache/openwhisk-cli/releases/download && \
curl -sL "$WSK_BASE/$WSK_VERSION/OpenWhisk_CLI-$WSK_VERSION-linux-$ARCH.tgz" | tar xzvf - -C /usr/bin/ && \
# install minio
MINIO_BASE=https://dl.min.io/client/mc/release/linux && \
MC_VER=RELEASE.2025-05-21T01-59-54Z && \
curl -sL "$MINIO_BASE-$ARCH/archive/mc.${MC_VER}" -o /usr/bin/mc && chmod +x /usr/bin/mc && \
# install taskfile
curl -sL https://taskfile.dev/install.sh | sh -s -- -d -b /usr/bin
curl gnupg zip unzip openssh-client && \
apt-get clean && rm -rf /var/lib/apt/lists/*

USER nuvolaris
WORKDIR /home/nuvolaris
# Copy virtualenv
COPY --from=deps --chown=nuvolaris:nuvolaris ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# Copy poetry
COPY --from=deps --chown=nuvolaris:nuvolaris ${POETRY_HOME} ${POETRY_HOME}

## saving those scripts just in case - now managed by ops prereqs
# ex install openwhisk cli - using the ops wrapper instead
#WSK_VERSION=1.2.0 && \
#WSK_BASE=https://github.com/apache/openwhisk-cli/releases/download && \
# curl -sL "$WSK_BASE/$WSK_VERSION/OpenWhisk_CLI-$WSK_VERSION-linux-$ARCH.tgz" | tar xzvf - -C /usr/bin/ && \
# ex install minio - archived binaries disappered... - installed by ops prereqs
# MINIO_BASE=https://dl.min.io/client/mc/release/linux && \
# MC_VER=RELEASE.2025-05-21T01-59-54Z && \
# curl -sL "$MINIO_BASE-$ARCH/archive/mc.${MC_VER}" -o /usr/bin/mc && chmod +x /usr/bin/mc && \
# ex install kubectl - installed by ops prereq now
#KVER="v1.23.0" && \
#ARCH="$(dpkg --print-architecture)" && \
#curl -sL "https://dl.k8s.io/release/$KVER/bin/linux/$ARCH/kubectl" -o /usr/bin/kubectl && chmod +x /usr/bin/kubectl && \
#VER="v4.5.7" && \
#curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F$VER/kustomize_${VER}_linux_${ARCH}.tar.gz" | tar xzvf - -C /usr/bin && \

RUN \
# install ops, wsk wrapper and task and create the op plugin from the home dir
VER="0.1.0-2501041342.dev";\
URL="https://raw.githubusercontent.com/apache/openserverless-cli/refs/tags/v$VER/install.sh" ;\
curl -sL $URL | VERSION="$VER" bash ;\
echo -e '#!/bin/bash\nops -wsk "$@"' >$HOME/.local/bin/wsk ; chmod +x $HOME/.local/bin/wsk ;\
curl -sL https://taskfile.dev/install.sh | sh -s -- -d -b $HOME/.local/bin/task

# env with l
ENV PATH="$HOME/.local/bin":\
"$HOME/.ops/linux-$(dpkg --print-architecture)/bin":\
"$HOME/.venv/bin":\
/usr/local/bin:/usr/bin:/sbin:/bin:/usr/sbin/

# Copy the home
COPY --from=sources --chown=nuvolaris:nuvolaris ${HOME} ${HOME}
RUN poetry install --only main --no-interaction --no-ansi && rm -rf ${POETRY_CACHE_DIR}

# prepares the required folders to deploy the whisk-system actions
RUN mkdir -p /home/nuvolaris/deploy/whisk-system && \
./whisk-system.sh && \
cd deploy && tar cvf ../deploy.tar *

# Create the ops op plugin and initialize prerequisites
RUN \
ops -t && ops setup && \
ln -sf "$HOME" "$HOME/.ops/olaris-op" && \
ops op && ops op setup && \
echo quit | ops op cli

CMD ["./run.sh"]
118 changes: 80 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,74 +20,116 @@

# Apache OpenServerless Operator

In this readme there are information for developers.
In this README we explain how to do development with the Operator

We describe how to build and test the operator in our development environment
The operator is a collection of modules managed with ops.

Please refer to the [website](https://openserverless.apache.org) for user information.
The operator itself is an ops plugin to invoke some of functions from the command line.

## How to build and use an operator image
To work with it, install ops and clone the source code from the top level, so you get the operator code under `openserverless/operator-op`

Ensure you have satisfied the prerequisites below. Most notably, you need to use our development virtual machine and you
need write access to a GitHub repository.
```
curl -sL bit.ly/get-ops | bash
git clone https://github.com/apache/openserverless --recurse-submodules
cd openserverless
```

Once you have satisfied the prerequisites, you can build an image you can use in the development machine.
To be able to work with the operator you need a Kubernetes cluster and a Working configuration.

Build an image with:
You can easily create one with kind:

```shell
task build
```
# destroy the old one
ops op clu kind destroy
# create a new cluster
ops op clu kind create
```

Please note that it will build the image locally and push in an internal registry, even if it is name is
`ghcr.io/${GITHUB_USER}/openserverless-operator`.
If you want to use kubectl directory use `ops util kubeconfig`
to export the kind configurat to `~/.kube/config`. WARNING it overwrites yout existing one.

To be able to build, the task `build` will commit and push all your changes and then build the operator from the public
sources in your local k3s.
## Configuration

It will also show the logs for the latest build.
You need a full configuration to be able to work with the operator.

You can then deploy it with:
You can create an actual configuration on the cluster skipping the launch of the operator:

For example this is a config of slim mode:

```shell
task deploy
```
# configure slim mode for example
ops config slim
# configure
ops setup kubernetes configure
```

Once you have finished with development you can create a public image with `task publish` that will publish the tag and
trigger a creation of the image.
## Execute the operator as a cli plugin

## Prerequisites
Many modules are now executable as `ops op nuvolaris` commands.

1. Please set up and use a development VM [as described here](https://github.com/apache/openserverless)
For example: `ops op nuv etcd`

2. With VSCode, access the development VM, open the workspace `openserverless/openserverless.code-workspace` and then
open a terminal with `operator` subproject: this will enable the `nix` environment with direnv (provided by the VM).
It shows the subcommand with `create [<replicas>]` and `delete`

3. Create a fork of `github.com/apache/openserverless-operator`
## Working on the cli

4. Copy .env.dist in .env and put your GitHub username in it
You can also test and work on the cli. Try this:

5. Since the build requires you push your sources in your repo, you need the credentials to access it. The fastest way
is
to [create a personal token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
```
ops op cli
```

Initialize the configuration:

```
import nuvolaris.operator_util as operator_util
owner = kube.get("wsk/controller")
operator_util.config_from_spec(owner['spec'])
```

6. Now set up a remote to access your repo and set it as your default upstream branch.
Create the components:

```
git remote add fork https://<GITHUB_USERNAME>:<GITHUB_TOKEN>@github.com/<GITHUB_USERNAME>/openserverless-operator
git branch -u https://github.com/<GITHUB_USERNAME>/openserverless-operator
import nuvolaris.etcd as etcd
msg = etcd.create(owner)
```

That's it. Now you can use `task build` to build the image.
## How to publish the operator image

7. Deploy the operator
When you are satisfied with your development you can publish the image.

To deploy a testing configuration of the Apache OpenServerless operator execute the command
First, install [task](http://taskfile.dev/docs/installation).

You need to setup some environment variables. Copy .env.dist in .env and put your GitHub username in it

Since the build requires you push your sources in your repo, you need the credentials to access it. The fastest way is
to [create a personal token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)

Build an image with:

```shell
task all
task build
```

The operator instance will be configured applying the `test/k3s/whisk.yaml` template.
All the components are activated except TLS and MONITORING.
Please note that it will build the image locally and push in an internal registry, even if it is name is
`ghcr.io/${GITHUB_USER}/openserverless-operator`.

To be able to build, the task `build` will commit and push all your changes and then build the operator from the public
sources in your local k3s.

It will also show the logs for the latest build.

You can then deploy it with:

```shell
task deploy
```

Once you have finished with development you can create a public image with `task publish` that will publish the tag and
trigger a creation of the image.

Once the image is publicly available you have to put in in `opsroot.json` to use it:

```
https://github.com/apache/openserverless-task/blob/9d2227b87196be9b487673d4d1f8202c2ec354f2/opsroot.json#L8
```
3 changes: 0 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ includes:
taskfile: TaskfileBuild.yml
o:
taskfile: TaskfileOlaris.yml
kind:
taskfile: clusters/kind.yml
dir: clusters
eks:
taskfile: clusters/eks.yml
dir: clusters
Expand Down
1 change: 1 addition & 0 deletions attic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Old stuff to be removed, once we ensure is no more needed
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions clusters/kind/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
54 changes: 54 additions & 0 deletions clusters/kind/opsfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
#
# http://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.
#
version: '3'

vars:
NAME: "nuvolaris-dev"
KUBEFILE: "{{.OPS_TMP}}/kind-dev.kubeconfig"
DRY: ""

env:
KUBECONFIG:
sh: if test -e "$OPS_TMP/kubeconfig"; then echo "$OPS_TMP/kubeconfig"; else echo ~/.kube/config ; fi
kc: "{{.DRY}} kubectl -n nuvolaris"

tasks:

create:
desc: create
cmds:
- kind create cluster --name "{{.NAME}}" --config kind.yaml
- kind get kubeconfig --name="{{.NAME}}" >{{.KUBEFILE}}
- cp "{{.KUBEFILE}}" "$OPS_TMP/kubeconfig"
- kubectl --namespace=ingress-nginx --kubeconfig "{{.KUBEFILE}}" apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

destroy:
desc: destroy
cmds:
- kind delete cluster --name "{{.NAME}}"
- rm -f "$OPS_TMP/kubeconfig" "{{.KUBEFILE}}"

list:
desc: list
cmds:
- kind get clusters

status:
desc: status
cmds:
- $kc get nodes
Loading
Loading