As part of learning kubernetes, publish a Web Service that uses kubernetes to deepen my understanding of kubernetes.
About motivation of a Web Service, I knew the classic ciphers as we encountered in "The Code Book", and I came to be interesting in the coding of the cipher's algorithm, I built a simple encrypt / decript service.
html
css
Java
groovy
Grails
MySQL
Redis
Docker
Docker Toolbox
Docker Compose
Minikubne
nginx
** Note: There are three ways to run this applications. However the configurations like endpoint, port etc are a little different for each way. So below command steps doesn't guruantee to start application successfully. Please see it as just reference purpose.
Deploy applications to k8s
Docker
docker pull redis
k8s
kubectl apply -f Deploy/Redis/redis-deployment.yaml
kubectl apply -f Deploy/Redis/redis-service.yaml
Docker
pushd ./Data/mysql
docker image build -t kurakuda/ccg:mysql5.7 -f ./Dockerfile .
popd
k8s
kubectl apply -f Deploy/MySql/mysql-statefulset.yaml
kubectl apply -f Deploy/MySql/mysql-service.yaml
kubectl logs ccg-mysql -c ccg-mysql
kubectl exec -it -- mysql -u user -p
Docker
pushd ./App/classic-cipher-generation-app
docker image build -t kurakuda/ccg:app-grails -f ./Dockerfile .
popd
k8s
kubectl apply -f Deploy/App/app-deployment.yaml
kubectl apply -f Deploy/App/app-service.yaml
Docker
pushd ./Web
docker image build -t kurakuda/ccg:web-nginx -f ./Dockerfile .
popd
k8s
kubectl create configmap nginx-conf --from-file=Web/deployment/nginx.conf
kubectl create configmap server-conf --from-file=Web/deployment/server.conf
kubectl apply -f Deploy/Web/web-deployment.yaml
kubectl apply -f Deploy/Web/web-service.yaml
k8s
kubectl apply -f Deploy/LB/nodeport.yaml
Run Applications by using docker command
Prerequisite
Build images by command for k8s
Docker
docker run -d -p 6379:6379 --name ccg-redis redis:latest
Docker
docker run -d -p 3306:3306 -e MYSQL_DATABASE=classic_cipher_generation_db -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_ROOT_PASSWORD=rootpassword --name ccg-mysql kurakuda/ccg:mysql5.7
Docker
docker run -d -v :/app -e DB_HOST=db -p 8080:8080 -e DB_NAME=ccg-db -e DB_PORT=3306 -e DB_USERNAME=user -e DB_PASSWORD=password --name ccg-app kurakuda/ccg:app-grails
Docker
docker run -d -p 80:80 -v :/usr/share/nginx/html --name ccg-web kurakuda/ccg:web-nginx
Run Applications by using Docker Compose
- Start / stop the applications
docker-compose up -d --build
docker-compose down
- Enter the container
docker exec -it classic_cipher_generation_web bash
docker exec -it classic_cipher_generation_app bash
docker exec -it classic_cipher_generation_db bash
mysql -u user -ppassword classic_cipher_generation_db
docker exec -it classic_cipher_generation_redis bash
redis-cli
- Check the container log
docker logs classic_cipher_generation_app
docker logs classic_cipher_generation_db