[WIP] Tuning parameters to make end-to-end testing work.

Please don't merge this patch, it's not ready yet.
When it's ready, this message will be gone.

- Disble Hugepage to avoid ngic-dp crash.
- Adding debug parameter in accelleran.

Change-Id: I98edeaef82d2bae9759bd1a4157694a709c3fbe8
diff --git a/mcord/cni-config/01-cni-service-account.yaml b/mcord/cni-config/01-cni-service-account.yaml
index 022e248..762cb77 100644
--- a/mcord/cni-config/01-cni-service-account.yaml
+++ b/mcord/cni-config/01-cni-service-account.yaml
@@ -29,22 +29,40 @@
   - '*'
   verbs:
   - '*'
+#- apiGroups: [""]
+#  resources: ["pods"]
+#  verbs: ["get"]
+#- apiGroups: [""]
+#  resources: ["pods/status"]
+#  verbs: ["update"]
+#- apiGroups: ["k8s.cni.cncf.io"]
+#  resources: ["*"]
+#  verbs: ["get"]
 ---
 apiVersion: v1
 kind: ServiceAccount
 metadata:
-  name: sriov-dp
+  name: multus-sa
   namespace: kube-system
 ---
-kind: ClusterRoleBinding
-apiVersion: rbac.authorization.k8s.io/v1beta1
+apiVersion: v1
+kind: Secret
 metadata:
-  name: sriov-dp
+  name: multus-sa-secret
+  namespace: kube-system
+  annotations:
+    kubernetes.io/service-account.name: multus-sa
+type: kubernetes.io/service-account-token
+---
+kind: ClusterRoleBinding
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+  name: multus-rb
 roleRef:
   apiGroup: rbac.authorization.k8s.io
   kind: ClusterRole
   name: pod-networks-operator
 subjects:
 - kind: ServiceAccount
-  name: sriov-dp
+  name: multus-sa
   namespace: kube-system
diff --git a/mcord/cni-config/04-sriov-device-plugin-configmap.yaml b/mcord/cni-config/04-sriov-device-plugin-configmap.yaml
index 086b9e7..3069f96 100644
--- a/mcord/cni-config/04-sriov-device-plugin-configmap.yaml
+++ b/mcord/cni-config/04-sriov-device-plugin-configmap.yaml
@@ -17,7 +17,7 @@
 kind: ConfigMap
 apiVersion: v1
 metadata:
-  name: multus-certs
+  name: multus-scripts
   namespace: kube-system
 data:
   install-certs.sh: |
@@ -29,7 +29,7 @@
     KUBE_CA_FILE=$SERVICE_ACCOUNT_PATH/ca.crt
     TLS_CFG="certificate-authority-data: $(cat $KUBE_CA_FILE | base64 | tr -d '\n')"
     SERVICEACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token)
-    #cat > /host/etc/cni/net.d/multus-kubeconfig <<EOF
+    cat > /host/etc/cni/net.d/multus-kubeconfig <<EOF
     # Kubeconfig file for Multus CNI plugin.
     apiVersion: v1
     kind: Config
@@ -49,6 +49,23 @@
         user: multus
     current-context: multus-context
     EOF
+  install-multus-conf.sh: |
+    # copied from https://github.com/intel/multus-cni/blob/master/images/entrypoint.sh
+    rm -f /host/etc/cni/net.d/00-multus.conf
+    MASTER_PLUGIN="$(ls /host/etc/cni/net.d | grep -E '\.conf(list)?$' | head -1)"
+    MASTER_PLUGIN_JSON="$(cat /host/etc/cni/net.d/$MASTER_PLUGIN)"
+    cat > /host/etc/cni/net.d/00-multus.conf <<EOF
+    {
+      "name": "multus-cni-network",
+      "type": "multus",
+      "logFile": "/var/log/multus.log",
+      "logLevel": "debug",
+      "kubeconfig": "/etc/cni/net.d/multus-kubeconfig",
+      "delegates": [
+                   $MASTER_PLUGIN_JSON
+      ]
+    }
+    EOF
 ---
 kind: ConfigMap
 apiVersion: v1
@@ -68,27 +85,3 @@
         }
       ]
     }
