Skip to content

IBM/cloud-functions-operator

Repository files navigation

IBM Cloud Functions Operator

Build Status License

This project provides a Kubernetes operator for managing IBM Cloud Functions resources: actions, packages, rules and triggers.

Quick start

Prerequisites

  • A cluster running Kubernetes 1.11+
  • kubectl installed and configured.

Installing the operator

  1. Clone this repository
  2. Install the CRDs using kubectl:
$ kubectl apply -f config/crds
  1. Then install the operator:
$ kubectl apply -f config/manager -f config/rbac/

By default the operator is installed in the ibmcloud-operators namespace and is granted clustor-wide permissions.

Using the operators

Setting up IBM cloud credentials

By default, all operators look for the IBM cloud function credentials in the seed-defaults-owprops secret:

# Extract properties from .wskprops
AUTH=$(cat ~/.wskprops | grep 'AUTH' | awk -F= '{print $2}')
APIHOST=$(cat ~/.wskprops | grep 'APIHOST' | awk -F= '{print $2}')

# And create secret
kubectl create secret generic seed-defaults-owprops \
    --from-literal=apihost=$APIHOST \
    --from-literal=auth=$AUTH

Alternativalely, you can directly create a k8s secret

apiVersion: v1
kind: Secret
metadata:
  name: seed-defaults-owprops
stringData:
  apihost: localhost
  auth: "23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP"
  insecure: "true"

NOTE: be aware that all operators update IBM cloud function entities and can potentially override existing entities.

Deploying your first function

The Function resource kind allows the deployment of actions:

apiVersion: ibmcloud.ibm.com/v1alpha1
kind: Function
metadata:
  name: greetings
spec:
  codeURI: https://raw.githubusercontent.com/apache/incubator-openwhisk-catalog/master/packages/utils/echo.js
  runtime: nodejs:6
  parameters:
  - name: message
    value: Bonjour

Deploy it:

$ kubectl apply -f sample.yaml

wait a little bit and run:

$ ibmcloud wsk action invoke greetings -br

Learn more