Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 1 | .. _dev_virtual: |
| 2 | |
| 3 | Developing code with a virtual VOLTHA POD |
| 4 | ========================================= |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 5 | |
| 6 | A guide to install a virtual POD. This is generally used to gain familiarity with the |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 7 | environment or for development purposes. |
| 8 | |
| 9 | Most of the `helm` and `voltctl` commands found in the :ref:`pod_physical` also |
| 10 | apply in the virtual environment. |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 11 | |
| 12 | Quickstart |
| 13 | ---------- |
| 14 | |
| 15 | Requires: |
| 16 | |
| 17 | - ``docker`` and ``go`` installed on your machine |
Zack Williams | 6ebfe06 | 2020-04-09 16:08:29 -0700 | [diff] [blame] | 18 | - `kind-voltha <https://gerrit.opencord.org/gitweb?p=kind-voltha.git>`_ cloned |
| 19 | on your machine |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 20 | |
| 21 | .. code:: bash |
| 22 | |
| 23 | TYPE=minimal WITH_RADIUS=y CONFIG_SADIS=y ONLY_ONE=y WITH_BBSIM=y ./voltha up |
| 24 | |
Andrea Campanella | 61fd666 | 2020-07-27 16:56:55 +0200 | [diff] [blame^] | 25 | For more information you can visit the `kind-voltha page <kind-voltha/README.md>`_. |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 26 | |
| 27 | Install BBSIM (Broad Band OLT/ONU Simulator) |
| 28 | -------------------------------------------- |
| 29 | |
| 30 | BBSIM provides a simulation of a BB device. It can be useful for |
| 31 | testing. |
| 32 | |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 33 | Create BBSIM Device |
| 34 | ^^^^^^^^^^^^^^^^^^^ |
| 35 | |
Andrea Campanella | 61fd666 | 2020-07-27 16:56:55 +0200 | [diff] [blame^] | 36 | After having deployed BBSIM either through `kind-voltha` or manually `bbsim <bbsim/docs/source/index.rst>`_ you can create a similated OLT. |
| 37 | |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 38 | .. code:: bash |
| 39 | |
| 40 | voltctl device create -t openolt -H $(kubectl get -n voltha service/bbsim -o go-template='{{.spec.clusterIP}}'):50060 |
| 41 | |
| 42 | Enable BBSIM Device |
| 43 | ^^^^^^^^^^^^^^^^^^^ |
| 44 | |
| 45 | .. code:: bash |
| 46 | |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 47 | voltctl device enable $(voltctl device list --filter Type~openolt -q) |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 48 | |
Andrea Campanella | 61fd666 | 2020-07-27 16:56:55 +0200 | [diff] [blame^] | 49 | Observing the newly created device in ONOS |
| 50 | ------------------------------------------ |
| 51 | |
| 52 | At this point you should be able to see a new device in ONOS. |
| 53 | |
| 54 | You can SSH into ONOS via |
| 55 | |
| 56 | .. code:: bash |
| 57 | |
| 58 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8201 karaf@localhost |
| 59 | |
| 60 | with password ``karaf``. |
| 61 | |
| 62 | Now when issuing `ports` command you should see something along the lines of: |
| 63 | |
| 64 | .. code:: bash |
| 65 | |
| 66 | karaf@root > ports |
| 67 | id=of:00000a0a0a0a0a00, available=true, local-status=connected 29s ago, role=MASTER, type=SWITCH, mfr=VOLTHA Project, hw=open_pon, sw=open_pon, serial=BBSIM_OLT_0, chassis=a0a0a0a0a00, driver=voltha, channelId=10.244.2.7:48630, managementAddress=10.244.2.7, protocol=OF_13 |
| 68 | port=16, state=enabled, type=fiber, speed=0 , adminState=enabled, portMac=08:00:00:00:00:10, portName=BBSM00000001-1 |
| 69 | port=17, state=disabled, type=fiber, speed=0 , adminState=enabled, portMac=08:00:00:00:00:11, portName=BBSM00000001-2 |
| 70 | port=18, state=disabled, type=fiber, speed=0 , adminState=enabled, portMac=08:00:00:00:00:12, portName=BBSM00000001-3 |
| 71 | port=19, state=disabled, type=fiber, speed=0 , adminState=enabled, portMac=08:00:00:00:00:13, portName=BBSM00000001-4 |
| 72 | port=1048576, state=enabled, type=fiber, speed=0 , adminState=enabled, portMac=0a:0a:0a:0a:0a:00, portName=nni-1048576 |
| 73 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 74 | |
| 75 | Developing changes on a virtual pod |
| 76 | ----------------------------------- |
| 77 | |
| 78 | We assume you already have downloaded the git repository you want to modify and |
| 79 | your IDE is correctly set up. |
| 80 | |
| 81 | In this tutorial we are going to use ``voltha-go`` as an example. |
| 82 | |
| 83 | Make the required changes in the ``voltha-go`` repository (the process |
| 84 | is the same for all the VOLTHA repositories) to the code and build the |
| 85 | docker images and push them on your private dockerhub account: |
| 86 | |
| 87 | .. code:: bash |
| 88 | |
| 89 | $ DOCKER_REGISTRY="matteoscandolo/" DOCKER_TAG="dev" make docker-build |
| 90 | |
| 91 | Then push them to your docker hub account: |
| 92 | |
| 93 | .. code:: bash |
| 94 | |
| 95 | $ DOCKER_REGISTRY="matteoscandolo/" DOCKER_TAG="dev" make docker-push |
| 96 | |
| 97 | Deploy your changes on kind-voltha |
| 98 | ---------------------------------- |
| 99 | |
| 100 | Create a copy of the `minimal-values.yaml` file: |
| 101 | |
| 102 | .. code:: bash |
| 103 | |
| 104 | $ cp minimal-values.yaml dev-values.yaml |
| 105 | |
| 106 | And edit that file so that it contains the appropriate values for the images you want to try, |
| 107 | for example uncomment and change these two lines (mind the indentation): |
| 108 | |
| 109 | .. code:: yaml |
| 110 | |
| 111 | images: |
| 112 | ro_core: |
| 113 | repository: matteoscandolo/voltha-ro-core |
| 114 | tag: dev |
| 115 | rw_core: |
| 116 | repository: matteoscandolo/voltha-rw-core |
| 117 | tag: dev |
| 118 | |
| 119 | Then redeploy `kind-voltha` using that the edited value file: |
| 120 | |
| 121 | .. code:: bash |
| 122 | |
| 123 | $ DEPLOY_K8S=no ./voltha down && DEPLOY_K8S=no EXTRA_HELM_FLAGS="-f dev-values.yaml" ./voltha up |
Andrea Campanella | 61fd666 | 2020-07-27 16:56:55 +0200 | [diff] [blame^] | 124 | |
| 125 | Create Kubernetes Cluster |
| 126 | ------------------------- |
| 127 | |
| 128 | Kind provides a command line control tool to easily create Kubernetes |
| 129 | clusters using just a basic Docker environment. The following commands |
| 130 | will create the desired deployment of Kubernetes and then configure your |
| 131 | local copy of ``kubectl`` to connect to this cluster. |
| 132 | |
| 133 | .. code:: bash |
| 134 | |
| 135 | kind create cluster --name=voltha-$TYPE --config $TYPE-cluster.cfg |
| 136 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 137 | kubectl cluster-info |
| 138 | |
| 139 | Initialize Helm |
| 140 | --------------- |
| 141 | |
| 142 | Helm provide a capability to install and manage Kubernetes applications. |
| 143 | VOLTHA’s default deployment mechanism utilized Helm. Before Helm can be |
| 144 | used to deploy VOLTHA it must be initialized and the repositories that |
| 145 | container the artifacts required to deploy VOLTHA must be added to Helm. |
| 146 | |
| 147 | .. code:: bash |
| 148 | |
| 149 | # Initialize Helm and add the required chart repositories |
| 150 | helm init |
| 151 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com |
| 152 | helm repo add stable https://kubernetes-charts.storage.googleapis.com |
| 153 | helm repo add onf https://charts.opencord.org |
| 154 | helm repo update |
| 155 | |
| 156 | # Create and k8s service account so that Helm can create pods |
| 157 | kubectl create serviceaccount --namespace kube-system tiller |
| 158 | kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 159 | kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' |
| 160 | |
| 161 | From this point follow the :ref:`physical VOLTHA POD installation instructions |
| 162 | <installation_steps>`. Come back here once done. |