|
20 | 20 |
|
21 | 21 | # Apache OpenServerless Operator |
22 | 22 |
|
23 | | -NOTE: this readme is outdated and needs to be updated, not everyhing is still relevant. |
| 23 | +In this README we explain how to do development with the Operator |
24 | 24 |
|
25 | | ---- |
| 25 | +The operator is a collection of modules managed with ops. |
26 | 26 |
|
27 | | -In this readme there are information for developers. |
| 27 | +The operator itself is an ops plugin to invoke some of functions from the command line. |
28 | 28 |
|
29 | | -We describe how to build and test the operator in our development environment |
| 29 | +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` |
30 | 30 |
|
31 | | -Please refer to the [website](https://openserverless.apache.org) for user information. |
| 31 | +``` |
| 32 | +curl -sL bit.ly/get-ops | bash |
| 33 | +git clone https://github.com/apache/openserverless --recurse-submodules |
| 34 | +cd openserverless |
| 35 | +``` |
32 | 36 |
|
33 | | -## How to build and use an operator image |
| 37 | +To be able to work with the operator you need a Kubernetes cluster and a Working configuration. |
34 | 38 |
|
35 | | -Ensure you have satisfied the prerequisites below. Most notably, you need to use our development virtual machine and you |
36 | | -need write access to a GitHub repository. |
| 39 | +You can easily create one with kind: |
37 | 40 |
|
38 | | -Once you have satisfied the prerequisites, you can build an image you can use in the development machine. |
| 41 | +``` |
| 42 | +# destroy the old one |
| 43 | +ops op clu kind destroy |
| 44 | +# create a new cluster |
| 45 | +ops op clu kind create |
| 46 | +``` |
39 | 47 |
|
40 | | -Build an image with: |
| 48 | +If you want to use kubectl directory use `ops util kubeconfig` |
| 49 | +to export the kind configurat to `~/.kube/config`. WARNING it overwrites yout existing one. |
41 | 50 |
|
42 | | -```shell |
43 | | -task build |
| 51 | +## Configuration |
| 52 | + |
| 53 | +You need a full configuration to be able to work with the operator. |
| 54 | + |
| 55 | +You can create an actual configuration on the cluster skipping the launch of the operator: |
| 56 | + |
| 57 | +For example this is a config of slim mode: |
| 58 | + |
| 59 | +``` |
| 60 | +# configure slim mode for example |
| 61 | +ops config slim |
| 62 | +# configure |
| 63 | +ops setup kubernetes configure |
44 | 64 | ``` |
45 | 65 |
|
46 | | -Please note that it will build the image locally and push in an internal registry, even if it is name is |
47 | | -`ghcr.io/${GITHUB_USER}/openserverless-operator`. |
| 66 | +## Execute the operator as a cli plugin |
48 | 67 |
|
49 | | -To be able to build, the task `build` will commit and push all your changes and then build the operator from the public |
50 | | -sources in your local k3s. |
| 68 | +Many modules are now executable as `ops op nuvolaris` commands. |
51 | 69 |
|
52 | | -It will also show the logs for the latest build. |
| 70 | +For example: `ops op nuv etcd` |
53 | 71 |
|
54 | | -You can then deploy it with: |
| 72 | +It shows the subcommand with `create [<replicas>]` and `delete` |
55 | 73 |
|
56 | | -```shell |
57 | | -task deploy |
| 74 | +## Working on the cli |
| 75 | + |
| 76 | +You can also test and work on the cli. Try this: |
| 77 | + |
| 78 | +``` |
| 79 | +ops op cli |
58 | 80 | ``` |
59 | 81 |
|
60 | | -Once you have finished with development you can create a public image with `task publish` that will publish the tag and |
61 | | -trigger a creation of the image. |
| 82 | +Initialize the configuration: |
62 | 83 |
|
63 | | -## Prerequisites |
| 84 | +``` |
| 85 | +import nuvolaris.operator_util as operator_util |
| 86 | +owner = kube.get("wsk/controller") |
| 87 | +operator_util.config_from_spec(owner['spec']) |
| 88 | +``` |
64 | 89 |
|
65 | | -1. Please set up and use a development VM [as described here](https://github.com/apache/openserverless) |
| 90 | +Create the components: |
66 | 91 |
|
67 | | -2. With VSCode, access the development VM, open the workspace `openserverless/openserverless.code-workspace` and then |
68 | | - open a terminal with `operator` subproject: this will enable the `nix` environment with direnv (provided by the VM). |
| 92 | +``` |
| 93 | +import nuvolaris.etcd as etcd |
| 94 | +msg = etcd.create(owner) |
| 95 | +``` |
69 | 96 |
|
70 | | -3. Create a fork of `github.com/apache/openserverless-operator` |
| 97 | +## How to publish the operator image |
71 | 98 |
|
72 | | -4. Copy .env.dist in .env and put your GitHub username in it |
| 99 | +When you are satisfied with your development you can publish the image. |
73 | 100 |
|
74 | | -5. Since the build requires you push your sources in your repo, you need the credentials to access it. The fastest way |
75 | | - is |
76 | | - to [create a personal token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) |
| 101 | +First, install [task](http://taskfile.dev/docs/installation). |
77 | 102 |
|
78 | | -6. Now set up a remote to access your repo and set it as your default upstream branch. |
| 103 | +You need to setup some environment variables. Copy .env.dist in .env and put your GitHub username in it |
79 | 104 |
|
80 | | -``` |
81 | | -git remote add fork https://<GITHUB_USERNAME>:<GITHUB_TOKEN>@github.com/<GITHUB_USERNAME>/openserverless-operator |
82 | | -git branch -u https://github.com/<GITHUB_USERNAME>/openserverless-operator |
| 105 | +Since the build requires you push your sources in your repo, you need the credentials to access it. The fastest way is |
| 106 | +to [create a personal token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) |
| 107 | + |
| 108 | +Build an image with: |
| 109 | + |
| 110 | +```shell |
| 111 | +task build |
83 | 112 | ``` |
84 | 113 |
|
85 | | -That's it. Now you can use `task build` to build the image. |
| 114 | +Please note that it will build the image locally and push in an internal registry, even if it is name is |
| 115 | +`ghcr.io/${GITHUB_USER}/openserverless-operator`. |
| 116 | + |
| 117 | +To be able to build, the task `build` will commit and push all your changes and then build the operator from the public |
| 118 | +sources in your local k3s. |
86 | 119 |
|
87 | | -7. Deploy the operator |
| 120 | +It will also show the logs for the latest build. |
88 | 121 |
|
89 | | -To deploy a testing configuration of the Apache OpenServerless operator execute the command |
| 122 | +You can then deploy it with: |
90 | 123 |
|
91 | 124 | ```shell |
92 | | -task all |
| 125 | +task deploy |
93 | 126 | ``` |
94 | 127 |
|
95 | | -The operator instance will be configured applying the `test/k3s/whisk.yaml` template. |
96 | | -All the components are activated except TLS and MONITORING. |
| 128 | +Once you have finished with development you can create a public image with `task publish` that will publish the tag and |
| 129 | +trigger a creation of the image. |
97 | 130 |
|
| 131 | +Once the image is publicly available you have to put in in `opsroot.json` to use it: |
| 132 | + |
| 133 | +``` |
| 134 | +https://github.com/apache/openserverless-task/blob/9d2227b87196be9b487673d4d1f8202c2ec354f2/opsroot.json#L8 |
| 135 | +``` |
0 commit comments