----
-apiVersion: v1
-kind: ConfigMap
-metadata:
-  name: multus-conf
-  namespace: kube-system
-data:
-  01-cni-conf.json: |
-    {
-      "name": "multus-cni-network",
-      "type": "multus",
-      "logLevel": "debug",
-      "logFile": "/tmp/multus.log",
-      "kubeconfig": "/etc/cni/net.d/multus-kubeconfig",
-      "delegates": [
-        {
-          "name": "cbr0",
-          "type": "flannel",
-          "delegate": {
-            "isDefaultGateway": true
-          }
-        }
-      ]
-    }
diff --git a/mcord/cni-config/05-sriov-device-plugin.yaml b/mcord/cni-config/05-sriov-device-plugin.yaml
index 9b358a9..6dbb38e 100644
--- a/mcord/cni-config/05-sriov-device-plugin.yaml
+++ b/mcord/cni-config/05-sriov-device-plugin.yaml
@@ -28,13 +28,16 @@
       labels:
         name: sriov-device-plugin
     spec:
-      serviceAccountName: sriov-dp
+      serviceAccountName: multus-sa
       initContainers:
-      - name: init-sriov-dp
+      - name: multus
         image: ngick8stesting/aio-cni:k8s-1.13
         command: [ "bash", "-c" ]
         args:
         - cp /tmp/cni/bin/{multus,sriov,centralip} /host/opt/cni/bin/;
+          /tmp/multus/install-multus-conf.sh;
+          /tmp/multus/install-certs.sh;
+          systemctl stop kubelet;
           echo "Restarting crio/containerd, kubelet";
           systemctl daemon-reload;
           systemctl restart containerd;
@@ -45,9 +48,9 @@
           mountPath: /host/usr/bin
         - name: cni-bin
           mountPath: /host/opt/cni/bin
-        - name: multus-cm
-          mountPath: /tmp/etc/cni/net.d
-        - name: multus-certs
+        - name: multus-sa
+          mountPath: /var/run/secrets/multus/serviceaccount
+        - name: multus-scripts
           mountPath: /tmp/multus
         - name: cni-conf
           mountPath: /host/etc/cni/net.d
@@ -59,10 +62,10 @@
       - name: sriov-device-plugin
         image: ngick8stesting/aio-cni:k8s-1.13
         imagePullPolicy: IfNotPresent
-        command: [ "/bin/sh", "-c" ]
+        command: [ "sh", "-c" ]
         args:
         - /usr/bin/sriovdp --logtostderr -v 10;
-          echo "exit status $?";
+          sleep infinity;
         volumeMounts:
         - mountPath: /var/lib/kubelet/device-plugins/
           name: devicesock
@@ -83,13 +86,13 @@
       - name: cni-bin
         hostPath:
           path: /opt/cni/bin
-      - name: multus-cm
-        configMap:
-          name: multus-conf
-      - name: multus-certs
+      - name: multus-sa
+        secret:
+          secretName: multus-sa-secret
+      - name: multus-scripts
         configMap:
           defaultMode: 511
-          name: multus-certs
+          name: multus-scripts
       - name: cni-conf
         hostPath:
           path: /etc/cni/net.d
diff --git a/mcord/mcord-bbu/Chart.yaml b/mcord/mcord-bbu/Chart.yaml
index 3ffd9b6..9c73673 100644
--- a/mcord/mcord-bbu/Chart.yaml
+++ b/mcord/mcord-bbu/Chart.yaml
@@ -18,4 +18,4 @@
 appVersion: "1.0"
 description: A Helm chart for MCORD BBU Services
 name: mcord-bbu
-version: 0.1.0
+version: 0.1.1
diff --git a/mcord/mcord-bbu/templates/accelleran.yaml b/mcord/mcord-bbu/templates/accelleran.yaml
index 6acd07c..c6d0467 100644
--- a/mcord/mcord-bbu/templates/accelleran.yaml
+++ b/mcord/mcord-bbu/templates/accelleran.yaml
@@ -105,15 +105,16 @@
             - IPC_LOCK
       - name: bbu
         image: {{ .Values.accelleran.images.bbu }}
-        imagePullPolicy: IfNotPresent
+        imagePullPolicy: Always
         env:
