Skip to content

Latest commit

 

History

History

introduction-to-knative

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Demos

Recommended content before running these demos

Prerequisites

  • 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

Demo 1: kubectl

  1. Deploying from image
    bat samples/simple-app.yml
    kubectl apply -f samples/simple-app.yml
  2. 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}"
    
  3. Deploying from source code
    bat samples/simple-app-from-source.yml
    kubectl apply -f samples/simple-app-from-source.yml
  4. Deploy same application and see how revisions are created with:
    kubectl get revisions

Demo 2: Autoscaling test

  1. 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
  2. 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

Demo 3: Knife

Knife is a CLI which generates Knative configution and can be piped to kubectl:

knife generate-service simple-app jszroberto/helloworld
  1. Deploying from image
    knife generate-service simple-app jszroberto/helloworld | kubectl apply -f -
  2. 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 -

Demo 4: knctl

knctl is an unofficial CLI for Knative:

  1. Deploying from image
    knctl deploy \
        --namespace default \
        --service simple-app \
        --image  jszroberto/helloworld
  2. 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
  3. 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

Further readings