Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 43 additions & 41 deletions helm/openwhisk/configMapFiles/installPackages/myTask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,58 @@ export OPENWHISK_HOME=/openwhisk

export PROVIDER_DB_URL=$PROVIDER_DB_PROTOCOL://$PROVIDER_DB_USERNAME:$PROVIDER_DB_PASSWORD@$PROVIDER_DB_HOST:$PROVIDER_DB_PORT

#####
# Install Route Mgmt Support
#####

# Clone openwhisk repo to get installRouteMgmt.sh and core/routemgmt
# Clone openwhisk repo
git clone https://github.com/apache/openwhisk openwhisk
pushd openwhisk
git checkout $OW_GIT_TAG_OPENWHISK
rm -f /openwhisk/ansible/files/auth.guest /openwhisk/ansible/files/auth.whisk.system
popd

# Setup env for installRouteMgmt.sh
if [ "$WHISK_API_GATEWAY_USER" ]; then
export GW_USER=$WHISK_API_GATEWAY_USER
else
export GW_USER=' '
fi
if [ "$WHISK_API_GATEWAY_PASSWORD" ]; then
export GW_PWD=$WHISK_API_GATEWAY_PASSWORD
else
export GW_PWD=' '
fi
if [ "$WHISK_API_GATEWAY_HOST_V2" ]; then
export GW_HOST_V2=$WHISK_API_GATEWAY_HOST_V2
else
echo "Must provide a value for WHISK_API_GATEWAY_HOST_V2"
exit 1
fi
if [ "${WHISK_API_GATEWAY_ENABLED:-no}" = "yes" ]; then
#####
# Install Route Mgmt Support
#####

pushd $OPENWHISK_HOME/ansible/roles/routemgmt/files
# This operation is unreliable in a TravisCI environment (for unknown reasons),
# so try multiple times before giving up.
PASSED=false
TRIES=0
until $PASSED || [ $TRIES -eq 10 ]; do
if ./installRouteMgmt.sh $WHISK_AUTH $WHISK_API_HOST_URL $WHISK_SYSTEM_NAMESPACE /usr/local/bin/wsk; then
PASSED=true
echo "Successfully deployed routemgmt package"
else
echo "Failed to deploy routemgmt package; will pause, uninstall, and try again"
let TRIES=TRIES+1
sleep 10
./uninstallRouteMgmt.sh $WHISK_AUTH $WHISK_API_HOST_URL $WHISK_SYSTEM_NAMESPACE /usr/local/bin/wsk;
fi
done
if ! $PASSED; then
echo "Giving up after 10 failed attempts to install the routemgmt package"
# Setup env for installRouteMgmt.sh
if [ "$WHISK_API_GATEWAY_USER" ]; then
export GW_USER=$WHISK_API_GATEWAY_USER
else
export GW_USER=' '
fi
if [ "$WHISK_API_GATEWAY_PASSWORD" ]; then
export GW_PWD=$WHISK_API_GATEWAY_PASSWORD
else
export GW_PWD=' '
fi
if [ "$WHISK_API_GATEWAY_HOST_V2" ]; then
export GW_HOST_V2=$WHISK_API_GATEWAY_HOST_V2
else
echo "Must provide a value for WHISK_API_GATEWAY_HOST_V2"
exit 1
fi
popd

pushd $OPENWHISK_HOME/ansible/roles/routemgmt/files
# This operation is unreliable in a TravisCI environment (for unknown reasons),
# so try multiple times before giving up.
PASSED=false
TRIES=0
until $PASSED || [ $TRIES -eq 10 ]; do
if ./installRouteMgmt.sh $WHISK_AUTH $WHISK_API_HOST_URL $WHISK_SYSTEM_NAMESPACE /usr/local/bin/wsk; then
PASSED=true
echo "Successfully deployed routemgmt package"
else
echo "Failed to deploy routemgmt package; will pause, uninstall, and try again"
let TRIES=TRIES+1
sleep 10
./uninstallRouteMgmt.sh $WHISK_AUTH $WHISK_API_HOST_URL $WHISK_SYSTEM_NAMESPACE /usr/local/bin/wsk;
fi
done
if ! $PASSED; then
echo "Giving up after 10 failed attempts to install the routemgmt package"
exit 1
fi
popd
fi

#####
# Install the OpenWhisk Catalog
Expand Down
38 changes: 21 additions & 17 deletions helm/openwhisk/configMapFiles/tests/smoketest/myTask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,29 @@ if [ -z "$RESULT" ]; then
exit 1
fi

