Check out the post.
Build the images and spin up the containers:
$ docker-compose up -d --build
Run the migrations and seed the database:
$ docker-compose exec server python manage.py recreate_db
$ docker-compose exec server python manage.py seed_db
Test it out at:
Install and run Minikube:
- Install a Hypervisor (like VirtualBox or HyperKit) to manage virtual machines
- Install and Set Up kubectl to deploy and manage apps on Kubernetes
- Install Minikube
Start the cluster:
$ minikube start --vm-driver=virtualbox
$ minikube dashboard
Create the volume:
$ kubectl apply -f ./kubernetes/persistent-volume.yml
Create the volume claim:
$ kubectl apply -f ./kubernetes/persistent-volume-claim.yml
Create the secret object:
$ kubectl apply -f ./kubernetes/secret.yml
Create deployment:
$ kubectl create -f ./kubernetes/postgres-deployment.yml
Create the service:
$ kubectl create -f ./kubernetes/postgres-service.yml
Create the database:
$ kubectl get pods
$ kubectl exec postgres-<POD_IDENTIFIER> --stdin --tty -- createdb -U postgres books
Build and push the image to Docker Hub:
$ docker build -t harbor.azhangbaobao.cn/library/flask-kubernetes ./services/server
$ docker push harbor.azhangbaobao.cn/library/flask-kubernetes
Make sure to replace
mjhea0
with your Docker Hub namespace in the above commands as well as in kubernetes/flask-deployment.yml
Create the deployment:
$ kubectl create -f ./kubernetes/flask-deployment.yml
Create the service:
$ kubectl create -f ./kubernetes/flask-service.yml
Apply the migrations and seed the database:
$ kubectl get pods
$ kubectl exec flask-<POD_IDENTIFIER> --stdin --tty -- python manage.py recreate_db
$ kubectl exec flask-<POD_IDENTIFIER> --stdin --tty -- python manage.py seed_db
Enable and apply:
$ minikube addons enable ingress
$ kubectl apply -f ./kubernetes/minikube-ingress.yml
Add entry to /etc/hosts file:
访问 echo "$(minikube ip) flask.world" | sudo tee -a /etc/hosts 浏览器访问ip
Try it out:
Build and push the image to Docker Hub:
$ docker build -t harbor.azhangbaobao.cn/library/vue-kubernetes ./services/client -f ./services/client/Dockerfile-minikube
$ docker push harbor.azhangbaobao.cn/library/vue-kubernetes
Again, replace
mjhea0
with your Docker Hub namespace in the above commands as well as in kubernetes/vue-deployment.yml
Create the deployment:
$ kubectl create -f ./kubernetes/vue-deployment.yml
Create the service:
$ kubectl create -f ./kubernetes/vue-service.yml
Try it out at http://hello.world/.