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 cd588b1 add alarm provider (#265) cd588b1 is described below commit cd588b13273855ce0300a69f39a8b113ca149d88 Author: Ying Chun Guo <guoyi...@cn.ibm.com> AuthorDate: Thu Aug 2 22:14:21 2018 +0800 add alarm provider (#265) --- helm/openwhisk/templates/clusterConfigMaps.yaml | 1 + helm/openwhisk/templates/invoker.yaml | 6 ++ helm/openwhisk/values.yaml | 2 +- helm/providers/charts/alarm/Chart.yaml | 12 ++++ helm/providers/charts/alarm/README.md | 49 ++++++++++++++ .../charts/alarm/configMapFiles/myTask.sh | 19 ++++++ helm/providers/charts/alarm/templates/NOTES.txt | 14 ++++ .../charts/alarm/templates/installPkgAlarmJob.yaml | 69 +++++++++++++++++++ .../charts/alarm/templates/pkgAlarmProvider.yaml | 79 ++++++++++++++++++++++ helm/providers/charts/alarm/values.yaml | 18 +++++ 10 files changed, 268 insertions(+), 1 deletion(-) diff --git a/helm/openwhisk/templates/clusterConfigMaps.yaml b/helm/openwhisk/templates/clusterConfigMaps.yaml index 4167ce9..1957479 100644 --- a/helm/openwhisk/templates/clusterConfigMaps.yaml +++ b/helm/openwhisk/templates/clusterConfigMaps.yaml @@ -38,6 +38,7 @@ data: db_host: {{ include "db_host" . | quote }} db_port: {{ .Values.db.port | quote }} db_url: "{{ .Values.db.protocol }}://{{ include "db_host" . }}:{{ .Values.db.port }}" + db_host_port: "{{ include "db_host" . }}:{{ .Values.db.port }}" db_whisk_actions: {{ .Values.db.actionsTable | quote }} db_whisk_activations: {{ .Values.db.activationsTable | quote }} db_whisk_auths: {{ .Values.db.authsTable | quote }} diff --git a/helm/openwhisk/templates/invoker.yaml b/helm/openwhisk/templates/invoker.yaml index 9eddb2b..0b3481d 100644 --- a/helm/openwhisk/templates/invoker.yaml +++ b/helm/openwhisk/templates/invoker.yaml @@ -94,6 +94,12 @@ spec: - name: "CONFIG_whisk_containerPool_coreShare" value: {{ .Values.invoker.containerPool.coreShare | quote }} + # DNS Server passed to action containers +{{- if not (eq .Values.invoker.kube_dns "nil") }} + - name: "CONFIG_whisk_containerFactory_containerArgs_dnsServers_0" + value: {{ .Values.invoker.kube_dns }} +{{ end }} + # Invoker name is the name of the node (DaemonSet) or pod (StatefulSet) - name: "INVOKER_NAME" valueFrom: diff --git a/helm/openwhisk/values.yaml b/helm/openwhisk/values.yaml index 04783e2..05420ef 100644 --- a/helm/openwhisk/values.yaml +++ b/helm/openwhisk/values.yaml @@ -174,6 +174,7 @@ invoker: numcore: 2 coreshare: 4 busyThreshold: 8 + kube_dns: nil # API Gateway configurations apigw: @@ -212,4 +213,3 @@ affinity: edgeNodeLabel: edge invokerNodeLabel: invoker providerNodeLabel: provider - diff --git a/helm/providers/charts/alarm/Chart.yaml b/helm/providers/charts/alarm/Chart.yaml new file mode 100644 index 0000000..7fe83b1 --- /dev/null +++ b/helm/providers/charts/alarm/Chart.yaml @@ -0,0 +1,12 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + +apiVersion: v1 +description: A Helm chart to deploy the Apache OpenWhisk Alarm Provider on Kubernetes +name: Apache OpenWhisk Alarm Provider +version: 0.1.0 +keywords: + - Apache OpenWhisk +maintainers: + - name: Apache OpenWhisk committers + email: d...@openwhisk.apache.org diff --git a/helm/providers/charts/alarm/README.md b/helm/providers/charts/alarm/README.md new file mode 100644 index 0000000..f5415ae --- /dev/null +++ b/helm/providers/charts/alarm/README.md @@ -0,0 +1,49 @@ +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +# Use Helm to deploy alarm provider and package + +This chart is to deploy alarm provider and package to OpenWhisk on a Kubernetes using Helm. + +## Preconditions + +Alarm package can only be successfully installed under these two preconditions: ++ persistentvolumes (aka 'pv') is defined in the Kubernetes cluster. You can verify by `kubectl get pv`. ++ Kubernetes DNS is used as the DNS server in action containers. In order to achieve it, you can set `KubernetesContainerFactory` as the [Invoker Container Factory](https://github.com/apache/incubator-openwhisk-deploy-kube/blob/master/docs/configurationChoices.md#invoker-container-factory) in the Kubernetes cluster by adding below configuration in the `mycluster.yaml` when you deploy OpenWhisk with Helm: +``` +# Invoker configurations +invoker: + containerFactory: + impl: "kubernetes" +``` +or you can pass Kubernetes DNS to invoker. First you can get the IP address of Kubernetes DNS server by `echo $(kubectl get svc kube-dns -n kube-system -o 'jsonpath={.spec.clusterIP}')` and then add below configuration in the `mycluster.yaml`: +``` +# Invoker configurations +invoker: + kube_dns: "<IP_Address_Of_Kube_DNS>" +``` + +## Install + +You may install this chart with command like +``` +helm install ./helm/providers/charts/alarm --namespace=openwhisk --name owdev-alarm-provider +``` + +You can use `helm status owdev-alarm-provider` to check the status. When you see pod is running and job is completed, you can check alarm package by `wsk package get /whisk.system/alarms -i --summary` diff --git a/helm/providers/charts/alarm/configMapFiles/myTask.sh b/helm/providers/charts/alarm/configMapFiles/myTask.sh new file mode 100644 index 0000000..c887021 --- /dev/null +++ b/helm/providers/charts/alarm/configMapFiles/myTask.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + +# installCatalog.sh expects the wsk cli to be $OPENWHISK_HOME/bin/wsk + +export OPENWHISK_HOME=/usr/local + +# install npm +apk add --update nodejs-npm + +git clone https://github.com/apache/incubator-openwhisk-package-alarms.git + +export DB_URL=http://$DB_USERNAME:$DB_PASSWORD@$DB_HOST:$DB_PORT +pushd /incubator-openwhisk-package-alarms + ./installCatalog.sh $AUTH $APIHOST $DB_URL $DB_PREFIX $APIHOST +popd + +echo "successfully setup alarm package" diff --git a/helm/providers/charts/alarm/templates/NOTES.txt b/helm/providers/charts/alarm/templates/NOTES.txt new file mode 100644 index 0000000..b01e731 --- /dev/null +++ b/helm/providers/charts/alarm/templates/NOTES.txt @@ -0,0 +1,14 @@ +{{/* Licensed to the Apache Software Foundation (ASF) under one or more contributor */}} +{{/* license agreements; and to You under the Apache License, Version 2.0. */}} +Apache OpenWhisk Kafka Provider +Copyright 2016-2018 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Your release is named {{ .Release.Name }}. + +To learn more about the release, try: + + $ helm status {{ .Release.Name }} + $ helm get {{ .Release.Name }} diff --git a/helm/providers/charts/alarm/templates/installPkgAlarmJob.yaml b/helm/providers/charts/alarm/templates/installPkgAlarmJob.yaml new file mode 100644 index 0000000..24dcf28 --- /dev/null +++ b/helm/providers/charts/alarm/templates/installPkgAlarmJob.yaml @@ -0,0 +1,69 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + +apiVersion: batch/v1 +kind: Job +metadata: + name: install-package-alarm + namespace: {{ .Release.Namespace | quote }} +spec: + activeDeadlineSeconds: 600 + template: + metadata: + name: install-package-alarm + spec: + restartPolicy: Never + volumes: + - name: task-dir + configMap: + name: install-package-alarms + containers: + - name: alarmpkginstaller + image: openwhisk/kube-whisk-script-runner + volumeMounts: + - name: task-dir + mountPath: "/task/myTask.sh" + subPath: "myTask.sh" + env: + - name: "AUTH" + valueFrom: + secretKeyRef: + name: whisk.auth + key: system + # poorly named envvar; actually expects full apihost (host:port) + - name: "APIHOST" + valueFrom: + configMapKeyRef: + name: whisk.config + key: whisk_api_host_nameAndPort + # for the database used by kafka package + - name: "DB_HOST" + valueFrom: + configMapKeyRef: + name: db.config + key: db_host + - name: "DB_PORT" + valueFrom: + configMapKeyRef: + name: db.config + key: db_port + - name: "DB_USERNAME" + valueFrom: + secretKeyRef: + name: db.auth + key: db_username + - name: "DB_PASSWORD" + valueFrom: + secretKeyRef: + name: db.auth + key: db_password + - name: "DB_PREFIX" + value: "{{- .Values.alarmprovider.dbPrefix -}}" +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: install-package-alarms + namespace: {{ .Release.Namespace | quote }} +data: +{{ (.Files.Glob "configMapFiles/myTask.sh").AsConfig | indent 2 }} diff --git a/helm/providers/charts/alarm/templates/pkgAlarmProvider.yaml b/helm/providers/charts/alarm/templates/pkgAlarmProvider.yaml new file mode 100644 index 0000000..c543bd8 --- /dev/null +++ b/helm/providers/charts/alarm/templates/pkgAlarmProvider.yaml @@ -0,0 +1,79 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.alarmprovider.name | quote }} + namespace: {{ .Release.Namespace | quote }} + labels: + name: alarmprovider +spec: + replicas: {{ .Values.alarmprovider.replicaCount }} + template: + metadata: + labels: + name: {{ .Values.alarmprovider.name | quote }} + spec: + restartPolicy: {{ .Values.alarmprovider.restartPolicy }} + volumes: + - name: alarm-logs + persistentVolumeClaim: + claimName: {{ .Values.alarmprovider.persistence.pvcName | quote }} + containers: + - name: {{ .Values.alarmprovider.name | quote }} + imagePullPolicy: {{ .Values.alarmprovider.imagePullPolicy | quote }} + image: {{ .Values.alarmprovider.image | quote }} + ports: + - name: kafkaprovider + containerPort: {{ .Values.alarmprovider.apiPort }} + env: + - name: "DB_PROTOCOL" + valueFrom: + configMapKeyRef: + name: db.config + key: db_protocol + - name: "DB_HOST" + valueFrom: + configMapKeyRef: + name: db.config + key: db_host_port + - name: "DB_USERNAME" + valueFrom: + secretKeyRef: + name: db.auth + key: db_username + - name: "DB_PASSWORD" + valueFrom: + secretKeyRef: + name: db.auth + key: db_password + - name: "DB_PREFIX" + value: "{{- .Values.alarmprovider.dbPrefix -}}" + - name: "ROUTER_HOST" + valueFrom: + configMapKeyRef: + name: whisk.config + key: whisk_api_host_nameAndPort + - name: "ENDPOINT_AUTH" + valueFrom: + configMapKeyRef: + name: whisk.config + key: whisk_api_host_nameAndPort + volumeMounts: + - name: alarm-logs + mountPath: /logs + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Values.alarmprovider.persistence.pvcName | quote }} + namespace: {{ .Release.Namespace | quote }} +spec: + storageClassName: {{ .Values.alarmprovider.persistence.storageClass }} + accessModes: + - {{ .Values.alarmprovider.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.alarmprovider.persistence.size }} diff --git a/helm/providers/charts/alarm/values.yaml b/helm/providers/charts/alarm/values.yaml new file mode 100644 index 0000000..530c3de --- /dev/null +++ b/helm/providers/charts/alarm/values.yaml @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements; and to You under the Apache License, Version 2.0. + +# Alarm provider configurations +alarmprovider: + name: "alarmprovider" + image: "openwhisk/alarmprovider:latest" + # NOTE: replicaCount > 1 doesn't work because of the PVC + replicaCount: 1 + imagePullPolicy: "IfNotPresent" + restartPolicy: "Always" + apiPort: 8080 + dbPrefix: "alm" + persistence: + pvcName: alarmprovider-pvc + size: 1Gi + storageClass: default + accessMode: ReadWriteOnce