Browse Source

feat: add hetzner

pull/3/head
Karan Sharma 1 year ago
parent
commit
6bb94f6f51
  1. 1
      hetzner/.env.sample
  2. 22
      hetzner/README.md
  3. 0
      hetzner/firewalls.tf
  4. 9
      hetzner/floating_ip.tf
  5. 26
      hetzner/main.tf
  6. 17
      hetzner/network.tf
  7. 3
      hetzner/variables.tf
  8. 10
      k8s/gitea/base/gitea/gitea-deployment.yml
  9. 8
      k8s/gitea/kubekutr.yml

1
hetzner/.env.sample

@ -0,0 +1 @@
TF_VAR_hcloud_token=

22
hetzner/README.md

@ -0,0 +1,22 @@
# Hetzner Infra
Uses [Terraform Provider for the Hetzner Cloud](https://github.com/hetznercloud/terraform-provider-hcloud) to provision resources for managing personal server where all the self-hosted applications are deployed.
## Getting Started
**Note**: Before you begin, export API token for performing any kind of ops with Hetzner API. Visit the [Cloud Console](https://console.hetzner.cloud), select your project, click "Security" on the left menu, switch to "Api Tokens" tab, click "GENERATE API TOKEN" button and follow the token creation master.
```sh
export TF_VAR_hcloud_token=<>
```
```shell
tf init
```
## Applying changes
```shell
tf plan
tf apply
```

0
hetzner/firewalls.tf

9
hetzner/floating_ip.tf

@ -0,0 +1,9 @@
resource "hcloud_floating_ip" "main_primary" {
type = "ipv4"
server_id = hcloud_server.main_primary.id
}
resource "hcloud_floating_ip_assignment" "main_primary" {
floating_ip_id = hcloud_floating_ip.main_primary.id
server_id = hcloud_server.main_primary.id
}

26
hetzner/main.tf

@ -0,0 +1,26 @@
provider "hcloud" {
token = var.hcloud_token
}
# Create a new SSH key
resource "hcloud_ssh_key" "karan" {
name = "Karan's SSH Key"
public_key = file("~/.ssh/mrkaran_rsa.pub")
}
# Create a `main-primary` instance
resource "hcloud_server" "main_primary" {
name = "main-primary"
server_type = "cx21"
image = "ubuntu-20.04"
location = "fsn1"
backups = true
labels = {
"group" = "hydra"
"service" = "main"
"role" = "primary"
"created_by" = "karan"
}
ssh_keys = ["${hcloud_ssh_key.karan.id}"]
}

17
hetzner/network.tf

@ -0,0 +1,17 @@
resource "hcloud_network" "hydra_private" {
name = "hydra-private"
ip_range = "10.0.0.0/8"
}
resource "hcloud_network_subnet" "hydra_private_subnet_0" {
network_id = hcloud_network.hydra_private.id
type = "cloud"
network_zone = "eu-central"
ip_range = "10.0.1.0/24"
}
resource "hcloud_server_network" "main_primary_ntwrk" {
server_id = hcloud_server.main_primary.id
subnet_id = hcloud_network_subnet.hydra_private_subnet_0.id
ip = "10.0.1.5"
}

3
hetzner/variables.tf

@ -0,0 +1,3 @@
variable "hcloud_token" {
# export TF_VAR_hcloud_token=<> in your env
}

10
k8s/gitea/base/gitea/gitea-deployment.yml

@ -20,7 +20,7 @@ spec:
spec:
containers:
- name: gitea
image: gitea/gitea:1.11
image: gitea/gitea:1.11.1
ports:
- containerPort: 3000
name: web-port
@ -28,11 +28,11 @@ spec:
name: ssh-port
resources:
requests:
memory: 150Mi
cpu: 200m
limits:
memory: 350Mi
memory: 450Mi
cpu: 400m
limits:
memory: 650Mi
cpu: 800m
volumeMounts:
- mountPath: /data
name: data

8
k8s/gitea/kubekutr.yml

@ -17,10 +17,10 @@ workloads:
port: 3000
- name: ssh-port
port: 22
cpuLimits: 400m
memoryLimits: 350Mi
cpuRequests: 200m
memoryRequests: 150Mi
cpuLimits: 800m
memoryLimits: 650Mi
cpuRequests: 400m
memoryRequests: 450Mi
# envVars:
# - name: "USER_UID"
# value: "1000"

Loading…
Cancel
Save