blob: 22f17db8642c2fd85fe089a95f506a4e6fed0f7f [file] [log] [blame]
Zack Williams16042b62020-03-29 22:03:16 -07001.. _dev_virtual:
2
3Developing code with a virtual VOLTHA POD
4=========================================
Matteo Scandolo1f5530b2019-12-17 10:12:31 -08005
6A guide to install a virtual POD. This is generally used to gain familiarity with the
Zack Williams16042b62020-03-29 22:03:16 -07007environment or for development purposes.
8
9Most of the `helm` and `voltctl` commands found in the :ref:`pod_physical` also
10apply in the virtual environment.
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080011
12Quickstart
13----------
14
15Requires:
16
17- ``docker`` and ``go`` installed on your machine
Zack Williams6ebfe062020-04-09 16:08:29 -070018- `kind-voltha <https://gerrit.opencord.org/gitweb?p=kind-voltha.git>`_ cloned
19 on your machine
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080020
21.. code:: bash
22
23 TYPE=minimal WITH_RADIUS=y CONFIG_SADIS=y ONLY_ONE=y WITH_BBSIM=y ./voltha up
24
Andrea Campanella61fd6662020-07-27 16:56:55 +020025For more information you can visit the `kind-voltha page <kind-voltha/README.md>`_.
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080026
27Install BBSIM (Broad Band OLT/ONU Simulator)
28--------------------------------------------
29
30BBSIM provides a simulation of a BB device. It can be useful for
31testing.
32
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080033Create BBSIM Device
34^^^^^^^^^^^^^^^^^^^
35
Andrea Campanella61fd6662020-07-27 16:56:55 +020036After having deployed BBSIM either through `kind-voltha` or manually `bbsim <bbsim/docs/source/index.rst>`_ you can create a similated OLT.
37
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080038.. code:: bash
39
40 voltctl device create -t openolt -H $(kubectl get -n voltha service/bbsim -o go-template='{{.spec.clusterIP}}'):50060
41
42Enable BBSIM Device
43^^^^^^^^^^^^^^^^^^^
44
45.. code:: bash
46
Zack Williamsc6460c22019-12-18 14:54:43 -070047 voltctl device enable $(voltctl device list --filter Type~openolt -q)
Zack Williams16042b62020-03-29 22:03:16 -070048
Andrea Campanella61fd6662020-07-27 16:56:55 +020049Observing the newly created device in ONOS
50------------------------------------------
51
52At this point you should be able to see a new device in ONOS.
53
54You can SSH into ONOS via
55
56.. code:: bash
57
58 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8201 karaf@localhost
59
60with password ``karaf``.
61
62Now 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 Williams16042b62020-03-29 22:03:16 -070074
75Developing changes on a virtual pod
76-----------------------------------
77
78We assume you already have downloaded the git repository you want to modify and
79your IDE is correctly set up.
80
81In this tutorial we are going to use ``voltha-go`` as an example.
82
83Make the required changes in the ``voltha-go`` repository (the process
84is the same for all the VOLTHA repositories) to the code and build the
85docker 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
91Then push them to your docker hub account:
92
93.. code:: bash
94
95 $ DOCKER_REGISTRY="matteoscandolo/" DOCKER_TAG="dev" make docker-push
96
97Deploy your changes on kind-voltha
98----------------------------------
99
100Create a copy of the `minimal-values.yaml` file:
101
102.. code:: bash
103
104 $ cp minimal-values.yaml dev-values.yaml
105
106And edit that file so that it contains the appropriate values for the images you want to try,
107for 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
119Then 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 Campanella61fd6662020-07-27 16:56:55 +0200124
125Create Kubernetes Cluster
126-------------------------
127
128Kind provides a command line control tool to easily create Kubernetes
129clusters using just a basic Docker environment. The following commands
130will create the desired deployment of Kubernetes and then configure your
131local 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
139Initialize Helm
140---------------
141
142Helm provide a capability to install and manage Kubernetes applications.
143VOLTHAs default deployment mechanism utilized Helm. Before Helm can be
144used to deploy VOLTHA it must be initialized and the repositories that
145container 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
161From this point follow the :ref:`physical VOLTHA POD installation instructions
162<installation_steps>`. Come back here once done.