GithubHelp home page GithubHelp logo

mts_sre's Introduction

SRE

Цель построения

SRE_schema

Построить postgesql + patroni пример

Накатить приложение в кубер

Приложение в kubernetes

Написать helm chart для разворачивания api в выделенном неймспейсе. Docker image лежит в публичном registry, разворачивать стоит актуальную версию ghcr.io/ldest/sre-course/api пример образа

нюансы по app

- DOTNET_ENVIRONMENT переменную выставляете в Development и вперед
- /app/Migrations/init.sql

описание сети в hub.cloud.mts.ru

подсеть network -- sre -- 192.168.10.0/24

haproxy -- (haproxy) точка входа через внешку 91.185.85.240  -- внутринний адрес 192.168.10.2
db1 -- (patroni + postgresql + haproxy) 192.168.10.3
db2 -- (patroni + postgresql + haproxy) 192.168.10.4
etcd1 -- (etcd)  192.168.10.5
etcd2 -- (etcd)  192.168.10.6
etcd3 -- (etcd)  192.168.10.7
namespace sre-cource-student-53
site name http://sre-app.rndhelp.ru

вывод списка городов http://sre-app.rndhelp.ru/cities , пока таблица пустая.

деплой postgresql

git clone https://github.com/vitabaks/postgresql_cluster.git

Заменить postgresql_cluster_my/inventory и postgresql_cluster_my/vars/main.yml на свои

!!! скорректировать значения postgresql_cluster_my/inventory под своей проект !!! !!! перед этим в vars/main.yml заменить пароли с "xxx" на свои !!!

в моем случае изменить

patroni_superuser_password: "xxx" 
patroni_replication_password: "xxx" 
pgbouncer_auth_password: "xxx"
monitoring_password: "xxx"
user_password: "xxx"
cp postgresql_cluster_my/inventory postgresql_cluster/inventory
cp postgresql_cluster_my/vars/main.yml postgresql_cluster/vars/main.yml

Подключаемся к БД (прошу обратить внимание что подкл. через gw в DMZ 192.168.10.0/24) но из внешки хост 91.185.85.240

# тут указать пароль который указывали ранее
psql -U postgresql -h 192.168.10.3 -p 5000 -W
# Создаем БД sre
CREATE DATABASE sre; 
# выдаем права для mydb-user
GRANT ALL PRIVILEGES ON DATABASE sre TO "mydb-user";

после этого извлекаем из образа (https://github.com/ldest/SreCourseApi/pkgs/container/sre-course%2Fapi) проекта sql миграцию , расположениую в /app/Migrations/init.sql и накатываем в БД sre

psql -U mydb-user -h 192.168.10.3 -p 5000 -W -d sre

# создаем в БД  sre структуру 
create table if not exists public.cities
(
    id   bigserial,
    name varchar(255)
);

create table if not exists public.forecast
(
    id          bigserial,
    "cityId"    bigint,
    "dateTime"  bigint,
    temperature integer,
    summary     text
);

деплой приложения через helm

!!! скорректировать значения в sre_app/.kube/app/values.yaml в поле secret под свои значения которые были указанны ранее в postgresql_cluster !!!

парметры подключения к БД уже открыто указаны в sre_app/.kube/app/values.yaml в secret кроме password, его зададим в ручную или через CI/CD

само приложение описано в helm шаблоне в каталоге sre_app/.kube/app

установка в кубере (пример):

helm upgrade --install -n sre-cource-student-53 --namespace sre-cource-student-53 --set secret.app.password="xxx" app sre_app/.kube/app/

Проверка работы сайта

Описание swagger

Проверка подключения к БД check_city

mts_sre's People

Contributors

kkulishov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.