-          - name: HOST_IP
-            value: {{ .Values.accelleran_hostname }}
+          - name: MME_IP
+            value: {{ .Values.mme_hostname }}
         stdin: true
         tty: true
         command: ["sh", "-c"]
         args:
-        - sqlite3 /mnt/app/datastoreRemRw.db "update FapServiceFapControlLteGateway_S1SigLinkServerListList set S1SigLinkServerList='{{ .Values.accelleran_hostname }}';";
+        - sqlite3 /mnt/app/datastore.db "insert into enbSctpSocketInterface ('interfaceName') values ('eth0');";
+          sqlite3 /mnt/app/datastore.db "update logging set severity=7 where id=25;"
           sleep 10;
           /l3/l3start;
         volumeMounts:
diff --git a/mcord/mcord-bbu/values.yaml b/mcord/mcord-bbu/values.yaml
index af47222..d7afd75 100644
--- a/mcord/mcord-bbu/values.yaml
+++ b/mcord/mcord-bbu/values.yaml
@@ -19,6 +19,7 @@
 # Declare variables to be passed into your templates.
 
 accelleran_hostname: "accelleran"
+mme_hostname: "mme"
 
 accelleran:
   images:
diff --git a/mcord/mcord-control-plane/Chart.yaml b/mcord/mcord-control-plane/Chart.yaml
index e4ad5cc..20886a4 100644
--- a/mcord/mcord-control-plane/Chart.yaml
+++ b/mcord/mcord-control-plane/Chart.yaml
@@ -18,4 +18,4 @@
 appVersion: "1.0"
 description: A Helm chart for MCORD Control Plane Services
 name: mcord-control-plane
-version: 0.1.4
+version: 0.1.5
diff --git a/mcord/mcord-control-plane/templates/hss.yaml b/mcord/mcord-control-plane/templates/hss.yaml
index dd3fb88..69dd53a 100644
--- a/mcord/mcord-control-plane/templates/hss.yaml
+++ b/mcord/mcord-control-plane/templates/hss.yaml
@@ -51,13 +51,13 @@
         image: {{ .Values.hss.images.init }}
         command: ["bash", "-xc"]
         args:
-        - until nslookup {{ .Values.hssdb_hostname }}; do echo waiting for cassandra; sleep 2; done;
-          sleep 10;
-          cqlsh --file /scripts/oai_db.cql cassandra;
-          /scripts/data_provisioning_users.sh 302720100000421 1122334456 apn1 6226194254742F2D67145153602F7C8D 1 cassandra {{ .Values.mme_hostname }} {{ .Values.mme_hostname }};
-          cqlsh -e "use vhss; update users_imsi set opc='D6CAF10C337FD65AC31A18EBACBF5BF9' where imsi='302720100000421';" cassandra;
-          /scripts/data_provisioning_mme.sh 1 19136246000 mme-0.{{ .Values.mme_hostname }}.{{ .Values.namespace }}.svc.cluster.local {{ .Values.mme_hostname }}.{{ .Values.namespace }}.svc.cluster.local 1 cassandra;
-          /scripts/data_provisioning_mme.sh 1 19136246000 smsrouter.test3gpp.net test3gpp.net 0  cassandra;
+        - until nslookup {{ .Values.hssdb_hostname }}; do echo "waiting for cassandra domain name resolve."; sleep 2; done;
+          until cqlsh -e "show version" {{ .Values.hssdb_hostname }}; do echo "waiting for cassandra database ready."; sleep 2; done;
+          until cqlsh --file /scripts/oai_db.cql {{ .Values.hssdb_hostname }}; do echo "Writing data into database failed. Retrying ..."; sleep 2; done;
+          /scripts/data_provisioning_users.sh 302720100000421 1122334456 apn1 6226194254742F2D67145153602F7C8D 1 {{ .Values.hssdb_hostname }} {{ .Values.mme_hostname }} {{ .Values.mme_hostname }};
+          cqlsh -e "use vhss; update users_imsi set opc='D6CAF10C337FD65AC31A18EBACBF5BF9' where imsi='302720100000421';" {{ .Values.hssdb_hostname }};
+          /scripts/data_provisioning_mme.sh 1 19136246000 mme-0.{{ .Values.mme_hostname }}.{{ .Values.namespace }}.svc.cluster.local {{ .Values.mme_hostname }}.{{ .Values.namespace }}.svc.cluster.local 1 {{ .Values.hssdb_hostname }};
+          /scripts/data_provisioning_mme.sh 1 19136246000 smsrouter.test3gpp.net test3gpp.net 0 {{ .Values.hssdb_hostname }};
       containers:
       - name: hss
         image: {{ .Values.hss.images.hss }}
