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 | |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 25 | Create Kubernetes Cluster |
| 26 | ------------------------- |
| 27 | |
| 28 | Kind provides a command line control tool to easily create Kubernetes |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 29 | clusters using just a basic Docker environment. The following commands |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 30 | will create the desired deployment of Kubernetes and then configure your |
| 31 | local copy of ``kubectl`` to connect to this cluster. |
| 32 | |
| 33 | .. code:: bash |
| 34 | |
| 35 | kind create cluster --name=voltha-$TYPE --config $TYPE-cluster.cfg |
| 36 | export KUBECONFIG="$(kind get kubeconfig-path --name="voltha-$TYPE")" |
| 37 | kubectl cluster-info |
| 38 | |
| 39 | Initialize Helm |
| 40 | --------------- |
| 41 | |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 42 | Helm provide a capability to install and manage Kubernetes applications. |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 43 | VOLTHA’s default deployment mechanism utilized Helm. Before Helm can be |
| 44 | used to deploy VOLTHA it must be initialized and the repositories that |
| 45 | container the artifacts required to deploy VOLTHA must be added to Helm. |
| 46 | |
| 47 | .. code:: bash |
| 48 | |
| 49 | # Initialize Helm and add the required chart repositories |
| 50 | helm init |
| 51 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com |
| 52 | helm repo add stable https://kubernetes-charts.storage.googleapis.com |
| 53 | helm repo add onf https://charts.opencord.org |
| 54 | helm repo update |
| 55 | |
| 56 | # Create and k8s service account so that Helm can create pods |
| 57 | kubectl create serviceaccount --namespace kube-system tiller |
| 58 | kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 59 | kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}' |
| 60 | |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 61 | From this point follow the :ref:`physical VOLTHA POD installation instructions |
| 62 | <installation_steps>`. Come back here once done. |
Matteo Scandolo | 1f5530b | 2019-12-17 10:12:31 -0800 | [diff] [blame] | 63 | |
| 64 | Install BBSIM (Broad Band OLT/ONU Simulator) |
| 65 | -------------------------------------------- |
| 66 | |
| 67 | BBSIM provides a simulation of a BB device. It can be useful for |
| 68 | testing. |
| 69 | |
| 70 | .. code:: bash |
| 71 | |
| 72 | helm install -f minimal-values.yaml --namespace voltha --name bbsim onf/bbsim |
| 73 | |
| 74 | Create BBSIM Device |
| 75 | ^^^^^^^^^^^^^^^^^^^ |
| 76 | |
| 77 | .. code:: bash |
| 78 | |
| 79 | voltctl device create -t openolt -H $(kubectl get -n voltha service/bbsim -o go-template='{{.spec.clusterIP}}'):50060 |
| 80 | |
| 81 | Enable BBSIM Device |
| 82 | ^^^^^^^^^^^^^^^^^^^ |
| 83 | |
| 84 | .. code:: bash |
| 85 | |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 86 | voltctl device enable $(voltctl device list --filter Type~openolt -q) |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 87 | |
| 88 | |
| 89 | Developing changes on a virtual pod |
| 90 | ----------------------------------- |
| 91 | |
| 92 | We assume you already have downloaded the git repository you want to modify and |
| 93 | your IDE is correctly set up. |
| 94 | |
| 95 | In this tutorial we are going to use ``voltha-go`` as an example. |
| 96 | |
| 97 | Make the required changes in the ``voltha-go`` repository (the process |
| 98 | is the same for all the VOLTHA repositories) to the code and build the |
| 99 | docker images and push them on your private dockerhub account: |
| 100 | |
| 101 | .. code:: bash |
| 102 | |
| 103 | $ DOCKER_REGISTRY="matteoscandolo/" DOCKER_TAG="dev" make docker-build |
| 104 | |
| 105 | Then push them to your docker hub account: |
| 106 | |
| 107 | .. code:: bash |
| 108 | |
| 109 | $ DOCKER_REGISTRY="matteoscandolo/" DOCKER_TAG="dev" make docker-push |
| 110 | |
| 111 | Deploy your changes on kind-voltha |
| 112 | ---------------------------------- |
| 113 | |
| 114 | Create a copy of the `minimal-values.yaml` file: |
| 115 | |
| 116 | .. code:: bash |
| 117 | |
| 118 | $ cp minimal-values.yaml dev-values.yaml |
| 119 | |
| 120 | And edit that file so that it contains the appropriate values for the images you want to try, |
| 121 | for example uncomment and change these two lines (mind the indentation): |
| 122 | |
| 123 | .. code:: yaml |
| 124 | |
| 125 | images: |
| 126 | ro_core: |
| 127 | repository: matteoscandolo/voltha-ro-core |
| 128 | tag: dev |
| 129 | rw_core: |
| 130 | repository: matteoscandolo/voltha-rw-core |
| 131 | tag: dev |
| 132 | |
| 133 | Then redeploy `kind-voltha` using that the edited value file: |
| 134 | |
| 135 | .. code:: bash |
| 136 | |
| 137 | $ DEPLOY_K8S=no ./voltha down && DEPLOY_K8S=no EXTRA_HELM_FLAGS="-f dev-values.yaml" ./voltha up |