This is an automated email from the ASF dual-hosted git repository. msciabarra pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/openserverless.git
commit 8ddd8023523aa855dcd850e9d441a13b6172e31c Author: Michele Sciabarra <[email protected]> AuthorDate: Sat Jul 6 19:27:21 2024 +0200 more instructions --- .attic/setup-k3s-wsl.txt | 33 ++++++++++++++++++ README.md | 88 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 99 insertions(+), 22 deletions(-) diff --git a/.attic/setup-k3s-wsl.txt b/.attic/setup-k3s-wsl.txt new file mode 100644 index 0000000..5d66680 --- /dev/null +++ b/.attic/setup-k3s-wsl.txt @@ -0,0 +1,33 @@ +Archived as k3s is not ready and usable + +### Setup a development VM in Windows 11 using WSL2 + +If you have Windows 11, open Powershell as an administrator then install and update WSL2 + +``` +wsl --install +wsl --update +wsl --set-default-version 2 +wsl --install -no-launch -d Ubuntu-24.04 +``` + +Then reboot your machine. + +If you have an older version of Windows, [check here](https://learn.microsoft.com/en-us/windows/wsl/install-manual) + +Now open again Powerlshell, as a normal user and prepare a data source for cloud init: + +``` +cd $env:USERPROFILE +mkdir .cloud-init +curl https://raw.githubusercontent.com/nuvolaris/openserverless/main/cloud-init.yaml -OutFile .\.cloud-init\Ubuntu-24.04.user-data +``` + +You are now ready to create your environment with + +``` +ubuntu2404.exe install --root +ubuntu2404.exe run cloud-init status --wait +``` + +You will see a sequence of dots. Wait until you see `status: done`. diff --git a/README.md b/README.md index 93f2e85..767fd97 100644 --- a/README.md +++ b/README.md @@ -2,57 +2,77 @@ Welcome to [Apache OpenServerless](https://cwiki.apache.org/confluence/display/INCUBATOR/OpenServerlessProposal) (also referenced as **AOS**), an incubating project at the [Apache Software Foundation](https://www.apache.org). -This readme provides informations for developers of the project. For user informations refer to the [website](https://openserverless.apache.org) (not yet available). +This README provides informations for developers of the project. For user informations refer to the [website](https://openserverless.apache.org) (not yet available). ## Development Enviroment Overview -AOS is a complex projects with lots of dependencies. It also needs a Kubernetes to be executed, tested and developed. +Apache OpenServerless is a complex projects with lots of dependencies. It also needs a Kubernetes to be executed, tested and developed. -You may setup the environment by yourself but it can take a lot of time. If you want to do it quickly read on. +You may setup the environment by yourself but it can take a lot of time so we prepared a ready-to-use development environment which runs the same on Windows, Linux and Mac. -In order to bootstrap easily the development environment for the project, we use a virtual machines based on Ubuntu (currently version 24) initialized with [cloud-init](https://cloud-init.io/). This virtual machine can be run either in your local machine or in a cloud provider. +In order to bootstrap easily the development environment for the project, we use a virtual machines based on Ubuntu (currently version 24) initialized with [cloud-init](https://cloud-init.io/). -As an IDE we use [VSCode](https://code.visualstudio.com/)] as it allows [Remote Development](https://code.visualstudio.com/docs/remote/remote-overview) within the virtual machine. You can also use a different IDE but the configuration for VSCode is ready and documented. +To create a virtual machine in your workstation we use [multipass](https://multipass.run/). You can also setup the virtual machine in a cloud provider and access it in the same way as in your local machine. We provide here instructions how to install in your local machine only. + +As an IDE we use [VSCode](https://code.visualstudio.com/)] as it allows [Remote Development](https://code.visualstudio.com/docs/remote/remote-overview) within the virtual machine. You can also use a different IDE but the configuration for VSCode is documented. You need a virtual machine with at least 8 giga of memory and 4 VCPU so your development workstation probably needs at least 16GB and 6VCPU. Your mileage may vary. ## Setup the Development Virtual Machine -Here we describe how to setup the development virtual machine in variuos scenarios. +Here we describe how to setup the development virtual machine on Linux, Mac and Windows using multipass. First, install multipass. -- Linux and Mac with Multipass -- Windows with WSL2 -- TODO: AWS, Azure, etc +- On Mac, if you already have [brew](https://brew.sh/), installing it is as easy as to type `brew install multipass`. -### Setup a development VM in Linux and Mac +- On Linux, if you already have [snap](https://snapcraft.io/), installing it is as easy as type `sudo snap install multipass` -The method we recomment to setup a VM in Linux and Mac is using [multipass](https://multipass.run/). +- On Windows, you need Windows 10 Pro/Enterprise/Education v 1803 or later, or any Windows 10 with VirtualBox . Make sure your local network is designated as private, otherwise Windows prevents Multipass from starting. -- On Mac, if you already have [brew](https://brew.sh/), installing it is as easy as to type `brew install multipass`. +Download the multipass installer from [here](https://multipass.run/download/windows) and run the installer. Pick Hyperv in preference, VirtualBox as an alternative. + +- Alternative options are available [here](https://multipass.run/install) -- On Linux, if you already have [snap](https://snapcraft.io/), installing it is as easy as type `sudo snap install multipass` -- Otherwise follow [those instructions](https://multipass.run/install) +### Setup a development VM using multipass -Once you have `multipass` type the following and wait util you see `status: done` +The steps and the commands to install the development VM are the same in Linux, Windows and Mac. + +Once you have `multipass` installed, open a terminal or powershell and type the following command: ``` multipass launch -nopenserverless -c4 -d20g -m8g --cloud-init https://raw.githubusercontent.com/nuvolaris/openserverless/main/cloud-init.yaml +``` + +Now wait until the installation is complete and you see `status: done` + +``` multipass exec "openserverless" -- sudo cloud-init status --wait ``` -## Setup SSH access for VSCode +Finally check if kubernetes (k3s) is up and running in the vm: + +``` +multipass exec openserverless sudo k3s kubectl get nodes +``` -## Setup access to multipass in Mac and Linux +You should see something like this: -To access the virtual machine from VSCode you need to setup a key and a configuration. Follow those steps: +``` +NAME STATUS ROLES AGE VERSION +openserverless Ready control-plane,master 4h58m v1.29.6+k3s1 +``` -1. Check if you already have a key in `$HOME/.ssh/id_rsa`. If not, generate one with `ssh-keygen -t rsa` (just press enter to confirm) +## Configure SSH access for VSCode -2. copy the key in the virtual machine: +To access the virtual machine from VSCode you need to setup a ssh key and create a configuration. Open a terminal (powershell on Windows) and follow those steps: + +1. Check if you already have a key in `$HOME/.ssh/id_rsa`. If not, generate one with `ssh-keygen -t rsa` then press enter to confirm. + +2. copy the key in the virtual machine to allow no password access: ``` -cat ~/.ssh/id_rsa.pub | multipass exec openserverless -- tee -a .ssh/authorized_keys +muultipass transfer $HOME/.ssh/id_rsa.pub openserverless: +multipass exec openserverless -- bash -c "cat id_rsa.pub | tee -a .ssh/authorized_keys" ``` 3. Create a configuration named `openserverless` to easily access it. @@ -68,7 +88,7 @@ openserverless Running 10.6.73.253 Ubuntu 24.04 LTS Take note of the `<IP>` in the `openserverless line` (in this case `10.6.73.253` but your value can be different) -Add to the file `~/ssh/config` the following +Use an editor to add to the file `~/ssh/config` the following: ``` Host openserverless @@ -85,11 +105,35 @@ ssh openserverless 5. Add your git username and email +Now you are in the virtual machine, setup your name and email for git use. + ``` git config --global user.name "<your-name>" git config --global user.email "<your-email> ``` +## Access the virtual machin with VSCode: + +1. Install [VSCode](https://code.visualstudio.com/) + +2. Type F1 then "Install Extensions" (or click on the task bar the package icon) + +3. Search "remote ssh" and install the extension "Remote - SSH" + +4. Type F1 then "Connect" (or click on the `><` symbol in the corner to the left at the bottom) and select "Remote-SSH: Connect Current Windows to Host" + +5. Click on `openserverless` then select Linux if requested + +6. Click on the menu bar on `File` then `Openworkspace from file`, then select the `openserverless` folder and open the `openserverless.code-workspace`. Select `Linux` and then `Trust the authors` if requested. + + +### Access to the subprojects + +Now you have all the repositories in your virtual madchine and the subprojects. Furthermore, in the vm it is configured `nix` that will setup all the dependencies to develop the subprojects, and `direnv` that will activate the right dependencies when you open the terminal on a subproject. + +For example try to execute `Terminal > New Terminal` and you will see you can choose the sub project. If you select `website` for example, the system will download all the dependencies to build the web site, in this case `hugo` and `npm` and install the required tools `postcss`. + + ### Cleanup If you do now want to keep the vm anymore, esure you have backed up all your files. Then remove it in your cloud provider (check your cloud provider documentation).
