Add support for Ceph based PV for chartmuseum and dashboard 41/741/6
authorZhe Huang <zhehuang@research.att.com>
Sun, 18 Aug 2019 04:10:52 +0000 (00:10 -0400)
committerZhe Huang <zhehuang@research.att.com>
Tue, 3 Sep 2019 20:27:48 +0000 (16:27 -0400)
Signed-off-by: Zhe Huang <zhehuang@research.att.com>
Change-Id: Id157c1284260c0a789faf2945a2991fcf0a1f378

15 files changed:
RECIPE_EXAMPLE/RIC_INFRA_RECIPE_EXAMPLE
bin/clean-up-aux [moved from ric-infra/15-Chartmuseum/bin/clear_data_path with 68% similarity]
ric-aux/80-Auxiliary-Functions/bin/install
ric-aux/80-Auxiliary-Functions/helm/dashboard/templates/persistentVolume.yaml
ric-aux/80-Auxiliary-Functions/helm/dashboard/templates/persistentVolumeClaim.yaml
ric-aux/80-Auxiliary-Functions/helm/dashboard/templates/storageClass.yaml [deleted file]
ric-aux/80-Auxiliary-Functions/helm/dashboard/values.yaml
ric-infra/15-Chartmuseum/bin/install
ric-infra/15-Chartmuseum/helm/chartmuseum/templates/deployment.yaml
ric-infra/15-Chartmuseum/helm/chartmuseum/templates/job-save-certs.yaml
ric-infra/15-Chartmuseum/helm/chartmuseum/templates/persistentVolume.yaml
ric-infra/15-Chartmuseum/helm/chartmuseum/templates/persistentVolumeClaim.yaml
ric-infra/15-Chartmuseum/helm/chartmuseum/templates/storageClass.yaml [deleted file]
ric-infra/15-Chartmuseum/helm/chartmuseum/values.yaml
ric-infra/45-Tiller/bin/install

index 6488385..786356e 100644 (file)
@@ -108,10 +108,13 @@ credential:
 
 
 chartmuseum:
-  repositoryOverride: "registry.hub.docker.com"
+  repositoryOverride: "docker.io"
   image:
     name: chartmuseum/chartmuseum
     tag: v0.8.2
+  job:
+    image:
+      name: alpine
+      tag: latest
 
   storagesize: 2Gi
-  datapath: /tmp/chartmuseum-data/
similarity index 68%
rename from ric-infra/15-Chartmuseum/bin/clear_data_path
rename to bin/clean-up-aux
index f7a3780..e36393b 100755 (executable)
 #   limitations under the License.                                             #
 ################################################################################
 
-OVERRIDEYAML=$1
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
-
-
-
-
-
-
-if [ -z $OVERRIDEYAML ]; then
-
-  DATAPATH=$(cat $DIR/../helm/chartmuseum/values.yaml | awk '/^.*datapath:.*/{ print $2;}')
-  
-else
-  DATAPATH=$(cat $OVERRIDEYAML | awk '/^chartmuseum:.*/{ getline; while ( match($0, / .*/) || (!$0)){  if(getline == 0){break;}; if (match($0, /^ .*datapath:.*/)){print $2}} }')
-
-
-  if [ -z $DATAPATH ]; then
-    DATAPATH=$(cat $DIR/../helm/chartmuseum/values.yaml | awk '/^.*datapath:.*/{ print $2;}')
-  fi
-
-fi
-
-  rm -rf $DATAPATH
-
-  mkdir -p $DATAPATH
-
-
-  chmod -R a+rwx $DATAPATH
+# This script clean up the PV data for aux cluster
 
+rm -rf /opt/data/dashboard-data
+rm -rf /opt/data/chartmuseum-data
index eae092c..52bf88d 100755 (executable)
@@ -59,6 +59,69 @@ else
    COMMON_OVERRIDE=$RIC_COMMON_OVERRIDE
 fi
 
