initial sdcore-helm-charts update
Change-Id: I91788de083b0f906ce4b32ac226f616fb2647ef9
diff --git a/5g-ran-sim/templates/NOTES.txt b/5g-ran-sim/templates/NOTES.txt
new file mode 100644
index 0000000..fe31845
--- /dev/null
+++ b/5g-ran-sim/templates/NOTES.txt
@@ -0,0 +1,9 @@
+{{- /*
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+*/ -}}
+
+Notes - Instructions to use 5g ran simulator helm charts
diff --git a/5g-ran-sim/templates/_helpers.tpl b/5g-ran-sim/templates/_helpers.tpl
new file mode 100644
index 0000000..700d36c
--- /dev/null
+++ b/5g-ran-sim/templates/_helpers.tpl
@@ -0,0 +1,115 @@
+{{- /*
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+*/ -}}
+
+{{/*
+Renders a set of standardised labels
+*/}}
+{{- define "5g-ransim-plane.metadata_labels" -}}
+{{- $application := index . 0 -}}
+{{- $context := index . 1 -}}
+release: {{ $context.Release.Name }}
+app: {{ $application }}
+{{- end -}}
+
+{{/*
+Render the given template.
+*/}}
+{{- define "5g-ransim-plane.template" -}}
+{{- $name := index . 0 -}}
+{{- $context := index . 1 -}}
+{{- $last := base $context.Template.Name }}
+{{- $wtf := $context.Template.Name | replace $last $name -}}
+{{ include $wtf $context }}
+{{- end -}}
+
+{{/*
+Render ServiceAccount, Role, and RoleBinding required for kubernetes-entrypoint.
+*/}}
+{{- define "5g-ransim-plane.service_account" -}}
+{{- $context := index . 1 -}}
+{{- $saName := index . 0 -}}
+{{- $saNamespace := $context.Release.Namespace }}
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+ labels:
+{{ tuple $saName $context | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+---
+{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
+apiVersion: rbac.authorization.k8s.io/v1
+{{- else }}
+apiVersion: rbac.authorization.k8s.io/v1beta1
+{{- end }}
+kind: RoleBinding
+metadata:
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+ labels:
+{{ tuple $saName $context | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: {{ $saName }}
+subjects:
+ - kind: ServiceAccount
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+---
+{{- if semverCompare ">=1.16-0" $context.Capabilities.KubeVersion.GitVersion }}
+apiVersion: rbac.authorization.k8s.io/v1
+{{- else }}
+apiVersion: rbac.authorization.k8s.io/v1beta1
+{{- end }}
+kind: Role
+metadata:
+ name: {{ $saName }}
+ namespace: {{ $saNamespace }}
+ labels:
+{{ tuple $saName $context | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+rules:
+ - apiGroups:
+ - ""
+ - extensions
+ - batch
+ - apps
+ verbs:
+ - get
+ - list
+ - patch
+ resources:
+ - statefulsets
+ - daemonsets
+ - jobs
+ - pods
+ - services
+ - endpoints
+ - configmaps
+{{- end -}}
+
+{{/*
+Render init container for coredump.
+*/}}
+{{- define "5g-ransim-plane.coredump_init" -}}
+{{- $pod := index . 0 -}}
+{{- $context := index . 1 -}}
+- name: {{ $pod }}-coredump-init
+ image: {{ $context.Values.images.tags.init | quote }}
+ imagePullPolicy: {{ $context.Values.images.pullPolicy }}
+ securityContext:
+ privileged: true
+ runAsUser: 0
+ command: ["bash", "-xc"]
+ args:
+ - echo '/tmp/coredump/core.%h.%e.%t' > /mnt/host-rootfs/proc/sys/kernel/core_pattern
+ volumeMounts:
+ - name: host-rootfs
+ mountPath: /mnt/host-rootfs
+{{- end -}}
diff --git a/5g-ran-sim/templates/bin/_gnbsim-run.sh.tpl b/5g-ran-sim/templates/bin/_gnbsim-run.sh.tpl
new file mode 100644
index 0000000..42e47bc
--- /dev/null
+++ b/5g-ran-sim/templates/bin/_gnbsim-run.sh.tpl
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Copyright 2020-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+set -xe
+
+{{- if .Values.config.coreDump.enabled }}
+cp /free5gc/amf/amf /tmp/coredump/
+{{- end }}
+
+#cat config files
+cd /free5gc
+cat ./config/gnb.conf
+cat /etc/hosts
+ip route add 192.168.252.0/24 via 192.168.251.1
+# Disabling checksum offloading to hardware
+ethtool -K enb tx off
+sleep infinity
diff --git a/5g-ran-sim/templates/configmap-gnbsim.yaml b/5g-ran-sim/templates/configmap-gnbsim.yaml
new file mode 100644
index 0000000..c7d5b14
--- /dev/null
+++ b/5g-ran-sim/templates/configmap-gnbsim.yaml
@@ -0,0 +1,22 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.gnbsim.deploy }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: gnbsim
+ labels:
+{{ tuple "gnbsim" . | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+data:
+ gnbsim-run.sh: |
+{{ tuple "bin/_gnbsim-run.sh.tpl" . | include "5g-ransim-plane.template" | indent 4 }}
+{{- range $key, $value := .Values.config.gnbsim.yamlCfgFiles }}
+ {{ $key }}: |
+{{ $value | indent 4 }}
+{{- end }}
+{{- end }}
diff --git a/5g-ran-sim/templates/networks.yaml b/5g-ran-sim/templates/networks.yaml
new file mode 100644
index 0000000..e716f03
--- /dev/null
+++ b/5g-ran-sim/templates/networks.yaml
@@ -0,0 +1,26 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+ # SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+---
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+ name: enb-net
+{{- if $.Values.config.gnbsim.sriov.enabled }}
+ annotations:
+ k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_vfio_access_net
+{{- end }}
+spec:
+ config: '{
+{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
+ "cniVersion": "0.3.1",
+{{- end }}
+ "type": {{ .Values.config.gnbsim.cniPlugin | quote }},
+ "ipam": {
+ "type": {{ .Values.config.gnbsim.ipam | quote }}
+ }
+ }'
+---
diff --git a/5g-ran-sim/templates/service-gnbsim.yaml b/5g-ran-sim/templates/service-gnbsim.yaml
new file mode 100644
index 0000000..003b625
--- /dev/null
+++ b/5g-ran-sim/templates/service-gnbsim.yaml
@@ -0,0 +1,23 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.gnbsim.deploy }}
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: gnbsim
+ labels:
+{{ tuple "gnbsim" . | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+spec:
+ type: ClusterIP
+ selector:
+{{ tuple "gnbsim" . | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+ ports:
+ - name: ngapp
+ port: {{ .Values.config.gnbsim.ngapp.port }}
+ protocol: SCTP
+{{- end }}
diff --git a/5g-ran-sim/templates/statefulset-gnbsim.yaml b/5g-ran-sim/templates/statefulset-gnbsim.yaml
new file mode 100644
index 0000000..d62293b
--- /dev/null
+++ b/5g-ran-sim/templates/statefulset-gnbsim.yaml
@@ -0,0 +1,109 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.config.gnbsim.deploy }}
+{{ tuple "gnbsim" . | include "5g-ransim-plane.service_account" }}
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: gnbsim
+ labels:
+{{ tuple "gnbsim" . | include "5g-ransim-plane.metadata_labels" | indent 4 }}
+spec:
+ replicas: 1
+ serviceName: gnbsim-headless
+ selector:
+ matchLabels:
+{{ tuple "gnbsim" . | include "5g-ransim-plane.metadata_labels" | indent 6 }}
+ template:
+ metadata:
+ labels:
+{{ tuple "gnbsim" . | include "5g-ransim-plane.metadata_labels" | indent 8 }}
+ annotations:
+ k8s.v1.cni.cncf.io/networks: '[
+ {
+ "name": "enb-net",
+ "interface": "enb",
+{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
+ "ips": [{{ .Values.config.gnbsim.gnb.ip | quote }}]
+{{- else }}
+ "ips": {{ .Values.config.gnbsim.gnb.ip | quote }}
+{{- end }}
+ }
+ ]'
+ spec:
+ {{- if .Values.nodeSelectors.enabled }}
+ nodeSelector:
+ {{ .Values.nodeSelectors.gnbsim.label }}: {{ .Values.nodeSelectors.gnbsim.value }}
+ {{- end }}
+ serviceAccountName: gnbsim
+ {{- if hasKey .Values.images "pullSecrets" }}
+ imagePullSecrets:
+{{ toYaml .Values.images.pullSecrets | indent 8 }}
+ {{- end }}
+
+ initContainers:
+ - name: wait-amf-module
+ image: {{ .Values.images.tags.init | quote }}
+ imagePullPolicy: {{ .Values.images.pullPolicy }}
+ command: ['sh', '-c', 'until nslookup amf; do echo waiting for nrf; sleep 4; done;']
+ {{- if .Values.config.coreDump.enabled }}
+{{ tuple "gnbsim" . | include "5g-ransim-plane.coredump_init" | indent 6 }}
+ {{- end }}
+ containers:
+ - name: gnbsim
+ image: {{ .Values.images.tags.gnbsim }}
+ imagePullPolicy: {{ .Values.images.pullPolicy }}
+ securityContext:
+ privileged: true
+ runAsUser: 0
+ stdin: true
+ tty: true
+ command: ["/opt/cp/scripts/gnbsim-run.sh"]
+ env:
+ - name: MEM_LIMIT
+ valueFrom:
+ resourceFieldRef:
+ containerName: gnbsim
+ resource: limits.memory
+ divisor: 1Mi
+ - name: POD_IP
+ valueFrom:
+ fieldRef:
+ fieldPath: status.podIP
+ {{- if .Values.resources.enabled }}
+ resources:
+{{ toYaml .Values.resources.gnbsim | indent 10 }}
+ {{- end }}
+ volumeMounts:
+ - name: cp-script
+ mountPath: /opt/cp/scripts/gnbsim-run.sh
+ subPath: gnbsim-run.sh
+ - name: cp-config
+ mountPath: /free5gc/config
+ {{- if .Values.config.coreDump.enabled }}
+ - name: coredump
+ mountPath: /tmp/coredump
+ {{- end }}
+ volumes:
+ - name: cp-script
+ configMap:
+ name: gnbsim
+ defaultMode: 493
+ - name: cp-config
+ configMap:
+ name: gnbsim
+ defaultMode: 420
+ {{- if .Values.config.coreDump.enabled }}
+ - name: host-rootfs
+ hostPath:
+ path: /
+ - name: coredump
+ hostPath:
+ path: {{ .Values.config.coreDump.path }}
+ {{- end }}
+{{- end }}