Based on https://swapi.dev
This is my diploma app, that could be used as a sample.
This repository contains:
- SWKB App code
- IaaC scripts to build infrastructure on Yandex Cloud
- Kubespray to set up Kubernetes on Yandex Cloud
To set up infrastructure on Yandex Cloud you need:
- Create account on Yandex cloud
- Get OAuth token, cloud id, folder id, zone (AZ). To get OAuth visit Yandex docs https://cloud.yandex.ru/docs/iam/concepts/authorization/oauth-token
- Create environment variables:
- YC_TOKEN=your_oauth_token
- YC_CLOUD_ID=your_cloud_id
- YC_FOLDER_ID=your_folder_id
- YC_ZONE=ru-central1-a (all Yandex Cloud AZs here)
- Create ssh-key (by default username is ubuntu) and save it to
~\.ssh\id_rsa
. You can change user/key parameters on variable.tf filessh-keygen -t rsa -b 2048 -C [email protected]
- Create two git-hub secrets (repository secrets) username: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN
Run terraform apply
from StarWarsKb.Infrastructure/Terraform directory.
If you want to set your db password then run terraform apply -var="db_password=your_pass"
By default terraform creates bastion host, 1 master node and 2 worker nodes. You can change these parameters, more info about count and size of nodes is here: StarWarsKb.Infrastructure/Terraform/README.md
Output would contain IP of bastion-host.
Connect to bastion host by ssh:
ssh ubuntu@bastion_public_ip
After that run installation script (I don't know what was wrong with userdata):
sudo cp /var/lib/cloud/instance/user-data.txt ~/magic.sh && sudo chmod 755 magic.sh && sudo ./magic.sh
kubectl
would be installed on master-host.