3.3-scale-services

command
v0.0.0-...-e665a74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 21 Imported by: 0

README

Scale Service

  1. Slides scale service

  2. Open directory

cd /root/automation-technology/chapter03-deploy-scale-services/3.3-scale-services
  1. Register for https://hub.docker.com

  2. Create public repository call [your-docker-repository-name]/automation-technology

  3. Make sure you are logged in with your docker account

docker login
username:
password:
  1. Update file deploy.sh change
DOCKER_REPOSITORY=
to
DOCKER_REPOSITORY=[your-docker-repository-name]
  1. Run command (deploy.sh will be the file used to build your project, especially when it integrate with ci/cd)
./deploy.sh
  1. Run command
cd k8s
  1. Run command to start databases
kubectl apply -f 00-databases/.
  1. Run command to check if every pods is running
kubectl get po -n scale-service

Wait until every services is 1/1 Running

  1. Run command to start all application services
kubectl apply -f 01-application/.
  1. Notice register-api and mail-consumer is started in different pod (different deployment)
kubectl get po -n scale-service
NAME                             READY   STATUS    RESTARTS   AGE
register-api-57f5b7cc87-rh4f6    1/1     Running   0          30s
register-api-57f5b7cc87-vmvdc    1/1     Running   0          30s
mail-consumer-6f648fb4b5-b2nfc   1/1     Running   0          30s
  1. Look into sourcecode (main.go) to see that we read SERVICE_ID from env in deployment files Also look how register-api send message to mail-consumer

  2. Also we read CACHE_SERVER and MQ_SERVERS from env too, to not hardcoding configuration in sourcecode

  3. Run command

curl -X POST "http://kubernetes.docker.internal/citizen"
{"citizen_id":"xxxxx","status":"success"}
  1. Run command to see the logs of consumer Copy pod name then run
kubectl logs [pod-name] -n scale-service
Consumer: main.go 68 Mail has sent to {"citizen_id":"xxxxx"}
  1. Run command to scale consumers
kubectl scale -f 01-application/06-mail-consumer.yml --replicas=3
deployment.apps/mail-consumer scaled
  1. Run command to see consumer has scaled, while api has stay the same
kubectl get po -n scale-service
watch "microk8s kubectl get po -n scale-service"
  1. Run command to play with replicas down
kubectl scale -f 01-application/06-mail-consumer.yml --replicas=1
kubectl get po -n scale-service

See the mail-consumer scale down to 1

  1. Run command to cleanup
kubectl delete ns scale-service

Documentation

Overview

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Create and maintain by Chaiyapong Lapliengtrakul (chaiyapong@3dsinteractive.com), All right reserved (2021 - Present)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL