blob: a20563cc52b562c7359037428cf9a62e0b6e7c8b [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
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080025Create Kubernetes Cluster
26-------------------------
27
28Kind provides a command line control tool to easily create Kubernetes
Zack Williamsc6460c22019-12-18 14:54:43 -070029clusters using just a basic Docker environment. The following commands
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080030will create the desired deployment of Kubernetes and then configure your
31local 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
39Initialize Helm
40---------------
41
Zack Williamsc6460c22019-12-18 14:54:43 -070042Helm provide a capability to install and manage Kubernetes applications.
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080043VOLTHAs default deployment mechanism utilized Helm. Before Helm can be
44used to deploy VOLTHA it must be initialized and the repositories that
45container 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 Williamsc6460c22019-12-18 14:54:43 -070061From this point follow the :ref:`physical VOLTHA POD installation instructions
62<installation_steps>`. Come back here once done.
Matteo Scandolo1f5530b2019-12-17 10:12:31 -080063
64Install BBSIM (Broad Band OLT/ONU Simulator)
65--------------------------------------------
66
67BBSIM provides a simulation of a BB device. It can be useful for
68testing.
69
70.. code:: bash
71
72 helm install -f minimal-values.yaml --namespace voltha --name bbsim onf/bbsim
73
74Create 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
81Enable BBSIM Device
82^^^^^^^^^^^^^^^^^^^
83
84.. code:: bash
85
Zack Williamsc6460c22019-12-18 14:54:43 -070086 voltctl device enable $(voltctl device list --filter Type~openolt -q)
Zack Williams16042b62020-03-29 22:03:16 -070087
88
89Developing changes on a virtual pod
90-----------------------------------
91
92We assume you already have downloaded the git repository you want to modify and
93your IDE is correctly set up.
94
95In this tutorial we are going to use ``voltha-go`` as an example.
96
97Make the required changes in the ``voltha-go`` repository (the process
98is the same for all the VOLTHA repositories) to the code and build the
99docker 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
105Then push them to your docker hub account:
106
107.. code:: bash
108
109 $ DOCKER_REGISTRY="matteoscandolo/" DOCKER_TAG="dev" make docker-push
110
111Deploy your changes on kind-voltha
112----------------------------------
113
114Create a copy of the `minimal-values.yaml` file:
115
116.. code:: bash
117
118 $ cp minimal-values.yaml dev-values.yaml
119
120And edit that file so that it contains the appropriate values for the images you want to try,
121for 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
133Then 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