Giter VIP home page Giter VIP logo

django's Introduction

Kubenetes of Docker web patch 1.0

Date       : March 15,2016
Author    : Leno  Hou
E-mail     : [email protected]

All sourcecode can be download from https://github.com/houstar/django.git


1.  Architecture
Environment 
    libvirt-coreos with kubernetes on Ubuntu 15.04 ( as hypervisor ).


2. Install nfs-server to Hypervisor
#apt-get install nfs-server
#cat >> /etc/exports < EOF
/root/django/db  10.10.*.*(rw,no_root_squash)
EOF
#service nfs-server restart
#tar -xvf db.tar -C /root/django/
3.  MySQL-Master ReplicationController
#cat mysql-master-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql-master
  labels: 
    name: mysql-master
spec: 
  replicas: 1
  selector: 
    name: mysql-master
  template:
    metadata:
      labels:
        name: mysql-master
    spec:
      containers:
      - name: mysql-master
        image: mysql
        env: 
          - name: MYSQL_ROOT_PASSWORD
            value: "000000"
            name: MYSQL_DATABASE
            value: LTC_China_CommitInfo
        ports:
        - containerPort: 3306
          name: mysql-master
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        nfs:
          # This path must already exist.
          # We use this IP for PODs mount volume
          server: 10.10.0.100
          path: "/root/django/db" 


#kubectl create -f mysql-master-rc.yaml

4. MySQL-Master Service
#cat mysql-master-service.yaml

 apiVersion: v1
kind: Service
metadata:
  name: mysql-master
  labels:
    name: mysql-master
spec:
  ports:
  - port: 3306
    targetPort: 3306
  selector:
    name: mysql-master

#kubectl create -f mysql-master-service.yaml

5. Django ReplicationController
Step 1. Before create django rc, you should make venture/django image and push to docker hub.
#git clone https://github.com/houstar/django.git
#cd django/appache-django
#docker build -t venture/django:1.5.17 .
#docker login
#docker push venture/django:1.5.17
Step 2. Create Django RC
#cat django-rc.yaml
apiVersion: v1 
kind: ReplicationController 
metadata: 
  name: django 
  labels: 
    name: django 
spec: 
  replicas: 2
  selector: 
    name: django 
  template: 
    metadata: 
      labels: 
        name: django 
    spec: 
      containers: 
      - name: django 
        image: venture/django:1.5.17 
        env: 
        - name: MYSQL_ROOT_PASSWORD 
          value: "000000" 
          name: MYSQL_DATABASE 
          value: LTC_China_CommitInfo 
        ports: 
        - containerPort: 80 


#kubectl create -f django-rc.yaml
6. Django Service
#cat django-service.yaml
apiVersion: v1 
kind: Service 
metadata: 
  name: django 
  labels: 
    name: django 
spec: 
  type: NodePort 
  ports: 
  - port: 80 
    nodePort: 30001 
  selector: 
    name: django 

#kubectl create -f django-service.yaml

7. How to visit this Django service ?
Visit the Django Server by NodeIP:NodePort
#links http://192.168.10.3:30001

Publish Service to Internet
#ssh -CfNg -L 80:192.168.10.4:30001 [email protected]
Then open http://9.114.111.63 in your browser.

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.