Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose 6653 port on each node through NodePort to allow OF Master/Standby connection #201

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea/
build/release
build/_output
.DS_Store
2 changes: 1 addition & 1 deletion onos-classic/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
apiVersion: v1
name: onos-classic
version: 0.1.7
version: 0.1.8
kubeVersion: ">=1.10.0"
appVersion: 2.2.4
description: ONOS cluster
Expand Down
42 changes: 24 additions & 18 deletions onos-classic/templates/nodeports.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
---
{{- if .Values.onosOfPort }}
{{- if .Values.onosApiPort }}
apiVersion: v1
kind: Service
metadata:
name: onos-of
name: onos-api
spec:
type: NodePort
ports:
- name: onos-of
port: 6653
nodePort: {{ .Values.onosOfPort }}
- name: onos-api
port: 8181
nodePort: {{ .Values.onosApiPort }}
selector:
app: {{ template "fullname" . }}
{{- end}}
{{- end}}
---
{{- if .Values.onosApiPort }}
{{- if .Values.onosSshPort }}
apiVersion: v1
kind: Service
metadata:
name: onos-api
name: onos-ssh
spec:
type: NodePort
ports:
- name: onos-api
port: 8181
nodePort: {{ .Values.onosApiPort }}
- name: onos-ssh
port: 8101
nodePort: {{ .Values.onosSshPort }}
selector:
app: {{ template "fullname" . }}
{{- end}}
{{- end}}

# workaround for . not working, see
# https://github.com/helm/helm/issues/1311
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really even that . doesn't work. It actually does work as intended. This is just a limitation of variable scopes in Go templates. It does make for some pretty messy workarounds. We probably won't get anything out of tracking the issue...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but since it took me a little to understand what was going on I still think it's worth tracking, also to show people why I have done something like that and to help if in the future something similar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep it took me a while to understand how it worked too. It can be pretty frustrating.

{{- if .Values.exposeNodePorts }}
{{- $root := . -}}
{{ range $k, $index := until (atoi (quote .Values.replicas) | default 3) }}
---
{{- if .Values.onosSshPort }}
apiVersion: v1
kind: Service
metadata:
name: onos-ssh
name: onos-of-{{ $index }}
spec:
type: NodePort
ports:
- name: onos-ssh
port: 8101
nodePort: {{ .Values.onosSshPort }}
- name: onos-of-{{ $index }}
port: 6653
nodePort: {{ add $index 31653 }}
selector:
app: {{ template "fullname" . }}
statefulset.kubernetes.io/pod-name: onos-onos-classic-{{ $index }}
{{ end }}
{{- end}}
9 changes: 5 additions & 4 deletions onos-classic/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ metadata:
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
{{- with .Values.ports }}
ports:
{{- range . }}
- name: {{ .name }}
port: {{ .port }}
protocol: {{ .protocol | default "TCP" | quote }}
- name: {{ .name }}
port: {{ .port }}
protocol: {{ .protocol | default "TCP" | quote }}
{{- end }}
{{- end }}
# ONOS and Atomix need to be able to talk to each other for ONOS to become ready
publishNotReadyAddresses: true
clusterIP: None
selector:
app: {{ template "fullname" . }}

2 changes: 2 additions & 0 deletions onos-classic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ resources:
cpu: 0.5
memory: 512Mi

exposeNodePorts: false
charlesmcchan marked this conversation as resolved.
Show resolved Hide resolved

ports:
- name: openflow
port: 6653
Expand Down