Initial Version of Helm Chart for OpenDaylight 07/98207/1
authorAndrew Hsia <andrew.hsia@verizonwireless.com>
Thu, 28 Oct 2021 17:22:18 +0000 (13:22 -0400)
committerAndrew Hsia <andrew.hsia@verizonwireless.com>
Thu, 28 Oct 2021 17:22:18 +0000 (13:22 -0400)
Signed-off-by: Andrew Hsia <andrew.hsia@verizonwireless.com>
Change-Id: I606aef322b463ee357dcd6c83679c97cba2b478b

12 files changed:
helm/README.md [new file with mode: 0644]
helm/opendaylight/.helmignore [new file with mode: 0644]
helm/opendaylight/Chart.yaml [new file with mode: 0644]
helm/opendaylight/templates/NOTES.txt [new file with mode: 0644]
helm/opendaylight/templates/_helpers.tpl [new file with mode: 0644]
helm/opendaylight/templates/configmap.yaml [new file with mode: 0644]
helm/opendaylight/templates/hpa.yaml [new file with mode: 0644]
helm/opendaylight/templates/ingress.yaml [new file with mode: 0644]
helm/opendaylight/templates/service.yaml [new file with mode: 0644]
helm/opendaylight/templates/serviceaccount.yaml [new file with mode: 0644]
helm/opendaylight/templates/statefulset.yaml [new file with mode: 0644]
helm/opendaylight/values.yaml [new file with mode: 0644]

