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