mirror of https://github.com/knative/docs.git
* Fix grpc-ping-go Still doesn't work, but at least it builds again. * Fix autoscale-go * Fix buildpack-app-dotnet * Fix buildpack-function-nodejs * Fix rest-api-go * Fix telemetry-go sample * Fix gitwebhook-go * Fix knative-routing-go * Address feedback from Ville. Prune boilerplate dep comment, fix cleanup command. |
||
---|---|---|
.. | ||
README.md | ||
sample.yaml |
README.md
Buildpack Sample Function
A sample function that demonstrates usage of Cloud Foundry buildpacks on Knative Serving, using the packs Docker images.
This deploys the riff square sample function for riff.
Prerequisites
Running
This sample uses the Buildpack build template in the build-templates repo.
First, install the Buildpack build template from that repo:
kubectl apply -f buildpack.yaml
Then you can deploy this to Knative Serving from the root directory via:
# Replace the token string with a suitable registry
REPO="gcr.io/<your-project-here>"
perl -pi -e "s@DOCKER_REPO_OVERRIDE@$REPO@g" serving/samples/buildpack-function-nodejs/sample.yaml
kubectl apply -f serving/samples/buildpack-function-nodejs/sample.yaml
Once deployed, you will see that it first builds:
$ kubectl get revision -o yaml
apiVersion: v1
items:
- apiVersion: serving.knative.dev/v1alpha1
kind: Revision
...
status:
conditions:
- reason: Building
status: "False"
type: BuildComplete
...
Once the BuildComplete
status becomes True
the resources will start getting created.
To access this service via curl
, we first need to determine its ingress address:
watch kubectl get svc knative-ingressgateway -n istio-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
knative-ingressgateway LoadBalancer 10.23.247.74 35.203.155.229 80:32380/TCP,443:32390/TCP,32400:32400/TCP 2d
Once the EXTERNAL-IP
gets assigned to the cluster, you can run:
# Put the Host name into an environment variable.
$ export SERVICE_HOST=`kubectl get route buildpack-function -o jsonpath="{.status.domain}"`
# Put the ingress IP into an environment variable.
$ export SERVICE_IP=`kubectl get svc knative-ingressgateway -n istio-system -o jsonpath="{.status.loadBalancer.ingress[*].ip}"`
# Curl the ingress IP "as-if" DNS were properly configured.
$ curl http://${SERVICE_IP}/ -H "Host: $SERVICE_HOST" -H "Content-Type: application/json" -d "33"
[response]
Cleaning up
To clean up the sample service:
kubectl delete -f serving/samples/buildpack-function-nodejs/sample.yaml