Code Monkey home page Code Monkey logo

15.2-clokub-homeworks's Introduction

Домашнее задание к занятию 15.2 "Вычислительные мощности. Балансировщики нагрузки".

  1. Создадал конфиг паблик бакета и загрузил в него картинку, предварительно сгенерив и прописав ключи доступа в main.tf
resource "yandex_storage_bucket" "desema-cloud-public-bucket" {
  bucket = "desema-cloud-public-bucket"
  acl    = "public-read"
}
resource "yandex_storage_object" "cat-picture" {
  bucket = "desema-cloud-public-bucket"
  key    = "cat.jpg"
  source = "./cat.jpg"
}
  1. Создал конфиг инстанс-группы с проверкой состояний.
resource "yandex_compute_instance_group" "ig-1" {
  name               = "fixed-ig"
  service_account_id = yandex_iam_service_account.ig-manager.id
  instance_template {
    platform_id = "standard-v1"
    resources {
      memory = 2
      cores  = 2
    }
    boot_disk {
      mode = "READ_WRITE"
      initialize_params {
        image_id = "fd827b91d99psvq5fjit"
      }
    }
    scheduling_policy {
      preemptible = true
    }
    network_interface {
      network_id = yandex_vpc_network.terra_network.id
      subnet_ids = ["${yandex_vpc_subnet.public.id}"]
    }
    metadata = {
      user-data          = "${file("meta.txt")}"
      serial-port-enable = 1
    }
  }
  scale_policy {
    fixed_scale {
      size = 3
    }
  }
  allocation_policy {
    zones = ["ru-central1-a"]
  }
  deploy_policy {
    max_unavailable = 1
    max_expansion   = 0
  }
  load_balancer {
    target_group_name = "balancer-target"
  }
  health_check {
    interval            = 5
    timeout             = 1
    healthy_threshold   = 2
    unhealthy_threshold = 2
    http_options {
      port = 80
      path = "/"
    }
  }
}

Убедился в работоспособности хелсчеков остановив апач на одной из вм. после этого она автоматически была пересоздана.

  1. После добавил в настройки сети секцию с балансиром:
resource "yandex_lb_network_load_balancer" "balancer" {
  name = "balancer"

  listener {
    name = "listener"
    port = 80
    external_address_spec {
      ip_version = "ipv4"
    }
  }
  attached_target_group {
    target_group_id = yandex_compute_instance_group.ig-1.load_balancer[0].target_group_id

    healthcheck {
      name = "http"
      http_options {
        port = 80
        path = "/"
      }
    }
  }
}

Проверил работоспособность и удалением вм и заменой index.html

15.2-clokub-homeworks's People

Contributors

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