Coder Social home page Coder Social logo

ruby-meetup-2018-11-27's Introduction

Knative examples for Ruby Meetup

Build demo images

docker build -t drnic/meetup:v1 meetup-v1
docker build -t drnic/meetup:v2 meetup-v2

docker push drnic/meetup:v1
docker push drnic/meetup:v2

Serving

Deploying v1

$ knctl deploy --service meetup --image drnic/meetup:v1

$ knctl curl -s meetup
Hello v1!

Local DNS routing to remote cluster

knctl curl is necessary because the generated routes aren't real. We can use kwt to map all Knative routes from local machine to remote Kubernetes cluster:

sudo -E kwt net start --dns-map-exec='knctl dns-map'

In another terminal:

curl meetup.default.example.com

Or can access website in local browser now.

Deploying v2

Knative does not require explicitly tagged images, but we can use them:

$ knctl deploy --service meetup --image drnic/meetup:v2

$ knctl curl -s meetup
Hello v2!

The difference between :v1 and :v2 is an environment variable TARGET. We can override this on our next deploy:

$ knctl deploy --service meetup --image drnic/meetup:v2 --env TARGET="revision 3"
$ knctl curl -s meetup
Hello revision 3!

Revisions are explicit

$ knctl revisions list
Service  Name          Tags      Annotations  Conditions  Age  Traffic
meetup   meetup-00003  latest    -            4 OK / 4    48s  100% -> meetup.default.example.com
~        meetup-00002  previous  -            4 OK / 4    1m   -
~        meetup-00001  -         -            4 OK / 4    10m  -

Rollout of traffic to new revisions

$ knctl deploy --service meetup --image drnic/meetup:v2 \
    --env TARGET="revision 4" \
    --managed-route=false
$ knctl rollout --route meetup -p meetup:previous=80% -p meetup:latest=20%

$ knctl revisions list
Service  Name          Tags      Annotations  Conditions  Age  Traffic
meetup   meetup-00004  latest    -            4 OK / 4    1m   20% -> meetup.default.example.com
~        meetup-00003  previous  -            4 OK / 4    3m   80% -> meetup.default.example.com
~        meetup-00002  -         -            2 OK / 4    3m   -
~        meetup-00001  -         -            2 OK / 4    12m  -

Later:

$ knctl rollout --route meetup -p meetup:previous=50% -p meetup:latest=50%
$ knctl revisions list
Service  Name          Tags      Annotations  Conditions  Age  Traffic
meetup   meetup-00004  latest    -            4 OK / 4    4m   50% -> meetup.default.example.com
~        meetup-00003  previous  -            4 OK / 4    6m   50% -> meetup.default.example.com
...

Finally:

$ knctl rollout --route meetup -p meetup:latest=100%
$ knctl revisions list
Revisions

Service  Name          Tags      Annotations  Conditions  Age  Traffic
meetup   meetup-00004  latest    -            4 OK / 4    5m   100% -> meetup.default.example.com
~        meetup-00003  previous  -            4 OK / 4    6m   -
...

ruby-meetup-2018-11-27's People

Contributors

drnic avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.