time-service CI #619
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: time-service CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
schedule: | |
- cron: "15 7 * * *" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Сборка и тестирование микросервиса time-service (Docker image) | |
run: | | |
cd time-service | |
docker build . -t time-service:0.1.0 | |
docker run --name time-service-test -d -p 8080:8080 time-service:0.1.0 | |
# проверка точек доступа | |
curl localhost:8080/nanotime | |
curl localhost:8080/time | |
# остановка контейнера | |
docker stop time-service-test | |
- name: Запуск микросервиса time-service в локальном кластере minikube | |
run: | | |
cd time-service | |
minikube start | |
# локальные образы недоступны minikube по умолчанию в GH Actions | |
minikube image load time-service:0.1.0 | |
# развертывание | |
kubectl create deployment time-service --image time-service:0.1.0 | |
# ожидание запуска | |
kubectl rollout status deployment/time-service --timeout 60s | |
kubectl get pods -o wide | |
# имя отсека и его описание | |
POD=$(kubectl get pod -l app=time-service -o jsonpath="{.items[0].metadata.name}") | |
kubectl describe pod $POD | |
# вариант отладки | |
kubectl get events | |
- name: Проверка сервисов микросервиса time-service в локальном кластере minikube | |
run: | | |
kubectl expose deployment time-service --port=8080 --type=NodePort | |
kubectl get services | |
# получение локального URL - вызывать не будем, так как доступ сильно разнится от реализации | |
minikube service --url time-service | |
# переадресация на порт 9999 (фоновый режим, небольшое ожидание) | |
kubectl port-forward service/time-service 9999:8080 & | |
sleep 5s | |
curl localhost:9999/time | |
- name: Проверка журналов микросервиса time-service | |
run: | | |
kubectl logs deployment/time-service | |
- name: Масштабирование микросервиса time-service | |
run: | | |
kubectl scale --replicas=3 deployment/time-service | |
# ожидание запуска | |
kubectl rollout status deployment/time-service --timeout 60s | |
kubectl get pods -o wide | |
# авто-масштабирование | |
minikube addons enable metrics-server | |
kubectl autoscale deployment/time-service --min=1 --max=3 --cpu-percent=80 | |
- name: Удаление развертывания и сервиса микросервиса time-service | |
run: | | |
kubectl delete deployment/time-service | |
kubectl delete service/time-service |