chore(terraform): scaffold server provisioning layout
Empty main.tf, dns.tf, variables.tf, outputs.tf and versions.tf matching OKF_CV_Website/architecture/terraform.md. Variables and outputs are written out; resources stay unwritten until the server facts are settled.
This commit is contained in:
commit
f2493767bd
8 files changed
+114
No files matched your search
@@ -0,0 +1,10 @@
|
|||||||
|
# State stays local per the design; a lost state file means rebuild, which is
|
||||||
|
# the point. Credentials never enter Git.
|
||||||
|
*.tfstate
|
||||||
|
*.tfstate.*
|
||||||
|
*.tfvars
|
||||||
|
!terraform.tfvars.example
|
||||||
|
.terraform/
|
||||||
|
.terraform.lock.hcl
|
||||||
|
kubeconfig
|
||||||
|
crash.log
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Terraform
|
||||||
|
|
||||||
|
Provisions everything outside the cluster on `server0`. Rebuild is
|
||||||
|
`terraform apply` plus `kubectl apply -k deploy/`.
|
||||||
|
|
||||||
|
Layout follows `OKF_CV_Website/architecture/terraform.md`:
|
||||||
|
|
||||||
|
| File | Covers |
|
||||||
|
|---|---|
|
||||||
|
| `main.tf` | packages, 2 GB swap, containerd, `kubeadm init`, Calico, metrics-server, local-path provisioner, Caddy |
|
||||||
|
| `dns.tf` | apex A record at Cloudflare |
|
||||||
|
| `variables.tf` | server IP, SSH key, domain |
|
||||||
|
| `outputs.tf` | server IP, kubeconfig path, proxy URL |
|
||||||
|
| `versions.tf` | provider requirements, pinned after `terraform init` |
|
||||||
|
|
||||||
|
Out of scope: anything inside namespace `cv`. Namespace, quota and workloads
|
||||||
|
are applied once by hand or by CI and then live in `deploy/`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cp terraform.tfvars.example terraform.tfvars # fill in
|
||||||
|
export CLOUDFLARE_API_TOKEN=...
|
||||||
|
terraform init
|
||||||
|
terraform plan
|
||||||
|
terraform apply
|
||||||
|
```
|
||||||
|
|
||||||
|
State stays local and out of Git. The kubeconfig this produces stays on this
|
||||||
|
machine.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# DNS layer: A record for the apex domain pointing at the server's public IPv4.
|
||||||
|
# The zone is at Cloudflare; Caddy does its own ACME challenge, so no
|
||||||
|
# additional records are needed.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Server layer: packages, swap, containerd, kubeadm control plane, Calico,
|
||||||
|
# metrics-server, local-path provisioner, and Caddy.
|
||||||
|
#
|
||||||
|
# Terraform does not manage anything inside the cluster beyond the bootstrap
|
||||||
|
# (namespace cv, quota, addons). Workloads belong to kustomize.
|
||||||
|
# See OKF_CV_Website/architecture/terraform.md.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Values other tooling and the operator need after apply.
|
||||||
|
|
||||||
|
output "server_ip" {
|
||||||
|
description = "Public IPv4 of server0."
|
||||||
|
value = var.server_host
|
||||||
|
}
|
||||||
|
|
||||||
|
output "proxy_url" {
|
||||||
|
description = "Public URL served by Caddy."
|
||||||
|
value = "https://${var.domain}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Kubeconfig stays on this machine and never enters Git. Add its path here once
|
||||||
|
# main.tf writes it, e.g. "${path.module}/kubeconfig".
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Copy to terraform.tfvars and fill in. terraform.tfvars is Git-ignored.
|
||||||
|
server_host = ""
|
||||||
|
ssh_user = "root"
|
||||||
|
ssh_private_key_path = "~/.ssh/id_ed25519"
|
||||||
|
domain = "example.dev"
|
||||||
|
cloudflare_zone_id = ""
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Inputs: the server, its SSH access, and the domain.
|
||||||
|
# Nothing secret belongs here; secrets come from the environment or tfvars.
|
||||||
|
|
||||||
|
variable "server_host" {
|
||||||
|
description = "Public IP or hostname of server0."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ssh_user" {
|
||||||
|
description = "SSH user Terraform logs in as."
|
||||||
|
type = string
|
||||||
|
default = "root"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ssh_private_key_path" {
|
||||||
|
description = "Path to the private key on this machine."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "domain" {
|
||||||
|
description = "Apex domain served by the site, e.g. noelsabia.dev."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "cloudflare_zone_id" {
|
||||||
|
description = "Zone ID of the domain in Cloudflare."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Provider requirements.
|
||||||
|
|
||||||
|
# Set once the providers are chosen and versions verified with `terraform init`.
|
||||||
|
# DNS lives at Cloudflare, so that provider is expected here.
|
||||||
|
# terraform {
|
||||||
|
# required_version = ">= 1.9"
|
||||||
|
# required_providers {
|
||||||
|
# cloudflare = {
|
||||||
|
# source = "cloudflare/cloudflare"
|
||||||
|
# version = "~> x.y"
|
||||||
|
# }
|
||||||
|
# null = {
|
||||||
|
# source = "hashicorp/null"
|
||||||
|
# version = "~> 3.2"
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
Reference in new issue
Block a user