You can refer to the Installation Guide to setup OpenFunction.
- Create secret
Follow this guide to create a registry credential.
- Create function
For sample function below, modify the spec.image field in sample-java-app.yaml to your own container registry address:
apiVersion: core.openfunction.io/v1beta2
kind: Function
metadata:
name: sample-java-app
spec:
image: "<your registry name>/sample-buildah-java:latest"Use the following command to create this Function:
kubectl apply -f sample-java-app.yaml- Access function
You can observe the process of a function with the following command:
kubectl get functions.core.openfunction.io
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE
sample-java-app Succeeded Running builder-jgnzp serving-q6wdp http://sample-java-app.default.svc.cluster.local/ 22mThe Function.status.addresses field provides various methods for accessing functions.
Get Function addresses by running following command:
kubectl get function sample-java-app -o=jsonpath='{.status.addresses}'You will get the following address:
[{"type":"External","value":"http://sample-java-app.default.ofn.io/"},
{"type":"Internal","value":"http://sample-java-app.default.svc.cluster.local/"}]You can use the following command to create a pod in the cluster and access the function from the pod:
kubectl run curl --image=radial/busyboxplus:curl -i --tty
Access functions by the internal address:
curl http://sample-java-app.default.svc.cluster.localAccess functions by the external address:
To access the function via the Address of type
ExternalinFuntion.status, you should configure local domain first, see Configure Local Domain.
curl http://sample-java-app.default.ofn.io