+
+
+NODENAME=$(kubectl get node | awk '{print $1}')
+LABELFOUND=false
+for f in $NODENAME; do
+    LABEL=$(kubectl describe node $f | grep local-storage)
+    if [ ! -z "$LABEL" ]; then
+        LABELFOUND=true
+    fi
+done
+  
+if [ ! -z $OVERRIDEYAML ]; then
+  FOUND_STORAGECLASS=$(grep storageclass $OVERRIDEYAML)
+fi
+
+
+
+if  ! $LABELFOUND && [ -z "$FOUND_STORAGECLASS" ]; then
+    echo "***********************************************************************************************"
+    echo "*                                          ERROR!!!!!!!!!!!!!                                 *"
+    echo "***********************************************************************************************"
+    echo "* Nodes label \"local-storage=enable\" is not found in any of the cluster node.               *"
+    echo "* Please pick a node and label it using the following command.                                *"
+    echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> local-storage=enable                       *"
+    echo "***********************************************************************************************"
+
+  exit 1
+fi
+
+
+
+
+if [ -z "$FOUND_STORAGECLASS" ] && $LABELFOUND; then
+
+    DATAPATH=$(cat $DIR/../helm/dashboard/values.yaml | grep datapath | awk '{ print $2}' )
+
+
+    if [ ! -z $OVERRIDEYAML ]; then
+        DATAPATHOVERRIDE=$(cat $OVERRIDEYAML | grep datapath | awk '{ print $2}' )
+    fi
+
+    if [ ! -z "$DATAPATHOVERRIDE" ]; then
+        DATAPATH=$DATAPATHOVERRIDE
+    fi
+
+
+    echo "***********************************************************************************************"
+    echo "*                                          WARNING!!!!!!!!!!!!!                               *"
+    echo "***********************************************************************************************"
+    echo "* Chartmuseume will use local storage. Please make sure that directory                        *"
+    echo "* $DATAPATH                                                                                   *"
+    echo "* exists on the selected cluster node, and contains the proper files.                         *"
+    echo "***********************************************************************************************"
+
+
+fi
+
+
+
+
+
+
+
 RICAUX_COMPONENTS="dashboard ves message-router"
 
 echo "Deploying RIC AUX components [$RICAUX_COMPONENTS]"
index cb63ba9..01bc7b3 100644 (file)
@@ -1,4 +1,14 @@
-# Remove this persistent volume when cloud storage is available
+{{- if not .Values.dashboard.storageclass }}
+
+kind: StorageClass
+apiVersion: storage.k8s.io/v1
+metadata:
+  name: storageclass-{{ include "common.name.dashboard" . }}
+provisioner: kubernetes.io/no-provisioner
+volumeBindingMode: WaitForFirstConsumer
+
+---
+
 apiVersion: v1
 kind: PersistentVolume
 metadata:
@@ -16,7 +26,9 @@ spec:
     required:
       nodeSelectorTerms:
       - matchExpressions:
-        - key: dashboard-node
+        - key: local-storage
           operator: In
           values:
           - enable
+{{- end -}}
+
index a13dde1..c436a42 100644 (file)
@@ -5,7 +5,7 @@ metadata:
 spec:
   accessModes:
   - ReadWriteOnce
-  storageClassName: storageclass-{{ include "common.name.dashboard" . }} 
+  storageClassName: {{ .Values.dashboard.storageclass | default (printf "storageclass-%s" ( include "common.name.dashboard" . )) }}
   resources:
     requests:
       storage: {{ .Values.dashboard.storagesize }}
diff --git a/ric-aux/80-Auxiliary-Functions/helm/dashboard/templates/storageClass.yaml b/ric-aux/80-Auxiliary-Functions/helm/dashboard/templates/storageClass.yaml
deleted file mode 100644 (file)
index eb1fb94..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: StorageClass
-apiVersion: storage.k8s.io/v1
-metadata:
-  name: storageclass-{{ include "common.name.dashboard" . }}
-provisioner: kubernetes.io/no-provisioner
-volumeBindingMode: WaitForFirstConsumer
index a4992a0..d263ce7 100644 (file)
@@ -34,12 +34,14 @@ dashboard:
   # The keys listed below MUST be configured in each deployment;
   # this list does not include all keys recognized by the app.
 
+  # Specify a storage class to bypass the local storage definition.
+  # storageclass:
   # persist user details as JSON to a persistent volume
   storagesize: 1Mi
   # in the container
   userfile: /dashboard-data/users.json
   # on the server
-  datapath: /tmp/dashboard-data
+  datapath: /opt/data/dashboard-data
 
   # The URL prefixes use K8S/Kong service names
   a1med:
index ae097fe..6a6fe8c 100755 (executable)
@@ -59,17 +59,62 @@ fi
 
 
 
