Giter Club home page Giter Club logo

k8s-review-app's Introduction

Review app example

Creates review apps. Tested with minikube.

Starting the cluster

minikube start
minikube addon enable ingress
minikube addon enable registry
kubectl --namespace=kube-system port-forward service/registry 80:5000

If you want to poke around in the dashboard:

minikube addon enable dashboard
minikube dashboard

Deploying master

In one terminal:

cd example-app
eval "$(minikube docker-env)"
docker build -t localhost:5000/example:master .
docker push localhost:5000/example:master

In another terminal:

cd review-app
npm ci
node . example master

Deploying another branch

In one terminal:

cd example-app
# ... after making changes to index.html ...
eval "$(minikube docker-env)"
docker build -t localhost:5000/example:some-feature .
docker push localhost:5000/example:some-feature

In another terminal:

cd review-app
node . example some-feature

Verifying

If the above instructions have gone well, you should have a pair of ingresses created for minikube:

$ kubectl --namespace=review get ingress
NAME                   HOSTS                             ADDRESS           PORTS   AGE
example-master         master.example.review.app         192.168.122.141   80      93s
example-some-feature   some-feature.example.review.app   192.168.122.141   80      91s

You can verify that the apps are running side-by-side by curling the ingress IP and overriding the host:

$ curl -H 'Host: master.example.review.app' http://192.168.122.141/
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Example Application</title>
  </head>
  <body>
    <p>This is the example app running on <code>master</code>.</p>
  </body>
</html>
$ curl -H 'Host: some-feature.example.review.app' http://192.168.122.141/
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Example Application</title>
  </head>
  <body>
    <p>This is the example app running on a <em>review branch!</em></p>
  </body>
</html>

Cleaning up

Objects are tagged with repo, branch, and tag metadata. (repo and branch are forced lowercase due to Kubernetes naming restrictions.)

# To delete a single review app:
kubectl delete svc,deployments,ingress -l app=example-some-feature

# To blow away an entire repo's apps:
kubectl delete svc,deployments,ingress -l repo=example

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.