Giter Site home page Giter Site logo

cirocosta / pizza-controller Goto Github PK

View Code? Open in Web Editor NEW
114.0 2.0 4.0 49 KB

That's right - order that nice pizza ๐Ÿ• with `kubectl`

Home Page: https://ops.tips/notes/kubernetes-pizza/

Makefile 1.93% Go 96.92% Dockerfile 1.15%
kubernetes crd controller controller-runtime

pizza-controller's Introduction

pizza-controller

making kubernetes do what it was always meant to do: order pizza.

usage

First, create a secret with the credit card information (yeah, this is fine, trust me) to be used during payment:

kind: Secret
apiVersion: v1
metadata:
  name: credit-card
stringData:
  number: 123343132314232
  expiration: 12/02
  securityCode: 123
  zip: m5d0l2

then, create a PizzaCustomer, the representation of you, the customer:

kind: PizzaCustomer
apiVersion: ops.tips/v1alpha1
metadata:
  name: you
spec:
  firstName: barack
  lastName: obama
  email: [email protected]
  phone: "31241323"
  streetNumber: "20"
  streetName: King St
  city: Toronto
  state: "ON"
  zip: m5lz8j

With the PizzaCustomer object created, we can see what's the closest store available for it:

$ kubectl get pizzacustomer
NAME              CLOSEST
you               store-123

Looking at the PizzaStore object, we can check out its menu:

$ kubectl get pizzastore store-123 -o yaml
kind: PizzaStore
metadata:
  name: store-123
spec:
  address: |
    51 Niagara St
    Toronto, ON M5V1C3
  id: "10391"
  phone: 416-364-3939
  products:
    - description: Unique Lymon (lemon-lime) flavor, clear, clean and crisp with no caffeine.
      id: 2LSPRITE
      name: Sprite
      size: 2 Litre

Knowing what's available to us, we can place the order:

kind: PizzaOrder
apiVersion: ops.tips/v1
metadata:
  name: ma-pizza
spec:
  yeahSurePlaceThisOrder: true  # otherwise, it'll just calculate the price
  storeRef: {name: store-123}
  customerRef: {name: you}
  payment:
    creditCardSecretRef: {name: cc}
  items:
    - ticker: 10SCREEN
      quantity: 1

To keep track of what's going on with your pizza, check out the order's status:

$ kubectl get pizzaorder ma-pizza
NAME    PRICE      ID                     CONDITION     AGE
order   9.030000   Wlz6HcE6BPlfQNlxDAXa   OrderPlaced   68m

what's next?

are you really into ordering pizza using kubectl?

like, really? are you sure?

here's what's missing:

  • well, any .. tests ๐Ÿด
  • order tracking (it's xml-based - SOAP stuff)
  • being more flexible with non-canadian folks (it's currently hardcoded for Canada, but could easily be changed)

at the moment I got my pizza .. development finished ๐Ÿ˜… maybe you'll carry it forward?

Installation

  1. apply the manifest
git clone https://github.com/cirocosta/pizza-controller
cd pizza-controller

# using `kapp` - recommended :)
#
kapp deploy -a pizza-controller -f ./config/release.yaml


# OR .. plain old kubectl
#
kubectl apply -f ./config/release.yaml

thanks

The API part was heavily inspired by these two projects:

Thank you!

LICENSE

MIT

pizza-controller's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.