+NODENAME=$(kubectl get node | awk '{print $1}')
+LABELFOUND=false
+for f in $NODENAME; do
+    LABEL=$(kubectl describe node $f | grep local-storage)
+    if [ ! -z "$LABEL" ]; then
+       LABELFOUND=true
+    fi
+done
+
+if [ ! -z $OVERRIDEYAML ]; then
+  FOUND_STORAGECLASS=$(grep storageclass $OVERRIDEYAML)
+fi
+
+
+
+if  ! $LABELFOUND && [ -z "$FOUND_STORAGECLASS" ]; then
+    echo "***********************************************************************************************"
+    echo "*                                          ERROR!!!!!!!!!!!!!                                 *"
+    echo "***********************************************************************************************"
+    echo "* Nodes label \"local-storage=enable\" is not found in any of the cluster node.               *"
+    echo "* Please pick a node and label it using the following command.                                *"
+    echo "* kubectl label --overwrite nodes <YOUR_NODE_NAME> local-storage=enable                       *"
+    echo "***********************************************************************************************"
+
+  exit 1
+fi
+
+
+
+
+if [ -z "$FOUND_STORAGECLASS" ] && $LABELFOUND; then
+
+    DATAPATH=$(cat $DIR/../helm/chartmuseum/values.yaml | grep datapath | awk '{ print $2}' )
+
+
+    if [ ! -z $OVERRIDEYAML ]; then
+        DATAPATHOVERRIDE=$(cat $OVERRIDEYAML | grep datapath | awk '{ print $2}' )
+    fi 
+
+    if [ ! -z "$DATAPATHOVERRIDE" ]; then
+       DATAPATH=$DATAPATHOVERRIDE
+    fi
+
 
-NODENAME=$(kubectl get node | awk 'NR==2{print $1}')
-kubectl label --overwrite nodes $NODENAME helm-node=enable
+    echo "***********************************************************************************************"
+    echo "*                                          WARNING!!!!!!!!!!!!!                               *"
+    echo "***********************************************************************************************"
+    echo "* Chartmuseume will use local storage. Please make sure that directory                        *"
+    echo "* $DATAPATH                                                                                   *"
+    echo "* exists on the selected cluster node, and contains the proper files.                         *"
+    echo "***********************************************************************************************"
 
-DIRTEMP=$DIR
-. "$DIR/clear_data_path"
-DIR=$DIRTEMP
 
+fi 
 
 RICINFRA_COMPONENTS="chartmuseum"
-mkdir -p /tmp/chartmuseum-data
 
 echo "Deploying RIC infra components [$RICINFRA_COMPONENTS]"
 echo "Helm Release Name: $RELEASE_NAME"
index c283c19..faee6f3 100644 (file)
@@ -36,6 +36,9 @@ spec:
         app: {{ include "common.namespace.infra" . }}-{{ include "common.name.chartmuseum" . }}
         release: {{ .Release.Name }}
     spec:
+      securityContext:
+        fsGroup: 0
+        runAsUser: 0
       hostname: {{ .Chart.Name }}
       imagePullSecrets:
         - name: {{ include "common.repositoryCred" . }}
index 01f5ac6..6253d53 100644 (file)
@@ -22,9 +22,12 @@ metadata:
 spec:
   template:
     spec:
+      imagePullSecrets:
+        - name: {{ include "common.repositoryCred" . }}
       containers:
       - name: cert-copy
-        image: alpine
+        image: {{ include "common.repository" . }}/{{ .Values.chartmuseum.job.image.name }}:{{ .Values.chartmuseum.job.image.tag }}
+        imagePullPolicy: {{ include "common.pullPolicy" . }}
         command: [ "/bin/sh","-c","cp -rL /var/run/helmcerts/..data/tls.crt /var/run/certs-copy/helmtls.crt"]
         #        command: ["tail", "-f", "/dev/null"]
         volumeMounts:
index 93127ca..42939be 100644 (file)
@@ -1,3 +1,14 @@
+{{- if not .Values.chartmuseum.storageclass }}
+
+kind: StorageClass
+apiVersion: storage.k8s.io/v1
+metadata:
+  name: storageclass-{{ include "common.name.chartmuseum" . }}
+provisioner: kubernetes.io/no-provisioner
+volumeBindingMode: WaitForFirstConsumer
+
+---
+
 apiVersion: v1
 kind: PersistentVolume
 metadata:
@@ -15,7 +26,9 @@ spec:
     required:
       nodeSelectorTerms:
       - matchExpressions:
-        - key: helm-node
+        - key: local-storage
           operator: In
           values:
           - enable
+{{- end -}}
+
index 11e0314..9a945b2 100644 (file)
@@ -5,7 +5,7 @@ metadata:
 spec:
   accessModes:
   - ReadWriteOnce
-  storageClassName: storageclass-{{ include "common.name.chartmuseum" . }} 
+  storageClassName: {{ .Values.chartmuseum.storageclass | default (printf "storageclass-%s" ( include "common.name.chartmuseum" . )) }} 
   resources:
     requests:
       storage: {{ .Values.chartmuseum.storagesize }}
