├── .gitignore ├── LICENSE ├── README.md ├── charts ├── mininet │ ├── .helmignore │ ├── Chart.yaml │ ├── templates │ │ ├── _helpers.tpl │ │ ├── pod.yaml │ │ └── service.yaml │ └── values.yaml └── onos │ ├── .helmignore │ ├── Chart.yaml │ ├── README.md │ ├── requirements.yaml │ ├── templates │ ├── _helpers.tpl │ ├── autoscaler.yaml │ ├── configmap-init.yaml │ ├── configmap-probe.yaml │ ├── deployment.yaml │ └── service.yaml │ └── values.yaml └── docker └── mininet ├── Dockerfile └── scripts └── start-mininet /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ONOS Kubernetes 2 | 3 | This project provides a canonical Kubernetes deployment for [ONOS] 1.14 and beyond. The goal of this project is to provide one click deployment of a configurable ONOS+Atomix+Mininet cluster. 4 | 5 | ## Pod Configuration 6 | 7 | To install the ONOS Helm chart, download [Helm] and run `helm install`: 8 | 9 | ``` 10 | helm install charts/onos 11 | ``` 12 | 13 | Atomix uses an anti-affinity policy to ensure cluster state is replicated on distinct hosts. 14 | When running the ONOS chart in Minikube, anti-affinity must be disabled since there's only a single Kubernetes worker node: 15 | 16 | ``` 17 | helm install --set atomix.podAntiAffinity.enabled=false charts/onos 18 | ``` 19 | 20 | The number of ONOS and Atomix nodes are independent of one another. To scale southbound I/O, 21 | increase the number of ONOS nodes by overriding `replicas`, and to scale data storage and fault tolerance, increase the number of Atomix nodes by overriding `atomix.replicas`: 22 | 23 | ``` 24 | helm install --set replicas=5 --set atomix.replicas=3 charts/onos 25 | ``` 26 | 27 | By default, the latest stable official ONOS and Atomix images are used. To override the images, use the `image` and `atomix.image` values: 28 | 29 | ``` 30 | helm install --set image.repository=onosproject/onos --set image.tag=1.14.1 charts/onos 31 | ``` 32 | 33 | ``` 34 | helm install --set atomix.image.tag=3.0.6 charts/onos 35 | ``` 36 | 37 | To set the resource requests for ONOS containers, override the `resources.requests` values: 38 | 39 | ``` 40 | helm install --set resources.requests.cpu=2 --set resources.requests.memory=4Gi charts/onos 41 | ``` 42 | 43 | The same goes for Atomix: 44 | 45 | ``` 46 | helm install --set atomix.resources.requests.cpu=2 --set atomix.resources.requests.memory=4Gi charts/onos 47 | ``` 48 | 49 | To set the Atomix persistence configuration, override `atomix.persistence` values: 50 | 51 | ``` 52 | helm install --set atomix.persistence.size=2Gi --set atomix.persistence.storageClass=local-storage charts/onos 53 | ``` 54 | 55 | We strongly recommend using the `local-storage` storage class. 56 | 57 | ### Application Configuration 58 | 59 | To activate ONOS applications at startup, override the `apps` value: 60 | 61 | ``` 62 | helm install --set apps={openflow, mcast} charts/onos 63 | ``` 64 | 65 | To customize the Atomix configuration, override `atomix.config` and provide 66 | a custom configuration in either JSON or HOCON format: 67 | 68 | ``` 69 | helm install --set atomix.config="partitionGroups.raft {type: raft, partitions: 7}" charts/onos 70 | ``` 71 | 72 | To change the heap size for either ONOS or Atomix, override `heap` or `atomix.heap` respectively: 73 | 74 | ``` 75 | helm install --set heap=4G charts/onos 76 | ``` 77 | 78 | ### Upgrading Atomix 79 | 80 | Helm does not support upgrades of dependency charts. Thus, to upgrade the Atomix cluster you must manually patch the Atomix StatefulSet. First, install the ONOS chart: 81 | 82 | ``` 83 | helm install --set atomix.image.tag=3.0.5 charts/onos 84 | ``` 85 | 86 | Once the chart is ready, patch the Atomix image to upgrade Atomix: 87 | 88 | ``` 89 | kubectl patch statefulset iced-bison-atomix --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "atomix/atomix:3.0.6"}]' 90 | ``` 91 | 92 | The Atomix pod disruption budget ensures only a single Atomix node will be down at any given time. Availability for the ONOS cluster will be maintained throughout the upgrade. 93 | 94 | [ONOS]: https://onosproject.org 95 | [Helm]: https://helm.sh 96 | -------------------------------------------------------------------------------- /charts/mininet/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /charts/mininet/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: mininet 3 | version: 0.1.0 4 | kubeVersion: ">=1.10.0" 5 | appVersion: "2.2.2" 6 | description: A single Mininet node 7 | -------------------------------------------------------------------------------- /charts/mininet/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | */}} 13 | {{- define "fullname" -}} 14 | {{- $name := default .Chart.Name .Values.nameOverride -}} 15 | {{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} 16 | {{- end -}} -------------------------------------------------------------------------------- /charts/mininet/templates/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: {{ template "fullname" . }} 5 | labels: 6 | app: {{ template "fullname" . }} 7 | release: {{ .Release.Name }} 8 | heritage: {{ .Release.Service }} 9 | spec: 10 | containers: 11 | - name: {{ .Chart.Name }} 12 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 13 | imagePullPolicy: {{ .Values.image.pullPolicy }} 14 | ports: 15 | - name: openflow-legacy 16 | containerPort: 6633 17 | - name: openflow 18 | containerPort: 6653 19 | - name: ovsdb 20 | containerPort: 6640 21 | env: 22 | - name: CONTROLLER_SERVICE 23 | value: {{ .Values.controller.service }} 24 | - name: CONTROLLER_REPLICAS 25 | value: {{ default "1" .Values.controller.replicas | quote }} 26 | - name: MININET_TOPO 27 | value: {{ default "linear,4" .Values.mininet.topo | quote }} 28 | - name: MININET_SWITCH 29 | value: {{ default "openvswitch" .Values.mininet.switch | quote }} 30 | command: 31 | - sh 32 | - -c 33 | - "./start-mininet \ 34 | --service=$CONTROLLER_SERVICE \ 35 | --replicas=$CONTROLLER_REPLICAS \ 36 | --topo=$MININET_TOPO \ 37 | --switch=$MININET_SWITCH" 38 | readinessProbe: 39 | tcpSocket: 40 | port: openflow 41 | initialDelaySeconds: 5 42 | periodSeconds: 10 43 | livenessProbe: 44 | tcpSocket: 45 | port: openflow 46 | initialDelaySeconds: 5 47 | periodSeconds: 10 48 | {{- if .Values.image.pullSecrets }} 49 | imagePullSecrets: 50 | {{- range .Values.image.pullSecrets }} 51 | - name: {{ . | quote }} 52 | {{- end }} 53 | {{- end }} 54 | -------------------------------------------------------------------------------- /charts/mininet/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ template "fullname" . }} 5 | labels: 6 | app: {{ template "fullname" . }} 7 | release: {{ .Release.Name }} 8 | heritage: {{ .Release.Service }} 9 | spec: 10 | type: ClusterIP 11 | ports: 12 | - name: openflow-legacy 13 | port: 6633 14 | - name: openflow 15 | port: 6653 16 | - name: ovsdb 17 | port: 6640 18 | selector: 19 | app: {{ template "fullname" . }} 20 | release: {{ .Release.Name }} 21 | -------------------------------------------------------------------------------- /charts/mininet/values.yaml: -------------------------------------------------------------------------------- 1 | nameOverride: "" 2 | 3 | image: 4 | repository: onos/mininet-kubernetes 5 | tag: 2.2.2 6 | pullPolicy: IfNotPresent 7 | pullSecrets: [] 8 | 9 | mininet: 10 | topo: "linear,4" 11 | switch: openvswitch 12 | 13 | controller: 14 | service: onos 15 | replicas: 3 16 | -------------------------------------------------------------------------------- /charts/onos/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /charts/onos/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: onos 3 | version: 0.1.0 4 | kubeVersion: ">=1.10.0" 5 | appVersion: 1.15.0-SNAPSHOT 6 | description: ONOS cluster 7 | keywords: 8 | - onos 9 | - sdn 10 | - networking 11 | home: http://onosproject.org 12 | icon: https://github.com/opennetworkinglab/onos/blob/master/tools/package/maven-plugin/src/main/resources/org/onosproject/maven/icon.png?raw=true 13 | maintainers: 14 | - name: Jordan Halterman 15 | email: jordan@opennetworking.org 16 | -------------------------------------------------------------------------------- /charts/onos/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opennetworkinglab/onos-kubernetes/bc0581be7b83a259f5f739d4b9517701124f6c36/charts/onos/README.md -------------------------------------------------------------------------------- /charts/onos/requirements.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: atomix 3 | version: 0.1.0 4 | repository: file://../../../atomix-k8s -------------------------------------------------------------------------------- /charts/onos/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 60 chars because some Kubernetes name fields are limited to 63 (by the DNS naming spec). 12 | */}} 13 | {{- define "fullname" -}} 14 | {{- $name := default .Chart.Name .Values.nameOverride -}} 15 | {{- printf "%s-%s" .Release.Name $name | trunc 60 | trimSuffix "-" -}} 16 | {{- end -}} 17 | 18 | {{- define "atomix.fullname" -}} 19 | {{- printf "%s-%s" .Release.Name "atomix" | trunc 59 | trimSuffix "-" -}} 20 | {{- end -}} 21 | -------------------------------------------------------------------------------- /charts/onos/templates/autoscaler.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ template "fullname" . }} 6 | spec: 7 | scaleTargetRef: 8 | apiVersion: apps/v1 9 | kind: Deployment 10 | name: {{ template "fullname" . }} 11 | minReplicas: {{ .Values.autoscaling.minReplicas }} 12 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 13 | metrics: 14 | - type: Resource 15 | resource: 16 | name: cpu 17 | targetAverageUtilization: 50 18 | {{- end }} -------------------------------------------------------------------------------- /charts/onos/templates/configmap-init.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ template "fullname" . }}-init-scripts 5 | labels: 6 | app: {{ template "fullname" . }} 7 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" 8 | release: "{{ .Release.Name }}" 9 | heritage: "{{ .Release.Service }}" 10 | data: 11 | configure-onos.sh: | 12 | #!/usr/bin/env bash 13 | 14 | apt-get update > /dev/null 2>&1 15 | apt-get -y install dnsutils > /dev/null 2>&1 16 | 17 | USER=`whoami` 18 | HOST=`hostname -s` 19 | DOMAIN=`hostname -d` 20 | CONFIG_DIR="/root/onos/config" 21 | CONFIG_FILE="$CONFIG_DIR/cluster.json" 22 | HEAP=2G 23 | 24 | function print_usage() { 25 | echo "\ 26 | Usage: start-onos [OPTIONS] 27 | Starts an ONOS node based on the supplied options. 28 | --service The name of the Atomix service to which to connect. 29 | --replicas The number of Atomix nodes to which to connect. The default value is 1. 30 | --heap The maximum amount of heap to use. The format is the 31 | same as that used for the Xmx and Xms parameters to the 32 | JVM. e.g. --heap=2G. The default is 2G. 33 | " 34 | } 35 | 36 | function print_config() { 37 | echo "{" 38 | print_name 39 | print_node 40 | print_storage 41 | echo "}" 42 | } 43 | 44 | function print_name() { 45 | echo " \"name\": \"atomix\"," 46 | } 47 | 48 | function print_node() { 49 | echo " \"node\": {" 50 | echo " \"id\": \"$HOST\"," 51 | echo " \"host\": \"$HOST\"," 52 | echo " \"port\": 9876" 53 | echo " }," 54 | } 55 | 56 | function print_storage() { 57 | echo " \"storage\": [" 58 | for (( i=1; i<=$ATOMIX_REPLICAS; i++ )) 59 | do 60 | if [ $i -eq $ATOMIX_REPLICAS ]; then 61 | echo " {" 62 | echo " \"id\": \"$ATOMIX_SERVICE-$((i))\"," 63 | echo " \"host\": \"$ATOMIX_SERVICE-$((i-1)).$ATOMIX_SERVICE-hs\"," 64 | echo " \"port\": 5679" 65 | echo " }" 66 | else 67 | echo " {" 68 | echo " \"id\": \"$ATOMIX_SERVICE-$((i))\"," 69 | echo " \"host\": \"$ATOMIX_SERVICE-$((i-1)).$ATOMIX_SERVICE-hs\"," 70 | echo " \"port\": 5679" 71 | echo " }," 72 | fi 73 | done 74 | echo " ]" 75 | } 76 | 77 | ATOMIX_SERVICE=$1 78 | ATOMIX_REPLICAS=$2 79 | 80 | until nslookup "$ATOMIX_SERVICE-api" > /dev/null 2>&1; do sleep 2; done; 81 | 82 | print_config 83 | -------------------------------------------------------------------------------- /charts/onos/templates/configmap-probe.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ template "fullname" . }}-probe-scripts 5 | labels: 6 | app: {{ template "fullname" . }} 7 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" 8 | release: "{{ .Release.Name }}" 9 | heritage: "{{ .Release.Service }}" 10 | data: 11 | check-onos-status: | 12 | #!/bin/bash 13 | set -e 14 | host=$(hostname -s) 15 | config=$(curl -s http://$host:8181/onos/v1/cluster/$host --user onos:rocks) 16 | echo $config 17 | printf '%q' $config | grep -q "READY" -------------------------------------------------------------------------------- /charts/onos/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ template "fullname" . }} 5 | labels: 6 | app: {{ template "fullname" . }} 7 | spec: 8 | replicas: {{ .Values.replicas }} 9 | selector: 10 | matchLabels: 11 | app: {{ template "fullname" . }} 12 | template: 13 | metadata: 14 | labels: 15 | app: {{ template "fullname" . }} 16 | spec: 17 | initContainers: 18 | - name: {{ .Chart.Name }}-init 19 | image: tutum/dnsutils:latest 20 | env: 21 | - name: ATOMIX_SERVICE 22 | value: {{ template "atomix.fullname" . }} 23 | - name: ATOMIX_REPLICAS 24 | value: {{ .Values.atomix.replicas | quote }} 25 | command: 26 | - sh 27 | - -c 28 | - "/scripts/configure-onos.sh $ATOMIX_SERVICE $ATOMIX_REPLICAS > /config/cluster.json && touch /config/active" 29 | volumeMounts: 30 | - name: init-scripts 31 | mountPath: /scripts 32 | - name: config 33 | mountPath: /config 34 | containers: 35 | - name: {{ .Chart.Name }} 36 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 37 | imagePullPolicy: {{ .Values.image.pullPolicy }} 38 | resources: 39 | requests: 40 | memory: {{ .Values.resources.requests.memory }} 41 | cpu: {{ .Values.resources.requests.cpu }} 42 | env: 43 | - name: JAVA_OPTS 44 | value: -Xmx{{ default "2G" .Values.heap }} 45 | ports: 46 | - name: openflow 47 | containerPort: 6653 48 | - name: ovsdb 49 | containerPort: 6640 50 | - name: east-west 51 | containerPort: 9876 52 | - name: cli 53 | containerPort: 8101 54 | - name: ui 55 | containerPort: 8181 56 | readinessProbe: 57 | exec: 58 | command: 59 | - sh 60 | - -c 61 | - /root/onos/bin/check-onos-status 62 | initialDelaySeconds: 30 63 | periodSeconds: 15 64 | failureThreshold: 10 65 | livenessProbe: 66 | exec: 67 | command: 68 | - sh 69 | - -c 70 | - /root/onos/bin/check-onos-status 71 | initialDelaySeconds: 300 72 | periodSeconds: 15 73 | timeoutSeconds: 5 74 | volumeMounts: 75 | - name: probe-scripts 76 | mountPath: /root/onos/bin/check-onos-status 77 | subPath: check-onos-status 78 | - name: config 79 | mountPath: /root/onos/config/cluster.json 80 | subPath: cluster.json 81 | {{- range .Values.apps }} 82 | - name: config 83 | mountPath: /root/onos/apps/{{ . }}/active 84 | subPath: active 85 | {{- end }} 86 | {{- if .Values.image.pullSecrets }} 87 | imagePullSecrets: 88 | {{- range .Values.image.pullSecrets }} 89 | - name: {{ . | quote }} 90 | {{- end }} 91 | {{- end }} 92 | volumes: 93 | - name: init-scripts 94 | configMap: 95 | name: {{ template "fullname" . }}-init-scripts 96 | defaultMode: 0744 97 | - name: probe-scripts 98 | configMap: 99 | name: {{ template "fullname" . }}-probe-scripts 100 | defaultMode: 0744 101 | - name: config 102 | emptyDir: {} -------------------------------------------------------------------------------- /charts/onos/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ template "fullname" . }}-hs 5 | labels: 6 | app: {{ template "fullname" . }} 7 | chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" 8 | release: "{{ .Release.Name }}" 9 | heritage: "{{ .Release.Service }}" 10 | spec: 11 | ports: 12 | - name: openflow 13 | port: 6653 14 | - name: ovsdb 15 | port: 6640 16 | - name: east-west 17 | port: 9876 18 | - name: cli 19 | port: 8101 20 | - name: ui 21 | port: 8181 22 | clusterIP: None 23 | selector: 24 | app: {{ template "fullname" . }} -------------------------------------------------------------------------------- /charts/onos/values.yaml: -------------------------------------------------------------------------------- 1 | nameOverride: "" 2 | 3 | image: 4 | repository: onosproject/onos 5 | tag: 1.14.0 6 | pullPolicy: IfNotPresent 7 | pullSecrets: [] 8 | 9 | replicas: 3 10 | heap: 4G 11 | apps: 12 | - org.onosproject.hostprovider 13 | - org.onosproject.openflow 14 | - org.onosproject.mcast 15 | 16 | atomix: 17 | replicas: 3 18 | 19 | autoscaling: 20 | enabled: false 21 | minReplicas: 2 22 | maxReplicas: 10 23 | 24 | resources: 25 | requests: 26 | cpu: 0.5 27 | memory: 512Mi -------------------------------------------------------------------------------- /docker/mininet/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | USER root 4 | WORKDIR /root 5 | 6 | RUN apt-get update && apt-get install -y --no-install-recommends \ 7 | curl \ 8 | iproute2 \ 9 | iputils-ping \ 10 | iptables \ 11 | mininet \ 12 | net-tools \ 13 | tcpdump \ 14 | vim \ 15 | x11-xserver-utils \ 16 | xterm 17 | 18 | COPY scripts /root 19 | 20 | EXPOSE 6633 6653 6640 21 | -------------------------------------------------------------------------------- /docker/mininet/scripts/start-mininet: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2018 Open Networking Foundation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | # 17 | # Usage: start-mininet [OPTIONS] 18 | # Starts a Mininet node based on the supplied options. 19 | # --service The name of the ONOS service to which to connect. 20 | # --replicas The number of ONOS nodes to which to connect. The default value is 1. 21 | 22 | 23 | USER=`whoami` 24 | HOST=`hostname -s` 25 | DOMAIN=`hostname -d` 26 | CONF_DIR="/src/onos/config" 27 | HEAP=2G 28 | 29 | function print_usage() { 30 | echo "\ 31 | Usage: start-onos [OPTIONS] 32 | Starts Mininet based on the supplied options. 33 | --service The name of the ONOS service to which to connect. 34 | --replicas The number of ONOS nodes to which to connect. The default value is 1. 35 | --topo The Mininet topology. 36 | " 37 | } 38 | 39 | optspec=":hv-:" 40 | while getopts "$optspec" optchar; do 41 | 42 | case "${optchar}" in 43 | -) 44 | case "${OPTARG}" in 45 | service=*) 46 | ONOS_SERVICE=${OPTARG##*=} 47 | ;; 48 | replicas=*) 49 | ONOS_REPLICAS=${OPTARG##*=} 50 | ;; 51 | *) 52 | break 53 | ;; 54 | esac;; 55 | h) 56 | print_usage 57 | exit 58 | ;; 59 | *) 60 | break 61 | ;; 62 | esac 63 | done 64 | 65 | shift $((OPTIND-1)) 66 | 67 | controllers="" 68 | for (( i=1; i<=$ONOS_REPLICAS; i++ )) 69 | do 70 | controllers+=" --controller remote,ip=$ONOS_SERVICE-$((i-1))" 71 | done 72 | 73 | echo "mn $controllers $@" 74 | 75 | service openvswitch-switch start 76 | ovs-vsctl set-manager ptcp:6640 77 | 78 | mn $controllers "$@" 79 | --------------------------------------------------------------------------------