You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by dg...@apache.org on 2019/05/21 14:41:29 UTC

[incubator-openwhisk-deploy-kube] branch master updated: Provide support for Lean OpenWhisk configuration (#463)

This is an automated email from the ASF dual-hosted git repository.

dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-deploy-kube.git


The following commit(s) were added to refs/heads/master by this push:
     new 4629143  Provide support for Lean OpenWhisk  configuration (#463)
4629143 is described below

commit 4629143bb08d38f02d994a4335cb1ec06c466c78
Author: Pavel Kravchenko <kp...@il.ibm.com>
AuthorDate: Tue May 21 17:41:23 2019 +0300

    Provide support for Lean OpenWhisk  configuration (#463)
    
    * adding support for lean openwhisk setup
---
 .travis.yml                                        |  2 +
 README.md                                          |  8 +++
 helm/openwhisk/templates/_helpers.tpl              | 68 +++++++++++++++++++++-
 helm/openwhisk/templates/controller-pod.yaml       | 24 +++++++-
 helm/openwhisk/templates/install-packages-job.yaml |  2 +
 helm/openwhisk/templates/invoker-pod.yaml          | 37 ++----------
 helm/openwhisk/templates/invoker-rolebind.yaml     |  2 +-
 helm/openwhisk/templates/invoker-svcacct.yaml      |  5 +-
 helm/openwhisk/templates/kafka-pod.yaml            |  3 +
 helm/openwhisk/templates/kafka-pvc.yaml            |  2 +-
 helm/openwhisk/templates/kafka-svc.yaml            |  3 +
 helm/openwhisk/templates/zookeeper-cm.yaml         |  3 +
 helm/openwhisk/templates/zookeeper-pod.yaml        |  3 +
 helm/openwhisk/templates/zookeeper-svc.yaml        |  3 +
 tools/travis/deploy-chart.sh                       | 15 +++--
 15 files changed, 138 insertions(+), 42 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index bbd0ce1..18c722f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,8 @@ env:
     - TRAVIS_KUBE_VERSION=1.12 OW_INCLUDE_SYSTEM_TESTS=true OW_CONTAINER_FACTORY=docker
     - TRAVIS_KUBE_VERSION=1.13 OW_INCLUDE_SYSTEM_TESTS=true OW_CONTAINER_FACTORY=docker
     - TRAVIS_KUBE_VERSION=1.13 OW_INCLUDE_SYSTEM_TESTS=false OW_CONTAINER_FACTORY=kubernetes
+    - TRAVIS_KUBE_VERSION=1.13 OW_INCLUDE_SYSTEM_TESTS=false OW_CONTAINER_FACTORY=kubernetes OW_LEAN_MODE=true
+    - TRAVIS_KUBE_VERSION=1.13 OW_INCLUDE_SYSTEM_TESTS=true OW_CONTAINER_FACTORY=docker OW_LEAN_MODE=true
 
 services:
   - docker
diff --git a/README.md b/README.md
index 69c9f4e..16a9cdd 100644
--- a/README.md
+++ b/README.md
@@ -344,6 +344,14 @@ openwhisk-deploy-kube directory:
 helm upgrade ./helm/openwhisk --namespace=openwhisk --name=owdev -f mycluster.yaml
 ```
 
+### Deploying Lean Openwhisk version.
+
+To have a lean setup (no Kafka, Zookeeper and no Invokers as separate entities):
+```yaml
+controller:
+  lean: true
+```
+
 # Cleanup
 
 Use the following command to remove all the deployed OpenWhisk components:
diff --git a/helm/openwhisk/templates/_helpers.tpl b/helm/openwhisk/templates/_helpers.tpl
index 2cd28ba..2aa8578 100644
--- a/helm/openwhisk/templates/_helpers.tpl
+++ b/helm/openwhisk/templates/_helpers.tpl
@@ -217,4 +217,70 @@ app: {{ template "openwhisk.fullname" . }}
 imagePullSecrets:
 - name: {{ .Release.Name }}-private-registry.auth
 {{- end }}
-{{- end -}}
\ No newline at end of file
+{{- end -}}
+
+{{/* Environment variables required for Lean OW configuration */}}
+{{- define "openwhisk.lean.provider" -}}
+{{- if .Values.controller.lean -}}
+- name: "CONFIG_whisk_spi_MessagingProvider"
+  value: "org.apache.openwhisk.connector.lean.LeanMessagingProvider"
+- name: "CONFIG_whisk_spi_LoadBalancerProvider"
+  value: "org.apache.openwhisk.core.loadBalancer.LeanBalancer"
+{{- end -}}
+{{- end -}}
+
+{{/* Environment variables required for invoker API HOST configuration */}}
+{{- define "openwhisk.invoker.apihost" -}}
+- name: "WHISK_API_HOST_PROTO"
+  valueFrom:
+    configMapKeyRef:
+      name: {{ .Release.Name }}-whisk.config
+      key: whisk_api_host_proto
+- name: "WHISK_API_HOST_PORT"
+  valueFrom:
+    configMapKeyRef:
+      name: {{ .Release.Name }}-whisk.config
+      key: whisk_api_host_port
+- name: "WHISK_API_HOST_NAME"
+  valueFrom:
+    configMapKeyRef:
+      name: {{ .Release.Name }}-whisk.config
+      key: whisk_api_host_name
+- name: "CONFIG_whisk_docker_containerFactory_useRunc"
+  value: {{ .Values.invoker.containerFactory.useRunc | quote }}
+- name: "CONFIG_whisk_containerPool_userMemory"
+  value: {{ .Values.whisk.containerPool.userMemory | quote }}
+{{- end -}}
+
+{{/* Environment variables required for invoker volumes configuration */}}
+{{- define "openwhisk.invoker.volumes" -}}
+{{- if eq .Values.invoker.containerFactory.impl "docker" }}
+      volumes:
+{{ include "openwhisk.docker_volumes" . | indent 6 }}
+      - name: scripts-dir
+        configMap:
+          name: {{ .Release.Name }}-invoker-scripts
+{{- end }}
+{{- end }}
+
+{{/* Environment variables required for invoker volumes configuration */}}
+{{- define "openwhisk.invoker.volume_mounts" -}}
+{{- if (eq .Values.invoker.containerFactory.impl "docker") }}
+        volumeMounts:
+{{ include "openwhisk.docker_volume_mounts" . | indent 8 }}
+{{- if .Values.invoker.containerFactory.networkConfig.dns.inheritInvokerConfig }}
+        - name: scripts-dir
+          mountPath: "/invoker-scripts/configureDNS.sh"
+          subPath: "configureDNS.sh"
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/* invoker additional options */}}
+{{- define "openwhisk.invoker.add_opts" -}}
+{{- if eq .Values.invoker.containerFactory.impl "docker" -}}
+-Dwhisk.spi.ContainerFactoryProvider=org.apache.openwhisk.core.containerpool.docker.DockerContainerFactoryProvider
+{{- else -}}
+-Dkubernetes.master=https://$KUBERNETES_SERVICE_HOST -Dwhisk.spi.ContainerFactoryProvider=org.apache.openwhisk.core.containerpool.kubernetes.KubernetesContainerFactoryProvider
+{{- end -}}
+{{- end -}}
diff --git a/helm/openwhisk/templates/controller-pod.yaml b/helm/openwhisk/templates/controller-pod.yaml
index 95b134f..f495151 100644
--- a/helm/openwhisk/templates/controller-pod.yaml
+++ b/helm/openwhisk/templates/controller-pod.yaml
@@ -31,14 +31,25 @@ spec:
       {{- end }}
 
       initContainers:
-      # The controller must wait for kafka and couchdb to be ready before it starts
+{{- if not .Values.controller.lean }}
+      # The controller must wait for kafka and/or couchdb to be ready before it starts
 {{ include "openwhisk.readiness.waitForKafka" . | indent 6 }}
+{{- end }}
 {{ include "openwhisk.readiness.waitForCouchDB" . | indent 6 }}
+      # The lean controller requires invoker volumes mounts
+{{- if .Values.controller.lean }}
+{{ include "openwhisk.invoker.volumes" . }}
+{{- end }}
 {{ include "openwhisk.docker.imagePullSecrets" . | indent 6 }}
+
       containers:
       - name: controller
         imagePullPolicy: {{ .Values.controller.imagePullPolicy | quote }}
         image: "{{- .Values.docker.registry.name -}}{{- .Values.controller.imageName -}}:{{- .Values.controller.imageTag -}}"
+{{- if .Values.controller.lean }}
+        securityContext:
+          privileged: true
+{{- end }}
         command: ["/bin/bash", "-c", "/init.sh `hostname | cut -d'-' -f3`"]
         ports:
         - name: controller
@@ -47,6 +58,9 @@ spec:
           containerPort: 2552
         - name: akka-mgmt-http
           containerPort: 19999
+{{- if .Values.controller.lean }}
+{{ include "openwhisk.invoker.volume_mounts" . }}
+{{- end }}
         livenessProbe:
           httpGet:
             path: "/ping"
@@ -79,7 +93,7 @@ spec:
 
         # specific controller arguments
         - name: "CONTROLLER_OPTS"
-          value: {{ .Values.controller.options | quote }}
+          value: "{{ .Values.controller.options }} {{ if .Values.controller.lean }} {{ include "openwhisk.invoker.add_opts" . }} {{ end }}"
 
         # action runtimes
         - name: "RUNTIMES_MANIFEST"
@@ -118,3 +132,9 @@ spec:
         - name: "CONFIG_akka_discovery_kubernetesApi_podPortName"
           value: "akka-mgmt-http"
 {{- end }}
+        # properties for lean messaging provider
+{{ include "openwhisk.lean.provider" . | indent 8 }}
+
+{{- if .Values.controller.lean }}
+{{ include "openwhisk.invoker.apihost" . | indent 8 }}
+{{- end }}
diff --git a/helm/openwhisk/templates/install-packages-job.yaml b/helm/openwhisk/templates/install-packages-job.yaml
index 553ff88..b638a25 100644
--- a/helm/openwhisk/templates/install-packages-job.yaml
+++ b/helm/openwhisk/templates/install-packages-job.yaml
@@ -23,7 +23,9 @@ spec:
         configMap:
           name: {{ .Release.Name }}-install-packages-cm
       initContainers:
+{{- if not .Values.controller.lean }}
 {{ include "openwhisk.readiness.waitForHealthyInvoker" . | indent 6 }}
+{{ end }}
 {{ include "openwhisk.docker.imagePullSecrets" . | indent 6 }}
       containers:
       - name: install-packages
diff --git a/helm/openwhisk/templates/invoker-pod.yaml b/helm/openwhisk/templates/invoker-pod.yaml
index de4a338..0b368c5 100644
--- a/helm/openwhisk/templates/invoker-pod.yaml
+++ b/helm/openwhisk/templates/invoker-pod.yaml
@@ -1,6 +1,8 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
+{{- if not .Values.controller.lean }}
+---
 {{- if eq .Values.invoker.containerFactory.impl "docker" }}
 apiVersion: apps/v1
 kind: DaemonSet
@@ -39,13 +41,7 @@ spec:
 {{ include "openwhisk.affinity.selfAntiAffinity" ( printf "%s-invoker" .Release.Name ) | indent 8 }}
 {{- end }}
 
-{{- if eq .Values.invoker.containerFactory.impl "docker" }}
-      volumes:
-{{ include "openwhisk.docker_volumes" . | indent 6 }}
-      - name: scripts-dir
-        configMap:
-          name: {{ .Release.Name }}-invoker-scripts
-{{- end }}
+{{ include "openwhisk.invoker.volumes" . }}
 
       initContainers:
 {{- if eq .Values.invoker.containerFactory.impl "docker" }}
@@ -69,21 +65,7 @@ spec:
             value: {{ .Values.invoker.port | quote }}
 
           # Needed by invoker to set the environment variable __OW_API_HOST in action containers
-          - name: "WHISK_API_HOST_PROTO"
-            valueFrom:
-              configMapKeyRef:
-                name: {{ .Release.Name }}-whisk.config
-                key: whisk_api_host_proto
-          - name: "WHISK_API_HOST_PORT"
-            valueFrom:
-              configMapKeyRef:
-                name: {{ .Release.Name }}-whisk.config
-                key: whisk_api_host_port
-          - name: "WHISK_API_HOST_NAME"
-            valueFrom:
-              configMapKeyRef:
-                name: {{ .Release.Name }}-whisk.config
-                key: whisk_api_host_name
+{{ include "openwhisk.invoker.apihost" . | indent 10 }}
 
           - name: "CONFIG_whisk_docker_containerFactory_useRunc"
             value: {{ .Values.invoker.containerFactory.useRunc | quote }}
@@ -132,7 +114,7 @@ spec:
 
           # Invoker options
           - name: "INVOKER_OPTS"
-            value: "{{ .Values.invoker.options }} {{ if eq .Values.invoker.containerFactory.impl "docker" }} -Dwhisk.spi.ContainerFactoryProvider=org.apache.openwhisk.core.containerpool.docker.DockerContainerFactoryProvider {{ else }} -Dkubernetes.master=https://$KUBERNETES_SERVICE_HOST -Dwhisk.spi.ContainerFactoryProvider=org.apache.openwhisk.core.containerpool.kubernetes.KubernetesContainerFactoryProvider {{ end }}"
+            value: "{{ .Values.invoker.options }} {{ include "openwhisk.invoker.add_opts" . }}"
 
 {{ if .Values.invoker.containerFactory.kubernetes.agent.enabled }}
           - name: "CONFIG_whisk_kubernetes_invokerAgent_enabled"
@@ -174,12 +156,5 @@ spec:
         ports:
         - name: invoker
           containerPort: {{ .Values.invoker.port }}
-{{- if eq .Values.invoker.containerFactory.impl "docker" }}
-        volumeMounts:
-{{ include "openwhisk.docker_volume_mounts" . | indent 8 }}
-{{- if .Values.invoker.containerFactory.networkConfig.dns.inheritInvokerConfig }}
-        - name: scripts-dir
-          mountPath: "/invoker-scripts/configureDNS.sh"
-          subPath: "configureDNS.sh"
-{{- end }}
+{{ include "openwhisk.invoker.volume_mounts" . }}
 {{- end }}
diff --git a/helm/openwhisk/templates/invoker-rolebind.yaml b/helm/openwhisk/templates/invoker-rolebind.yaml
index ffeb480..6b2873c 100644
--- a/helm/openwhisk/templates/invoker-rolebind.yaml
+++ b/helm/openwhisk/templates/invoker-rolebind.yaml
@@ -16,7 +16,7 @@ metadata:
 subjects:
 - kind: ServiceAccount
   namespace: {{ .Release.Namespace | quote }}
-  name: {{ .Release.Name }}-invoker
+  name: {{ if .Values.controller.lean }} {{ .Release.Name }}-core {{ else }} {{ .Release.Name }}-invoker {{ end }}
 roleRef:
   kind: Role
   name: {{ .Release.Name }}-invoker
diff --git a/helm/openwhisk/templates/invoker-svcacct.yaml b/helm/openwhisk/templates/invoker-svcacct.yaml
index ac28dca..698c2f2 100644
--- a/helm/openwhisk/templates/invoker-svcacct.yaml
+++ b/helm/openwhisk/templates/invoker-svcacct.yaml
@@ -1,12 +1,13 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
-
-{{ if eq .Values.invoker.containerFactory.impl "kubernetes" }}
 # When using KubernetesContainerFactory, invoker pods need extensive
 # permissions to manage pods and deployments. The ability to create
 # pods can enable privilege escalation attacks, so restrict it to a
 # ServiceAccount that is only used for the invokers and only defined
 # when using KubernetesContainerFactory.
+
+{{- if and (eq .Values.invoker.containerFactory.impl "kubernetes") (not .Values.controller.lean) }}
+---
 apiVersion: v1
 kind: ServiceAccount
 metadata:
diff --git a/helm/openwhisk/templates/kafka-pod.yaml b/helm/openwhisk/templates/kafka-pod.yaml
index 504e53a..8077232 100644
--- a/helm/openwhisk/templates/kafka-pod.yaml
+++ b/helm/openwhisk/templates/kafka-pod.yaml
@@ -1,6 +1,8 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
+{{- if not .Values.controller.lean }}
+---
 apiVersion: apps/v1
 kind: StatefulSet
 metadata:
@@ -76,3 +78,4 @@ spec:
         requests:
           storage: {{ .Values.kafka.persistence.size }}
 {{- end }}
+{{- end }}
diff --git a/helm/openwhisk/templates/kafka-pvc.yaml b/helm/openwhisk/templates/kafka-pvc.yaml
index a315b29..cdaa4c2 100644
--- a/helm/openwhisk/templates/kafka-pvc.yaml
+++ b/helm/openwhisk/templates/kafka-pvc.yaml
@@ -1,7 +1,7 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
-{{ if and .Values.k8s.persistence.enabled (eq (int .Values.kafka.replicaCount) 1 ) }}
+{{ if and .Values.k8s.persistence.enabled (eq (int .Values.kafka.replicaCount) 1 ) (not .Values.controller.lean) }}
 apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
diff --git a/helm/openwhisk/templates/kafka-svc.yaml b/helm/openwhisk/templates/kafka-svc.yaml
index 9b14f1c..700fe87 100644
--- a/helm/openwhisk/templates/kafka-svc.yaml
+++ b/helm/openwhisk/templates/kafka-svc.yaml
@@ -1,6 +1,8 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
+{{- if not .Values.controller.lean }}
+---
 apiVersion: v1
 kind: Service
 metadata:
@@ -15,3 +17,4 @@ spec:
   ports:
   - name: broker
     port: {{ .Values.kafka.port }}
+{{- end }}
diff --git a/helm/openwhisk/templates/zookeeper-cm.yaml b/helm/openwhisk/templates/zookeeper-cm.yaml
index a89331c..78851b6 100644
--- a/helm/openwhisk/templates/zookeeper-cm.yaml
+++ b/helm/openwhisk/templates/zookeeper-cm.yaml
@@ -1,6 +1,8 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
+{{- if not .Values.controller.lean }}
+---
 apiVersion: v1
 kind: ConfigMap
 metadata:
@@ -22,3 +24,4 @@ data:
 {{- range $i, $e := until (int .Values.zookeeper.replicaCount) }}
     server.{{ . }}={{ $zkname }}-{{ . }}.{{ $zkname }}.{{ $.Release.Namespace }}.svc.{{ $kubeDomain }}:{{ $zkserverport }}:{{ $zkelectionport }}
 {{- end }}
+{{- end }}
diff --git a/helm/openwhisk/templates/zookeeper-pod.yaml b/helm/openwhisk/templates/zookeeper-pod.yaml
index bd6d08b..d59b6df 100644
--- a/helm/openwhisk/templates/zookeeper-pod.yaml
+++ b/helm/openwhisk/templates/zookeeper-pod.yaml
@@ -1,6 +1,8 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
+{{- if not .Values.controller.lean }}
+---
 apiVersion: apps/v1
 kind: StatefulSet
 metadata:
@@ -104,3 +106,4 @@ spec:
         requests:
           storage: {{ .Values.zookeeper.persistence.size }}
 {{- end }}
+{{- end }}
diff --git a/helm/openwhisk/templates/zookeeper-svc.yaml b/helm/openwhisk/templates/zookeeper-svc.yaml
index de0d01c..f536aea 100644
--- a/helm/openwhisk/templates/zookeeper-svc.yaml
+++ b/helm/openwhisk/templates/zookeeper-svc.yaml
@@ -1,6 +1,8 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor
 # license agreements; and to You under the Apache License, Version 2.0.
 
+{{- if not .Values.controller.lean }}
+---
 apiVersion: v1
 kind: Service
 metadata:
@@ -19,3 +21,4 @@ spec:
       name: "server"
     - port: {{ .Values.zookeeper.leaderElectionPort }}
       name: "leader-election"
+{{- end }}
diff --git a/tools/travis/deploy-chart.sh b/tools/travis/deploy-chart.sh
index 1f2d00e..af77271 100755
--- a/tools/travis/deploy-chart.sh
+++ b/tools/travis/deploy-chart.sh
@@ -85,7 +85,7 @@ jobHealthCheck () {
   TIMEOUT=0
   until $PASSED || [ $TIMEOUT -eq $TIMEOUT_STEP_LIMIT ]; do
     KUBE_DEPLOY_STATUS=$(kubectl -n openwhisk get pods -l name="$1" -o wide | grep "$1" | awk '{print $3}')
-    if [ "$KUBE_DEPLOY_STATUS" == "Completed" ]; then
+    if [[ $KUBE_DEPLOY_STATUS == *Completed* ]]; then
       PASSED=true
       echo "The job $1 has completed"
       break
@@ -202,6 +202,9 @@ invoker:
 
 nginx:
   httpsNodePort: $WSK_PORT
+
+controller:
+  lean: ${OW_LEAN_MODE:-false}
 EOF
 
 echo "Contents of mycluster.yaml are:"
@@ -213,10 +216,14 @@ helm install helm/openwhisk --namespace=openwhisk --name=ow4travis -f mycluster.
 statefulsetHealthCheck "ow4travis-controller"
 
 # Wait for invoker to be up
-deploymentHealthCheck "ow4travis-invoker"
+if [ "${OW_LEAN_MODE:-false}" == "false" ]; then
+
+  # Wait for invoker to be up
+  deploymentHealthCheck "ow4travis-invoker"
 
-# Wait for the controller to confirm that it has at least one healthy invoker
-verifyHealthyInvoker
+  # Wait for the controller to confirm that it has at least one healthy invoker
+  verifyHealthyInvoker
+fi
 
 # Wait for install-packages job to complete successfully
 jobHealthCheck "ow4travis-install-packages"