diff --git a/ric-infra/15-Chartmuseum/helm/chartmuseum/templates/storageClass.yaml b/ric-infra/15-Chartmuseum/helm/chartmuseum/templates/storageClass.yaml
deleted file mode 100644 (file)
index 85eed19..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: StorageClass
-apiVersion: storage.k8s.io/v1
-metadata:
-  name: storageclass-{{ include "common.name.chartmuseum" . }}
-provisioner: kubernetes.io/no-provisioner
-volumeBindingMode: WaitForFirstConsumer
index 203a678..026e3fd 100644 (file)
 # Default values for nexus.
 # This is a YAML-formatted file.
 # Declare variables to be passed into your templates.
-repository: "registry.hub.docker.com"
+repository: "docker.io"
 imagePullPolicy: IfNotPresent
 repositoryCred: docker-reg-cred
 helmRepositoryCert: xapp-mgr-certs
 
 chartmuseum:
+  repositoryOverride: "docker.io"
   replicaCount: 1
 
 
+  job:
+    image:
+      name: alpine
+      tag: latest
+
 # This is designed to be deployed using local image
   image:
     name: chartmuseum/chartmuseum
     tag: v0.8.2
 
-
+# Specify a storage class to bypass the local storage definition.
+# storageclass:
   storagesize: 2Gi
-  datapath: /tmp/chartmuseum-data/
+  datapath: /opt/data/chartmuseum-data
index c246fc1..74313b1 100755 (executable)
 #   See the License for the specific language governing permissions and        #
 #   limitations under the License.                                             #
 ################################################################################
-
-
 OVERRIDEYAML=$1
-
-
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
-
 source $DIR/../etc/tiller.conf
 
 if [ -z "$RICINFRA_RELEASE_NAME" ];then
-   RELEASE_NAME=$helm_release_name
+    RELEASE_NAME=$helm_release_name
 else
-   RELEASE_NAME=$RICINFRA_RELEASE_NAME
+    RELEASE_NAME=$RICINFRA_RELEASE_NAME
 fi
+
 # Namespace configuration
 if [ -z "$RICPLT_NAMESPACE" ];then
-   PLT_NAMESPACE=$plt_namespace
+    PLT_NAMESPACE=$plt_namespace
 else
-   PLT_NAMESPACE=$RICPLT_NAMESPACE
+    PLT_NAMESPACE=$RICPLT_NAMESPACE
 fi
+
 if [ -z "$RICXAPP_NAMESPACE" ];then
-   XAPP_NAMESPACE=$xapp_namespace
+    XAPP_NAMESPACE=$xapp_namespace
 else
-   XAPP_NAMESPACE=$RICXAPP_NAMESPACE
+    XAPP_NAMESPACE=$RICXAPP_NAMESPACE
 fi
+
 if [ -z "$RICAUX_NAMESPACE" ];then
-   AUX_NAMESPACE=$aux_namespace
+    AUX_NAMESPACE=$aux_namespace
 else
-   AUX_NAMESPACE=$RICAUX_NAMESPACE
+    AUX_NAMESPACE=$RICAUX_NAMESPACE
 fi
+
 if [ -z "$RICINFRA_NAMESPACE" ];then
-   INFRA_NAMESPACE=$infra_namespace
+    INFRA_NAMESPACE=$infra_namespace
 else
-   INFRA_NAMESPACE=$RICINFRA_NAMESPACE
+    INFRA_NAMESPACE=$RICINFRA_NAMESPACE
 fi
 
 if [ -z "$RIC_COMMON_OVERRIDE" ];then
-   COMMON_OVERRIDE="--set global.namespace.platform=$PLT_NAMESPACE --set global.namespace.xapp=$XAPP_NAMESPACE --set global.namespace.aux=$AUX_NAMESPACE --set global.namespace.infra=$INFRA_NAMESPACE"
+    COMMON_OVERRIDE="--set global.namespace.platform=$PLT_NAMESPACE --set global.namespace.xapp=$XAPP_NAMESPACE --set global.namespace.aux=$AUX_NAMESPACE --set global.namespace.infra=$INFRA_NAMESPACE"
 else
-   COMMON_OVERRIDE=$RIC_COMMON_OVERRIDE
+    COMMON_OVERRIDE=$RIC_COMMON_OVERRIDE
 fi
 
 
-
-
 RICINFRA_COMPONENTS="xapp-tiller"
 
 echo "Deploying RIC infra components [$RICINFRA_COMPONENTS]"