/kubernetes-demo

demo for running services in kubernetes.

Primary LanguagePHP

kubernetes-demo

demo for running services in kubernetes.

Steps

  1. install kubectl and helm, run helm init to init both server (install tiller) and client.

  2. Optional: build and push Docker images (if you need) under mysql/master, mysql/slave, archlinux-php, backend-service, backend-www. If you build and push images yourself, you need to change container image in all yaml files.

  3. Deploy MySQL master:

kubectl apply -f mysql/master/mysql-master-local.yaml
  1. Deploy MySQL slave:
kubectl apply -f mysql/slave/mysql-slave-local.yaml
  1. Deploy consul:

Change server.storage and server.storageClass to fit your requirement.

git submodule update --init
cd consul/consul-helm && helm install --name consul --set server.storage=20Gi,server.storageClass=alicloud-disk-ssd ./
  1. Deploy backend-service, which provides jsonrpc service for backend-www:
kubectl apply -f backend-service/backend-service.yaml
  1. Deploy backend-www, which calls backend-service and provides HTTP web access:
kubectl apply -f backend-www/backend-www.yaml
  1. Test if all are ok:
# get backend-www's EXTERNAL-IP
kubectl get svc

# If you have EXTERNAL-IP
curl -i -XPOST EXTERNAL-IP/user?name=fatcat

# If you have no EXTERNAL-IP
# Change xxxx to your Pod name
kubectl exec backend-www-xxxx -- curl -i -XPOST "backend-www/user?name=fatcat"

# Check fatcat_db.user table in mysql master or slave if data inserted
...

Pods