Kubernetes (k8s) Deployment Controller

This repository demonstrates the auto-deployment of a website (http://35.232.213.37/) with updates in a Kubernetes Engine hosted on Google Cloud Platform.

How it works

Files for auto-deployment (selective)

app.py file

@app.route('/namespace')
  • create new namespace
@app.route('/deployment')
  • create new deployments
@app.route('/service')
  • create new services
@app.route('/build_docker_image', methods=['GET', 'POST'])
  • run build_docker_image.sh while received PUSH from Github

build_docker_image.sh file

##clone the github repo of WebSite and Dockerfile
git clone https://3caa02e0948b68640d4b36521dc20ab8e63bafb2@github.com/tuyuqi/docker_flask.git /tmp/docker_flask

##get the Dockerhub login infomation
cat /home/yuqi_tu/my_password.txt | docker login --username yuqitu --password-stdin

##build docker image
docker build -t yuqitu/flask-demo:simpleflaskwebsite /tmp/docker_flask/

##push the docker image to the dockerhub for further deployment
docker push yuqitu/flask-demo:simpleflaskwebsite

## remove the directory after pushed
rm -rf /tmp/docker_flask