Giter Club home page Giter Club logo

diploma-terraform's Introduction

Предварительные настройки

Необходимый софт:

  • terraform
  • ansible
  • pip3
  • git
  • kubectl
  • jq

Необходимые реквизиты:

  • Аккаунт GitHub и Personal Access Token
  • Аккаунт Docker Hub
  • Аккаунт Yandex Cloud и Service Account, ключ авторизации сервисного аккаунта
  • Закрытый и открытый ключ .ssh в ~/.ssh

Что нужно настроить:

  • Настройте git на локальной машине для работы с репозиториями в GitHub, должна быть возможность делать push по ключу ssh, без ввода пароля

Как запустить

  1. Зайдите в папку 00-bucket

    • Заполните переменные 00-bucket/.auto.tfvars
    • Примените конфигурацию
      terraform init
      terraform apply -auto-approve
  2. Зайдите в папку 01-yandex

    • Инициализируйте Тераформ:
      terraform init
    • Создайте воркспейсы stage и prod:
      terraform workspace new stage
      terraform workspace new prod
    • Примените конфигурацию
      terraform workspace select stage 
      terraform apply -auto-approve
      terraform workspace select prod 
      terraform apply -auto-approve
  3. После применения конфигурации prod, Terraform выведет ссылки на все ресурсы, которые должны быть доступны извне: приложение, Grafana, Atlantis, Jenkins.

    Приблизительно так должен выглядеть вывод:

    Apply complete! Resources: 28 added, 0 changed, 0 destroyed.
    
    Outputs:
    
    control_nodes = [
    "name=diploma-control-prod-0, public=51.250.12.74, private=10.0.0.12",
    ]
    links = <<EOT
        App: http://51.250.12.74:30080
    Jenkins: http://51.250.12.74:30808
    Atlantis: http://51.250.12.74:30141
    Grafana: http://51.250.12.74:30300
    
    EOT
    worker_nodes = [
    "name=diploma-worker-prod-0, public=51.250.12.74, private=10.0.0.19",
    ]

    Приложение пока будет недоступно. Оно будет работать, когда поднимется Jenkins, соберёт первый билд и отправит в Docker Hub.

  4. Зайдите в папку 02-app:

    • Выполните скрипт, чтобы создать теги и отправить их в репозиторий:
      {
          tag_n=0
          date +%s > dummy
          git add dummy 
          tag_n=$((tag_n+1))
          git commit -m "tag $tag_n"
          git tag v0.0.$tag_n
          git push --tags origin main
      }
    • Через пару минут проверьте, что Jenkins собрал докер-образы и отправил в Docker Hub

Возможно потребуется создать докер-контейнер Jenkins с плагинами

Для задания был подготовлен докер-контейнер с Jenkins с нужными плагинами. Если со временем я его удалю, то вначале нужно будет сделать собственный. Это нужно делать вначале, иначе не получится автоматический развренуть Jenkins.

  1. Зайдите в папку 05-jenkins, запустите jenkins с docker-compose,
  2. Пройдите шаги мастера, подождите когда установятся планигы
  3. Добавьте плагин Basic Branch Build Strategies Plugin
  4. Содержимое папки data/plugins положите в 05-jenkins/plugins
  5. Создайте docker контейнер, отправьте в DockerHub
  6. Поправьте image в manifests/00-deployment.yml на созданный Вами

diploma-terraform's People

Contributors

pavelmm 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.