Skip to content

terraform state for deploying kubernetes to yandex cloud

Notifications You must be signed in to change notification settings

b4ck5p4c3/yc_kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Deploy K8s with terraform

Requirements:

  • OpenTofu
  • Yandex Cloud CLI
  • jq

Yandex Cloud CLI installation

  • MacOS:
    • Quick: curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
    • Brew: brew install yandex-cloud-cli
  • Linux:
    • Quick: curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
    • Other: Seek your distro repos!

See: https://yandex.cloud/en-ru/docs/cli/quickstart#install

Yandex Provider setup:

  1. Init yc profile with your account:
yc init
  1. Now, Inside Yandex Cloud Console go ahead and find service account terraform-deploy with following permissions: vpc.admin, compute.admin, load-balancer.admin.

  2. Create authorized key for your service account.

yc iam key create \
  --service-account-id <service_account_ID> \
  --description "<nickname>" \
  --output key.json
  1. Create CLI profile to run operations on behalf of the service account: yc config profile create <profile_name>

  2. Set the profile configuration:

yc config set service-account-key key.json 
yc config set cloud-id <cloud_ID> 
yc config set folder-id <folder_ID>
  1. Export credentials to your environment:
source ./env_prepare.sh

Warning

Tokens are alive for only 12 Hours!

Deploying configuration

  1. Clone current repo
  2. Run tofu init to initialize yandex provider

Warning

VPN Needed, otherwise use Yandex Mirror

Create .tofurc file with following code:

provider_installation {
  network_mirror {
    url = "https://terraform-mirror.yandexcloud.net/"
    include = ["registry.opentofu.org/*/*"]
  }
  direct {
    exclude = ["registry.opentofu.org/*/*"]
  }
}
  1. Test your terraform configuration with tofu plan
  2. Apply your configuration to yandex cloud: tofu apply
  3. Destroy everything in the cloud: tofu destroy

TODO:

  • switch in terraform configuration yandex_compute_placement_group to yandex_compute_instance_group
  • write ansible playbooks to deploy kubernetes cluster via kubespray
  • switch port in healthchecks to k8s cluster's port
  • add alerts? monitoring?

About

terraform state for deploying kubernetes to yandex cloud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published