Merge pull request #25 from HideyoshiNakazone/staging
Staging - Smaller Instances and Configures Swap Space
This commit is contained in:
12
.github/workflows/terraform.yml
vendored
12
.github/workflows/terraform.yml
vendored
@@ -42,4 +42,14 @@ jobs:
|
|||||||
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
|
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks
|
||||||
- name: Terraform Apply
|
- name: Terraform Apply
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
run: terraform apply -auto-approve -input=false
|
run: terraform apply -auto-approve -input=false
|
||||||
|
|
||||||
|
- name: Deploy Project via Dispatcher
|
||||||
|
if: env.TF_WORKSPACE == 'prod'
|
||||||
|
env:
|
||||||
|
DISPATCHER_EVENT: 'deploy-prod'
|
||||||
|
run: |
|
||||||
|
curl -X POST https://api.github.com/repos/HideyoshiNakazone/infra-hideyoshi.com/dispatches \
|
||||||
|
-H 'Accept: application/vnd.github.everest-preview+json' \
|
||||||
|
-u ${{ secrets.ACTIONS_KEY }} \
|
||||||
|
--data '{"event_type": "${{env.DISPATCHER_EVENT}}" }'
|
||||||
@@ -72,7 +72,7 @@ resource "aws_security_group" "project_pool" {
|
|||||||
|
|
||||||
resource "aws_instance" "main" {
|
resource "aws_instance" "main" {
|
||||||
ami = "ami-0af6e9042ea5a4e3e"
|
ami = "ami-0af6e9042ea5a4e3e"
|
||||||
instance_type = "t3a.small"
|
instance_type = "t2.micro"
|
||||||
vpc_security_group_ids = [ aws_security_group.project_pool.id ]
|
vpc_security_group_ids = [ aws_security_group.project_pool.id ]
|
||||||
|
|
||||||
key_name = aws_key_pair.ssh_key_main.key_name
|
key_name = aws_key_pair.ssh_key_main.key_name
|
||||||
@@ -92,6 +92,10 @@ resource "aws_instance" "main" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline = [
|
inline = [
|
||||||
|
"sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024",
|
||||||
|
"sudo /sbin/mkswap /var/swap.1",
|
||||||
|
"sudo chmod 600 /var/swap.1",
|
||||||
|
"sudo /sbin/swapon /var/swap.1",
|
||||||
"echo 'curl -sfL https://get.k3s.io | K3S_TOKEN=\"${var.k3s_token}\" K3S_KUBECONFIG_MODE=644 INSTALL_K3S_EXEC=\"server --disable=traefik\" sh -' >> /home/ubuntu/setup.sh",
|
"echo 'curl -sfL https://get.k3s.io | K3S_TOKEN=\"${var.k3s_token}\" K3S_KUBECONFIG_MODE=644 INSTALL_K3S_EXEC=\"server --disable=traefik\" sh -' >> /home/ubuntu/setup.sh",
|
||||||
"echo 'mkdir /home/ubuntu/.kube' >> /home/ubuntu/setup.sh",
|
"echo 'mkdir /home/ubuntu/.kube' >> /home/ubuntu/setup.sh",
|
||||||
"echo 'sudo chmod 644 /etc/rancher/k3s/k3s.yaml' >> /home/ubuntu/setup.sh",
|
"echo 'sudo chmod 644 /etc/rancher/k3s/k3s.yaml' >> /home/ubuntu/setup.sh",
|
||||||
@@ -130,6 +134,10 @@ resource "aws_instance" "worker" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline = [
|
inline = [
|
||||||
|
"sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024",
|
||||||
|
"sudo /sbin/mkswap /var/swap.1",
|
||||||
|
"sudo chmod 600 /var/swap.1",
|
||||||
|
"sudo /sbin/swapon /var/swap.1",
|
||||||
"echo 'curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC=\"agent\" K3S_TOKEN=\"${var.k3s_token}\" K3S_URL=\"${var.project_domain}:6443\" sh -s -' >> /home/ubuntu/setup.sh",
|
"echo 'curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC=\"agent\" K3S_TOKEN=\"${var.k3s_token}\" K3S_URL=\"${var.project_domain}:6443\" sh -s -' >> /home/ubuntu/setup.sh",
|
||||||
"chmod +x /home/ubuntu/setup.sh",
|
"chmod +x /home/ubuntu/setup.sh",
|
||||||
"while ! nc -z ${aws_instance.main.public_ip} 6443; do sleep 0.1; done",
|
"while ! nc -z ${aws_instance.main.public_ip} 6443; do sleep 0.1; done",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Configuring ssh keys
|
||||||
echo -e "${extra_key}" >> /home/ubuntu/.ssh/authorized_keys;
|
echo -e "${extra_key}" >> /home/ubuntu/.ssh/authorized_keys;
|
||||||
echo -e "${terraform_key}" >> /home/ubuntu/.ssh/authorized_keys;
|
echo -e "${terraform_key}" >> /home/ubuntu/.ssh/authorized_keys;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user