diff --git a/helm/README.md b/helm/README.md
new file mode 100644 (file)
index 0000000..0a28a87
--- /dev/null
@@ -0,0 +1,195 @@
+# OpenDaylight Helm Chart
+
+OpenDaylight Helm Chart is a packaging for kubernetes deployment.
+The composition of this chart consist of statefulset that can scale to multiple standalone instances of OpenDaylight Pods.
+
+## Customization
+
+Before deploying, there are several areas can be customized.
+Either by editing values.yaml or using --set flag pass-in with the helm command 
+e.g
+```
+helm install sdnc opendaylight --set persistence.enabled=true
+```
+
+### Java Memory and GC settings
+
+In values.yaml, java max memory and GC settings can be customized
+
+```
+  javaOptions:
+    maxGCPauseMillis: 100
+    parallelGCThreads : 3
+    numberGCLogFiles: 10
+    minMemory: 512m
+    maxMemory: 2048m
+    gcLogOptions: ""
+```
+
+### OpenDaylight Features
+
+In values.yaml, one can customize features to be included during instance startup.  By default, only restconf is included.
+
+```
+config:
+  odl_basedir: /opt/opendaylight
+  #features: odl-restconf,odl-restconf-all,odl-bgpcep-pcep,odl-bgpcep-bgp,odl-bgpcep-bgp-config-example,odl-bgpcep-bmp,odl-bgpcep-bmp-config-example,odl-jolokiaa,odl-daexim-all
+  features: odl-restconf,odl-restconf-all
+```
+
+### Container Image Version
+
+The pull policy can be customized in values.yaml.
+
+```
+image:
+  repository: nexus3.opendaylight.org:10001/opendaylight/opendaylight
+  pullPolicy: IfNotPresent
+```
+
+The container image version is located in Chart.yaml
+```
+appVersion: "14.2.0"
+```
+so the combined image from above two files will be:
+`nexus3.opendaylight.org:10001/opendaylight:14.2.0`
+
+### Persistent Volume
+
+By default the OpenDaylight Pod uses ephemeral volume.
+The data stored at /data will lost after container restarts.
+
+To support data persistence, it requires kubernetes persistent storageClass.  Depend on your environment, there are many implementation of storage plugin.  Following is example of define a storageClass on OpenEBS storage plugin.
+
+create storageClass vg01-lvmpv for OpenEBS on volume group vg01
+```
+kubectl apply -f - <<EOD
+apiVersion: storage.k8s.io/v1
+kind: StorageClass
+metadata:
+  name: vg01-lvmpv
+allowVolumeExpansion: true
+parameters:
+   volgroup: "vg01"
+provisioner: local.csi.openebs.io
+EOD
+```
+
+Once storageClass is defined, adjust the values.yaml
+- enabled = true
+- size = `adjustable based on number of devices supported`
+- storageClass = `defined storageClass`
+```
+persistence:
+  enabled: false
+  accessMode: ReadWriteOnce
+  size: 5Gi
+  mountPath: /data
+  storageClass: vg01-lvmpv
+  volName: odlvol
+```
+
+### Dry run
+the generated definition can be inspected before actual deployment using --dry-run flag
+```
+helm install sdnc opendaylight --dry-run 
+```
+
+## Deploy
+
+Following will deploy a release called sdnc to default namespace with persistent volume
+```
+helm install sdnc opendaylight --set persistence.enabled=true
+```
+
+if need to deploy on different namespace (sdntest)
+```
+helm install sdnc opendaylight --set persistence.enabled=true --create-namespace -n sdntest
+```
+
+
+the output:
+```
+NAME: sdnc
+LAST DEPLOYED: Thu Oct 28 12:58:19 2021
+NAMESPACE: default
+STATUS: deployed
+REVISION: 1
+TEST SUITE: None
+NOTES:
+1. Get the application URL by running these commands:
+  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=opendaylight,app.kubernetes.io/instance=sdnc" -o jsonpath="{.items[0].metadata.name}")
+  export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+  echo "Visit http://127.0.0.1:8080 to use your application"
+  kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
+```
+
+List deployed charts
+```
+helm list
+
+NAME   NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
+sdnc   default         1               2021-10-28 12:58:19.548011 -0400 EDT    deployed        opendaylight-0.1.0      14.2.0
+```
+
+Inspect Pods, by default only one instance of OpenDaylight Pods
+```
+kubectl get po
+
+NAME                  READY   STATUS    RESTARTS   AGE
+sdnc-opendaylight-0   1/1     Running   0          52s
+
+
+kubectl get pvc
+
+NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
+odlvol-sdnc-opendaylight-0   Bound    pvc-5d7ece71-088e-4dd6-9fda-67a928a51495   5Gi        RWO            vg01-lvmpv     77s
+```
+
+scale out to 3 standalone opendaylight instance
+```
+kubectl edit statefulset sdnc-opendaylight
+```
+
+update replica from 1 to 3
+```
+spec:
+  podManagementPolicy: OrderedReady
+  replicas: 1
+```
+
+```
+ kubectl get po
+NAME                  READY   STATUS    RESTARTS   AGE
+sdnc-opendaylight-0   1/1     Running   0          6m37s
+sdnc-opendaylight-1   1/1     Running   0          3m2s
+sdnc-opendaylight-2   1/1     Running   0          2m20s
+```
+
+uninstall sdnc release
+```
+helm uninstall sdnc
+
+release "sdnc" uninstalled
+```
+
+the persistent volumes still preserved and can be reuse for next deployment
+```
+kubectl get pvc
+
+NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
+odlvol-sdnc-opendaylight-0   Bound    pvc-5d7ece71-088e-4dd6-9fda-67a928a51495   5Gi        RWO            vg01-lvmpv     10m
+odlvol-sdnc-opendaylight-1   Bound    pvc-df825859-5970-453b-90df-22eb754a15f8   5Gi        RWO            vg01-lvmpv     6m47s
+odlvol-sdnc-opendaylight-2   Bound    pvc-e074f280-4393-4b96-b34d-5d6ab22bdf77   5Gi        RWO            vg01-lvmpv     6m5s
+```
+
+### Access RESTCONF Swagger
+base on the notes output from heml install, set up port forwarding to first instance
+```
+  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=opendaylight,app.kubernetes.io/instance=sdnc" -o jsonpath="{.items[0].metadata.name}")
+  export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+  echo "Visit http://127.0.0.1:8080 to use your application"
+  kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
+```
+
+from browser, go to `http://127.0.0.1:8080/apidoc/explorer/index.html` then login with `admin/admin` 
\ No newline at end of file
diff --git a/helm/opendaylight/.helmignore b/helm/opendaylight/.helmignore
new file mode 100644 (file)
index 0000000..7ddbad7
--- /dev/null
@@ -0,0 +1,22 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+components/
diff --git a/helm/opendaylight/Chart.yaml b/helm/opendaylight/Chart.yaml
new file mode 100644 (file)
index 0000000..fcef5ab
--- /dev/null
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+apiVersion: v2
+name: opendaylight
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "14.2.0"
diff --git a/helm/opendaylight/templates/NOTES.txt b/helm/opendaylight/templates/NOTES.txt
new file mode 100644 (file)
index 0000000..4e6a831
--- /dev/null
@@ -0,0 +1,33 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+  {{- range .paths }}
+  http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+  {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "opendaylight.fullname" . }})
+  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+  echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+           You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "opendaylight.fullname" . }}'
+  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "opendaylight.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+  echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "opendaylight.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+  export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+  echo "Visit http://127.0.0.1:8080 to use your application"
+  kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/helm/opendaylight/templates/_helpers.tpl b/helm/opendaylight/templates/_helpers.tpl
new file mode 100644 (file)
index 0000000..c697e81
--- /dev/null
@@ -0,0 +1,73 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "opendaylight.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "opendaylight.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "opendaylight.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "opendaylight.labels" -}}
+helm.sh/chart: {{ include "opendaylight.chart" . }}
+{{ include "opendaylight.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "opendaylight.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "opendaylight.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "opendaylight.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "opendaylight.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/helm/opendaylight/templates/configmap.yaml b/helm/opendaylight/templates/configmap.yaml
new file mode 100644 (file)
index 0000000..3d26566
--- /dev/null
@@ -0,0 +1,58 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "opendaylight.fullname" . }}
+data:
+  startodl.sh: |
+    #!/bin/bash
+    mountpath="{{ .Values.persistence.mountPath }}"
+    BASEDIR="{{ .Values.config.odl_basedir }}"
+    odl_prefix="/opt/opendaylight"
+
+    if [[ ! -d "$mountpath/snapshots" ]];then
+      mkdir -p $mountpath/snapshots
+    fi
+
+    if [[ ! -d "$mountpath/data" ]];then
+      mkdir -p $mountpath/data
+    fi
+
+    if [[ ! -d "$mountpath/segmented-journal" ]];then
+      mkdir -p $mountpath/segmented-journal
+    fi
+
+    if [[ ! -d "$mountpath/daexim" ]];then
+      mkdir -p $mountpath/daexim
+    fi
+
+    if [[ ! -L "$odl_prefix/snapshots" ]];then
+      rm -rf $odl_prefix/snapshots && ln -s $mountpath/snapshots $odl_prefix/snapshots
+    fi
+
+    if [[ ! -L "$odl_prefix/data" ]];then
+      rm -rf $odl_prefix/data && ln -s $mountpath/data $odl_prefix/data
+    fi
+
+    if [[ ! -L "$odl_prefix/segmented-journal" ]];then
+      rm -rf $odl_prefix/segmented-journal && ln -s $mountpath/segmented-journal $odl_prefix/segmented-journal
+    fi
+
+    if [[ ! -L "$odl_prefix/daexim" ]];then
+      rm -rf $odl_prefix/daexim && ln -s $mountpath/daexim $odl_prefix/daexim
+    fi
+
+    sed -i "s/\(featuresBoot= \|featuresBoot = \)/featuresBoot = ${FEATURES},/g" ${BASEDIR}/etc/org.apache.karaf.features.cfg
+    cat ${BASEDIR}/etc/org.apache.karaf.features.cfg
+    ${BASEDIR}/bin/karaf run
diff --git a/helm/opendaylight/templates/hpa.yaml b/helm/opendaylight/templates/hpa.yaml
new file mode 100644 (file)
index 0000000..99eefa0
--- /dev/null
@@ -0,0 +1,39 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+  name: {{ include "opendaylight.fullname" . }}
+  labels:
+    {{- include "opendaylight.labels" . | nindent 4 }}
+spec:
+  scaleTargetRef:
+    apiVersion: apps/v1
+    kind: Deployment
+    name: {{ include "opendaylight.fullname" . }}
+  minReplicas: {{ .Values.autoscaling.minReplicas }}
+  maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+  metrics:
+    {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: cpu
+        targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+    {{- end }}
+    {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    - type: Resource
+      resource:
+        name: memory
+        targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+    {{- end }}
+{{- end }}
diff --git a/helm/opendaylight/templates/ingress.yaml b/helm/opendaylight/templates/ingress.yaml
new file mode 100644 (file)
index 0000000..58a414b
--- /dev/null
@@ -0,0 +1,72 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "opendaylight.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+  {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+  {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+  {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+  name: {{ $fullName }}
+  labels:
+    {{- include "opendaylight.labels" . | nindent 4 }}
+  {{- with .Values.ingress.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+spec:
+  {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+  ingressClassName: {{ .Values.ingress.className }}
+  {{- end }}
+  {{- if .Values.ingress.tls }}
+  tls:
+    {{- range .Values.ingress.tls }}
+    - hosts:
+        {{- range .hosts }}
+        - {{ . | quote }}
+        {{- end }}
+      secretName: {{ .secretName }}
+    {{- end }}
+  {{- end }}
+  rules:
+    {{- range .Values.ingress.hosts }}
+    - host: {{ .host | quote }}
+      http:
+        paths:
+          {{- range .paths }}
+          - path: {{ .path }}
+            {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+            pathType: {{ .pathType }}
+            {{- end }}
+            backend:
+              {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+              service:
+                name: {{ $fullName }}
+                port:
+                  number: {{ $svcPort }}
+              {{- else }}
+              serviceName: {{ $fullName }}
+              servicePort: {{ $svcPort }}
+              {{- end }}
+          {{- end }}
+    {{- end }}
+{{- end }}
diff --git a/helm/opendaylight/templates/service.yaml b/helm/opendaylight/templates/service.yaml
new file mode 100644 (file)
index 0000000..11486e8
--- /dev/null
@@ -0,0 +1,28 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ include "opendaylight.fullname" . }}
+  labels:
+    {{- include "opendaylight.labels" . | nindent 4 }}
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    - port: {{ .Values.service.port }}
+      targetPort: http
+      protocol: TCP
+      name: http
+  clusterIP: None
+  selector:
+    {{- include "opendaylight.selectorLabels" . | nindent 4 }}
diff --git a/helm/opendaylight/templates/serviceaccount.yaml b/helm/opendaylight/templates/serviceaccount.yaml
new file mode 100644 (file)
index 0000000..f37d8cf
--- /dev/null
@@ -0,0 +1,23 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: {{ include "opendaylight.serviceAccountName" . }}
+  labels:
+    {{- include "opendaylight.labels" . | nindent 4 }}
+  {{- with .Values.serviceAccount.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+{{- end }}
diff --git a/helm/opendaylight/templates/statefulset.yaml b/helm/opendaylight/templates/statefulset.yaml
new file mode 100644 (file)
index 0000000..1dc3fd7
--- /dev/null
@@ -0,0 +1,110 @@
+{{/*
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+*/}}
+
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: {{ include "opendaylight.fullname" . }}
+spec:
+  {{- if not .Values.autoscaling.enabled }}
+  replicas: {{ .Values.replicaCount }}
+  {{- end }}
+  serviceName: {{ include "opendaylight.fullname" . }}
+  selector:
+    matchLabels:
+      {{- include "opendaylight.selectorLabels" . | nindent 6 }}
+  template:
+    metadata:
+      {{- with .Values.podAnnotations }}
+      annotations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      labels:
+        {{- include "opendaylight.selectorLabels" . | nindent 8 }}
+    spec:
+      {{- with .Values.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      serviceAccountName: {{ include "opendaylight.serviceAccountName" . }}
+      securityContext:
+        {{- toYaml .Values.podSecurityContext | nindent 8 }}
+      initContainers:
+        - name: updatevolperm
+          image: busybox
+          command: ['chown','8181','/data']
+          volumeMounts:
+          - name: {{ .Values.persistence.volName }}
+            mountPath: {{ .Values.persistence.mountPath }}
+      containers:
+        - name: {{ .Chart.Name }}
+          securityContext:
+            {{- toYaml .Values.securityContext | nindent 12 }}
+          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+          command: ['bash','-c','bash -x /scripts/startodl.sh']
+          env:
+          - name: FEATURES
+            value: "{{ .Values.config.features }}"
+          - name: JAVA_HOME
+            value: "{{ .Values.config.javaHome}}"
+          - name: JAVA_OPTS
+            value: "-Xms{{.Values.config.javaOptions.minMemory}} -Xmx{{.Values.config.javaOptions.maxMemory}}"
+          - name: EXTRA_JAVA_OPTS
+            value: "-XX:+UseG1GC -XX:MaxGCPauseMillis={{.Values.config.javaOptions.maxGCPauseMillis}} -XX:ParallelGCThreads={{.Values.config.javaOptions.parallelGCThreads}} -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication {{.Values.config.javaOptions.gcLogOptions}}"
+          ports:
+            - name: http
+              containerPort: {{ .Values.service.port }}
+              protocol: TCP
+          readinessProbe:
+            tcpSocket:
+              port: {{ .Values.service.port }}
+            initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
+            periodSeconds: {{ .Values.readiness.periodSeconds }}
+          resources:
+            {{- toYaml .Values.resources | nindent 12 }}
+          volumeMounts:
+          - name: {{ .Values.persistence.volName }}
+            mountPath: {{ .Values.persistence.mountPath }}
+          - name: scripts
+            mountPath: /scripts
+      {{- with .Values.nodeSelector }}
+      nodeSelector:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.tolerations }}
+      tolerations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      volumes:
+        - name: scripts
+          configMap:
+            name: {{ include "opendaylight.fullname" . }}
+  {{ if not .Values.persistence.enabled }}
+        - name: {{ .Values.persistence.volName }} 
+          emptyDir: {}
+  {{ else }}
+  volumeClaimTemplates:
+  - metadata:
+      name: {{ .Values.persistence.volName }} 
+    spec:
+      accessModes:
+      - {{ .Values.persistence.accessMode }}
+      storageClassName: {{ .Values.persistence.storageClass }}
+      resources:
+        requests:
+          storage: {{ .Values.persistence.size }}
+  {{- end }}
diff --git a/helm/opendaylight/values.yaml b/helm/opendaylight/values.yaml
new file mode 100644 (file)
index 0000000..a12c000
--- /dev/null
@@ -0,0 +1,117 @@
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2021 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+# Default values for opendaylight.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+  repository: nexus3.opendaylight.org:10001/opendaylight/opendaylight
+  pullPolicy: IfNotPresent
+  # Overrides the image tag whose default is the chart appVersion.
+  tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+config:
+  odl_basedir: /opt/opendaylight
+  #features: odl-restconf,odl-restconf-all,odl-bgpcep-pcep,odl-bgpcep-bgp,odl-bgpcep-bgp-config-example,odl-bgpcep-bmp,odl-bgpcep-bmp-config-example,odl-jolokiaa,odl-daexim-all
+  features: odl-restconf,odl-restconf-all
+  javaHome: /opt/openjdk-11/
+  javaOptions:
+    maxGCPauseMillis: 100
+    parallelGCThreads : 3
+    numberGCLogFiles: 10
+    minMemory: 512m
+    maxMemory: 2048m
+    gcLogOptions: ""
+
+serviceAccount:
+  # Specifies whether a service account should be created
+  create: true
+  # Annotations to add to the service account
+  annotations: {}
+  # The name of the service account to use.
+  # If not set and create is true, a name is generated using the fullname template
+  name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+  # fsGroup: 2000
+
+securityContext: {}
+  # capabilities:
+  #   drop:
+  #   - ALL
+  # readOnlyRootFilesystem: true
+  # runAsNonRoot: true
+  # runAsUser: 1000
+
+readiness:
+  initialDelaySeconds: 30
+  periodSeconds: 10
+
+service:
+  type: ClusterIP
+  port: 8181
+
+ingress:
+  enabled: false
+  className: ""
+  annotations: {}
+    # kubernetes.io/ingress.class: nginx
+    # kubernetes.io/tls-acme: "true"
+  hosts:
+    - host: chart-example.local
+      paths:
+        - path: /
+          pathType: ImplementationSpecific
+  tls: []
+  #  - secretName: chart-example-tls
+  #    hosts:
+  #      - chart-example.local
+
+persistence:
+  enabled: false
+  accessMode: ReadWriteOnce
+  size: 5Gi
+  mountPath: /data
+  storageClass: vg01-lvmpv
+  volName: odlvol
+
+resources: {}
+  # We usually recommend not to specify default resources and to leave this as a conscious
+  # choice for the user. This also increases chances charts run on environments with little
+  # resources, such as Minikube. If you do want to specify resources, uncomment the following
+  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+  # limits:
+  #   cpu: 100m
+  #   memory: 128Mi
+  # requests:
+  #   cpu: 100m
+  #   memory: 128Mi
+
+autoscaling:
+  enabled: true
+  minReplicas: 1
+  maxReplicas: 3
+  targetCPUUtilizationPercentage: 80
+  # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}