From 3563a844f53f20a85737d9a602551d8b76cce172 Mon Sep 17 00:00:00 2001 From: Andrew Hsia Date: Thu, 28 Oct 2021 13:22:18 -0400 Subject: [PATCH] Initial Version of Helm Chart for OpenDaylight Signed-off-by: Andrew Hsia Change-Id: I606aef322b463ee357dcd6c83679c97cba2b478b --- helm/README.md | 195 ++++++++++++++++++ helm/opendaylight/.helmignore | 22 ++ helm/opendaylight/Chart.yaml | 34 +++ helm/opendaylight/templates/NOTES.txt | 33 +++ helm/opendaylight/templates/_helpers.tpl | 73 +++++++ helm/opendaylight/templates/configmap.yaml | 58 ++++++ helm/opendaylight/templates/hpa.yaml | 39 ++++ helm/opendaylight/templates/ingress.yaml | 72 +++++++ helm/opendaylight/templates/service.yaml | 28 +++ .../templates/serviceaccount.yaml | 23 +++ helm/opendaylight/templates/statefulset.yaml | 110 ++++++++++ helm/opendaylight/values.yaml | 117 +++++++++++ 12 files changed, 804 insertions(+) create mode 100644 helm/README.md create mode 100644 helm/opendaylight/.helmignore create mode 100644 helm/opendaylight/Chart.yaml create mode 100644 helm/opendaylight/templates/NOTES.txt create mode 100644 helm/opendaylight/templates/_helpers.tpl create mode 100644 helm/opendaylight/templates/configmap.yaml create mode 100644 helm/opendaylight/templates/hpa.yaml create mode 100644 helm/opendaylight/templates/ingress.yaml create mode 100644 helm/opendaylight/templates/service.yaml create mode 100644 helm/opendaylight/templates/serviceaccount.yaml create mode 100644 helm/opendaylight/templates/statefulset.yaml create mode 100644 helm/opendaylight/values.yaml diff --git a/helm/README.md b/helm/README.md new file mode 100644 index 0000000..0a28a87 --- /dev/null +++ b/helm/README.md @@ -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 - <=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 index 0000000..11486e8 --- /dev/null +++ b/helm/opendaylight/templates/service.yaml @@ -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 index 0000000..f37d8cf --- /dev/null +++ b/helm/opendaylight/templates/serviceaccount.yaml @@ -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 index 0000000..1dc3fd7 --- /dev/null +++ b/helm/opendaylight/templates/statefulset.yaml @@ -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 index 0000000..a12c000 --- /dev/null +++ b/helm/opendaylight/values.yaml @@ -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: {} -- 2.36.6