- Have OpenFaas installed: For example you can use
arkadeto easy install it on your k8s cluster.arkade install openfaas \ --set=gateway.upstreamTimeout=295s \ --set=gateway.readTimeout=300s \ --set=gateway.writeTimeout=300s \ --set=faasnetes.readinessProbe.timeoutSeconds=2 \ --set=faasnetes.livenessProbe.timeoutSeconds=2 \ --clusterrole - Notice the increase in timeouts, as many CLI scripts take longer.
- Run your functions in your own "sandbox" namespace. See Openfaas namespaces:
- Run
kubectl annotate <your-namespace> openfaas="1". - Run
kubectl apply -f installation/networkpolicy-allow-ingress-from-openfaas.yaml --namespace <your-namespace>
- Run
-
Deploy your StackState password as a secret into your k8s cluster. Use the pattern
sts-passwordfor the secret name in case you're working with a single StackState instance. -
In case you want to change the defaults from
cli-default.yml, copy the file intocli-override.ymland change what is needed:sts_username: Define the StackState usernamests_password: Define the k8s secret you'll use (sts-password)sts_base_api: Define the base api url (default:http://k8s-sts:8080)sts_receiver_api: Define the base api url (default:http://k8s-sts:8080)sts_admin_api: Define the base api url (default:http://k8s-sts:8080)sts_api_key: Define the API key (default:f3ec7af4027370b18cfe96c140a8f6b1)
-
In case you want to change the default download zip from
dl-default.yml, copy the file intodl-domain-override.ymland change what is needed. This is typically only relevant when loading themsp,banking,telco, ... scenario.dl_download_link: Contains the location where to find a zipped version of the scripts to run.dl_download_user: The username to be used for basic auth.dl_download_password: The name of the k8s secret that contains the password.
-
StackPacks:
- To make use of a stackpack in
stackpack-default.yml, copy the file intostackpack-override.ymland override thestackpack_download_user. - Also create a secret into your k8s cluster. Use the pattern
artifactory-passwordfor the secret name, unless you want to change that. If you change it, you'll have to setARTIFACTORY_PASSWORDwhen deploying. - If you want to make use of a different stackpack, change
stackpack_download_link. Default is thedemo-stackpack.
- To make use of a stackpack in
-
Deploy your function:
faas-cli deploy -f stscli.ymlor when you've defined changes in
cli-override.yml:CLI_OVERRIDE="./stscli/cli-override.yml" faas-cli deploy -f stscli.ymlor when you're using a different OpenFaas gateway:
faas-cli deploy -f stscli.yml -g "http://something:someport"or when you've changed the default name for the
sts-passwordsecret:STS_PASSWORD="sts-password-custom" faas-cli deploy -f stscli.ymlor when you've changed the download link:
DL_OVERRIDE="./stscli/msp-override.yml" faas-cli deploy -f msp.ymlor when you're working on a stackpack:
STACKPACK_OVERRIDE="./stscli/stackpack-demo-override.yml" faas-cli deploy -f demo.yml -
Creating a "Component Action" in StackState using OpenFaas:
- Use the function:
cli-graph-import. - Change the request body to
JSON. - Use the following as an example for the content:
{"nodes": [{ "_type":"ComponentActionDefinition", "bindQuery":"type = \"*\"", "description":"", "name":"Rollback to v5", "script":"Http.post('http://127.0.0.1:8080/async-function/msp-fix-problem')" }] }
- Use the function:
-
Items that can be overriden:
CLI_OVERRIDE: Override any value from./stscli/cli-default.yml.DL_OVERRIDE: Override any value from./stscli/dl-default.yml.STACKPACK_OVERRIDE: Override any value from./stscli/stackpack-default.yml.STS_PASSWORD: The k8s secret name that will need to be mapped onto/var/openfaas/secrets/(default:sts-password).ARTIFACTORY_PASSWORD: The k8s secret name that will need to be mapped onto/var/openfaas/secrets/(default:artifactory-password).
-
The
live-demostackpack:- Deploy via
CLI_OVERRIDE="./stscli/cli-override.yml" STACKPACK_OVERRIDE="./stscli/stackpack-live-demo-override.yml" faas-cli deploy -f live-demo.yml. - The function
stackpack-install-live-demo-stackpackrequires in the request bodystackpack install live-demo -p receiverUrl <your-stackstate-instance-endpoint>. Withyour-stackstate-instance-endpointfor examplehttp://abcdefghij.ngrok.iowhen exposing your local instance using ngrok.
- Deploy via