Giter Site home page Giter Site logo

thanh-nguyen-van / kubernetes-flask-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from btotharye/kubernetes-flask-example

0.0 0.0 0.0 49 KB

A basic flask app to test Kubernetes

Dockerfile 6.48% Python 23.19% JavaScript 25.39% HTML 24.36% Shell 20.58%

kubernetes-flask-example's Introduction

Guestbook Example

This example shows how to build a simple, multi-tier web application using Kubernetes and Docker.

We will be using Minikube to install our application locally.

Screenshot of App

screenshot

The example consists of:

  • A web frontend
  • A redis master (for storage), and a replicated set of redis 'slaves'.

The web frontend interacts with the redis master via javascript redis API calls.

Note: If you are running this example on a Google Container Engine installation, see this Google Container Engine guestbook walkthrough instead. The basic concepts are the same, but the walkthrough is tailored to a Container Engine setup.

Building Your Own Image

You can use the images already pre-defined in the kubernetes manifest files or you can use the below to create your own images and use them:

Replace the realbtotharye with your Dockerhub repository

docker build -t thanh3d/flask-kubernetes-nginx nginx/
docker push thanh3d/flask-kubernetes-nginx

docker build -t thanh3d/flask-kubernetes-redis flask-redis/
docker push thanh3d/flask-kubernetes-redis

Prerequisites

Make sure to install Minikube and then proceed with ensuring kubectl works and your cluster is up.

This example requires a running Kubernetes cluster. First, check that kubectl is properly configured by getting the cluster state:

$ kubectl cluster-info

If you see a url response, you are ready to go.

Quick Start

This section shows the simplest way to get the example work. If you want to know the details, you should skip this and read the rest of the example.

Start the guestbook with one command:

Ensure you are in the working dir

cd kubernetes-flask-example
$ kubectl create -f .
service "redis-master" created
deployment "redis-master" created
service "redis-slave" created
deployment "redis-slave" created
service "frontend" created
deployment "frontend" created

Then, list all your Services:

$ kubectl get services
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
frontend       NodePort    10.99.150.67    <none>        80:32515/TCP   34s
kubernetes     ClusterIP   10.96.0.1       <none>        443/TCP        48m
redis-master   ClusterIP   10.104.124.32   <none>        6379/TCP       34s
redis-slave    ClusterIP   10.104.43.119   <none>        6379/TCP       34s

Now with using minikube we can run the following to get the url for the service and access our app:

minikube service frontend --url

Use the URL given to us here and we can access it. If you are not using minikube then you can access this via the ClusterIP or setup a load balancer or proxy to access the application.

Clean up the guestbook:

$ kubectl delete -f .

kubernetes-flask-example's People

Contributors

btotharye 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.