# now define it as an api and invoke it that way
echo "Registering as an api"
wsk -i api create /demo /hello get hello || (echo "FAILED: unable to create API"; exit 1)
echo "Invoking action via the api"
API_URL=$(wsk -i api list | grep hello | awk '{print $4}')
echo "External api URL: $API_URL"
INTERNAL_URL=$(echo $API_URL | sed s#^http.*/api/#$WSK_API_HOST_URL/api/#)
echo "Internal api URL: $INTERNAL_URL"
RESULT=$(wget --no-check-certificate -qO- "$INTERNAL_URL" | grep 'Hello world')
if [ -z "$RESULT" ]; then
echo "FAILED! Could not invoke hello via apigateway"
exit 1
fi
if [ "${WHISK_API_GATEWAY_ENABLED:-no}" = "yes" ]; then
# now define it as an api and invoke it that way
echo "Registering as an api"
wsk -i api create /demo /hello get hello || (echo "FAILED: unable to create API"; exit 1)
echo "Invoking action via the api"
API_URL=$(wsk -i api list | grep hello | awk '{print $4}')
echo "External api URL: $API_URL"
INTERNAL_URL=$(echo $API_URL | sed s#^http.*/api/#$WSK_API_HOST_URL/api/#)
echo "Internal api URL: $INTERNAL_URL"
RESULT=$(wget --no-check-certificate -qO- "$INTERNAL_URL" | grep 'Hello world')
if [ -z "$RESULT" ]; then
echo "FAILED! Could not invoke hello via apigateway"
exit 1
fi

# now delete the resources so the test could be run again
wsk -i api delete /demo || (echo "FAILED! failed to delete API"; exit 1)
wsk -i action delete hello || (echo "FAILED! failed to delete action"; exit 1)
# now delete the resources so the test could be run again
wsk -i api delete /demo || (echo "FAILED! failed to delete API"; exit 1)
wsk -i action delete hello || (echo "FAILED! failed to delete action"; exit 1)

echo "PASSED! Created Hello action and invoked via cli, web and apigateway"
echo "PASSED! Created Hello action and invoked via apigateway, cli, and web"
else
echo "PASSED! Created Hello action and invoked via cli, and web"
fi



2 changes: 2 additions & 0 deletions helm/openwhisk/templates/apigateway-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

{{- if .Values.apigw.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -71,3 +72,4 @@ spec:
configMapKeyRef:
name: {{ .Release.Name }}-whisk.config
key: whisk_internal_api_host_url
{{- end }}
2 changes: 2 additions & 0 deletions helm/openwhisk/templates/apigateway-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

{{- if .Values.apigw.enabled }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -30,3 +31,4 @@ spec:
name: mgmt
- port: {{ .Values.apigw.apiPort }}
name: api
{{- end }}
2 changes: 2 additions & 0 deletions helm/openwhisk/templates/install-packages-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ spec:
name: {{ .Release.Name }}-whisk.config
key: whisk_internal_api_host_url
# apigateway configuration (for installing routemgmt actions)
- name: "WHISK_API_GATEWAY_ENABLED"
value: {{ if .Values.apigw.enabled }} "yes" {{ else }} "no" {{ end }}
- name: "WHISK_SYSTEM_NAMESPACE"
valueFrom:
configMapKeyRef:
Expand Down
2 changes: 1 addition & 1 deletion helm/openwhisk/templates/redis-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

{{ if not .Values.redis.external }}
{{ if and .Values.apigw.enabled (not .Values.redis.external) }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
2 changes: 1 addition & 1 deletion helm/openwhisk/templates/redis-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

{{- if and (not .Values.redis.external) .Values.k8s.persistence.enabled }}
{{- if and .Values.apigw.enabled (not .Values.redis.external) .Values.k8s.persistence.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down
2 changes: 1 addition & 1 deletion helm/openwhisk/templates/redis-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

{{ if not .Values.redis.external }}
{{ if and .Values.apigw.enabled (not .Values.redis.external) }}
apiVersion: v1
kind: Service
metadata:
Expand Down
2 changes: 2 additions & 0 deletions helm/openwhisk/templates/tests/smoketest-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ spec:
configMapKeyRef:
name: {{ .Release.Name }}-whisk.config
key: whisk_internal_api_host_url
- name: "WSK_API_GATEWAY_ENABLED"
value: {{ if .Values.apigw.enabled }} "yes" {{ else }} "no" {{ end }}
{{- end }}
1 change: 1 addition & 0 deletions helm/openwhisk/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ invoker:

# API Gateway configurations
apigw:
enabled: true # Disabling this also disables Redis
imageName: "openwhisk/apigateway"
imageTag: "1.0.0"
imagePullPolicy: "IfNotPresent"
Expand Down