- Build, deploy, manage modern serverless workloads using Knative on Kubernetes
- Running my first application on Knative
- How to run an application easily on Knative
- Kubernetes, Istio and Knative already deployed.
- Install buildpack template:
kubectl apply -f https://raw.githubusercontent.com/knative/build-templates/master/buildpack/buildpack.yaml
- Have a Docker Registry ready (e.g. Docker Hub).
- Configure credentials for Docker Registry with
kubectl apply -f samples/docker.yml
:apiVersion: v1 kind: Secret metadata: name: basic-user-pass annotations: build.knative.dev/docker-0: https://index.docker.io # Described below type: kubernetes.io/basic-auth stringData: username: jszroberto password: <REMOVED> --- apiVersion: v1 kind: ServiceAccount metadata: name: build-bot secrets: - name: basic-user-pass - name: registry
- Deploying from image
bat samples/simple-app.yml kubectl apply -f samples/simple-app.yml
- Interact with the app
export HOST_URL=$(kubectl get route simple-app -o jsonpath='{.status.domain}') export IP_ADDRESS=$(kubectl get node -o 'jsonpath={.items[0].status.addresses[0].address}'):$(kubectl get svc knative-ingressgateway -n istio-system -o 'jsonpath={.spec.ports[?(@.port==80)].nodePort}') curl -H "Host: ${HOST_URL}" "http://${IP_ADDRESS}"
- Deploying from source code
bat samples/simple-app-from-source.yml kubectl apply -f samples/simple-app-from-source.yml
- Deploy same application and see how revisions are created with:
kubectl get revisions
- Curl an application scaled-to-zero and see how it creates a container in a matter of seconds:
curl ghost-app.default.knative.mybluemix-test.net
- You can generate some load againts the endpoint and see how the application scales:
go get github.com/tscolari/bender
bender --command "curl -H \"Host: ${HOST_URL}\" http://${IP_ADDRESS}" --concurrency 100 --interval 100ms --keep-running
Knife is a CLI which generates Knative configution and can be piped to kubectl
:
knife generate-service simple-app jszroberto/helloworld
- Deploying from image
knife generate-service simple-app jszroberto/helloworld | kubectl apply -f -
- Deploying from source code
knife generate-service simple-app jszroberto/simple-app-from-source \ -s build-bot \ -u https://github.com/jszroberto/helloworld-go \ -t buildpack \ -a IMAGE=jszroberto/simple-app-from-source \ | kubectl apply -f -
knctl
is an unofficial CLI for Knative
:
- Deploying from image
knctl deploy \ --namespace default \ --service simple-app \ --image jszroberto/helloworld
- Deploying from source code
knctl deploy \ --namespace default \ --service simple-app \ --git-url https://github.com/jszroberto/helloworld-go \ --git-revision master \ --service-account build-bot \ --template buildpack \ --image jszroberto/simple-app-from-source
- Deploy slides from directory:
knctl -n default deploy \
--service introduction-to-knative \
--directory=$PWD \
--service-account build-bot \
--image index.docker.io/jszroberto/introduction-to-knative \
--template buildpack