diff --git a/mcord/mcord-control-plane/templates/mme.yaml b/mcord/mcord-control-plane/templates/mme.yaml
index ad28806..8b4eef9 100644
--- a/mcord/mcord-control-plane/templates/mme.yaml
+++ b/mcord/mcord-control-plane/templates/mme.yaml
@@ -29,7 +29,7 @@
     protocol: UDP
   - name: s1ap
     port: {{ .Values.mme.ports.s1ap }}
-    protocol: TCP
+    protocol: SCTP
   - name: s6a
     port: {{ .Values.mme.ports.s6a }}
     protocol: TCP
@@ -76,7 +76,7 @@
               fieldRef:
                 fieldPath: status.podIP
           - name: ENB_S1AP_IP
-            value: {{ .Values.mme.enb_s1ap_ip }}
+            value: {{ .Values.accelleran_hostname }}
           - name: ENB_S1AP_PORT
             value: "{{ .Values.mme.ports.s1ap }}"   #ng4t uses 32767
           - name: CONNECT_PEER
diff --git a/mcord/mcord-control-plane/values.yaml b/mcord/mcord-control-plane/values.yaml
index 5e3ef5b..6b20a1f 100644
--- a/mcord/mcord-control-plane/values.yaml
+++ b/mcord/mcord-control-plane/values.yaml
@@ -26,6 +26,7 @@
 # Need to get SPGW-U interface IP address to put at here
 spgwu_s1u_ip: "119.0.0.45"
 spgwu_port: 20
+accelleran_hostname: "10.233.65.254"
 
 hss:
   # TODO: init UE's IMEI to DB?
diff --git a/mcord/mcord-data-plane/Chart.yaml b/mcord/mcord-data-plane/Chart.yaml
index 2c685ea..d0e6d20 100644
--- a/mcord/mcord-data-plane/Chart.yaml
+++ b/mcord/mcord-data-plane/Chart.yaml
@@ -18,4 +18,4 @@
 appVersion: "1.0"
 description: A Helm chart for MCORD Data Plane Services
 name: mcord-data-plane
-version: 0.2.0
+version: 0.2.1
diff --git a/mcord/mcord-data-plane/templates/dp.yaml b/mcord/mcord-data-plane/templates/dp.yaml
index 53137ce..e7844dc 100644
--- a/mcord/mcord-data-plane/templates/dp.yaml
+++ b/mcord/mcord-data-plane/templates/dp.yaml
@@ -80,7 +80,7 @@
               divisor: 1Mi
         command: [ "bash",  "-xc"]
         args:
-        - ifconfig lo down;
+        - ip addr show;
           ifconfig;
           . /opt/ngic/config/dp_config.cfg;
           ./ngic_dataplane $EAL_ARGS -- $APP_ARGS
diff --git a/mcord/mcord-data-plane/values.yaml b/mcord/mcord-data-plane/values.yaml
index 62adfb3..f54ede3 100644
--- a/mcord/mcord-data-plane/values.yaml
+++ b/mcord/mcord-data-plane/values.yaml
@@ -19,6 +19,8 @@
 # Declare variables to be passed into your templates.
 
 redis_hostname: "redis"
+accelleran_hostname: "accelleran"
+mme_hostname: "mme"
 controlplane_hostname: "ngic-cp"
 controlplane_port: 21
 
@@ -31,12 +33,12 @@
   replicas: 1
   resources:
     cpu: 8
-    mem: "1Gi"
+    mem: "8Gi"
     hugepage: "8Gi"
   config:
     rtr_sgi_ip: "13.1.1.254"
     sgi_mask: "255.255.255.0"
     dpdk_enabled: false
-    hugepage_enabled: true
+    hugepage_enabled: false
 
 namespace: epc