mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 10:19:35 +00:00
examples/terraform: Add install_disk optional override
This commit is contained in:
@@ -32,16 +32,16 @@ Copy the `terraform.tfvars.example` file to `terraform.tfvars`. Ensure `provider
|
||||
```hcl
|
||||
matchbox_http_endpoint = "http://matchbox.example.com:8080"
|
||||
matchbox_rpc_endpoint = "matchbox.example.com:8081"
|
||||
ssh_authorized_key = "ADD ME"
|
||||
|
||||
cluster_name = "demo"
|
||||
container_linux_version = "1353.7.0"
|
||||
container_linux_channel = "stable"
|
||||
ssh_authorized_key = "ADD ME"
|
||||
```
|
||||
|
||||
Provide an ordered list of controller names, MAC addresses, and domain names. Provide an ordered list of worker names, MAC addresses, and domain names.
|
||||
|
||||
```
|
||||
```hcl
|
||||
controller_names = ["node1"]
|
||||
controller_macs = ["52:54:00:a1:9c:ae"]
|
||||
controller_domains = ["node1.example.com"]
|
||||
@@ -50,18 +50,26 @@ worker_macs = ["52:54:00:b2:2f:86", "52:54:00:c3:61:77"]
|
||||
worker_domains = ["node2.example.com", "node3.example.com"]
|
||||
```
|
||||
|
||||
Finally, provide an `assets_dir` for generated manifests and a DNS name which you've setup to resolves to controller(s) (e.g. round-robin). Worker nodes and your kubeconfig will communicate via this endpoint.
|
||||
Provide an `assets_dir` for generated manifests and a DNS name which you've setup to resolves to controller(s) (e.g. round-robin). Worker nodes and your kubeconfig will communicate via this endpoint.
|
||||
|
||||
```
|
||||
```hcl
|
||||
k8s_domain_name = "cluster.example.com"
|
||||
asset_dir = "assets"
|
||||
```
|
||||
|
||||
### Options
|
||||
Note: The `cached-container-linux-install` profile will PXE boot and install Container Linux from matchbox [assets](https://github.com/coreos/matchbox/blob/master/Documentation/api.md#assets). If you have not populated the assets cache, use the `container-linux-install` profile to use public images (slower).
|
||||
|
||||
You may set `experimental_self_hosted_etcd = "true"` to deploy "self-hosted" etcd atop Kubernetes instead of running etcd on hosts directly. Warning, this is experimental and potentially dangerous.
|
||||
### Optional
|
||||
|
||||
The example above defines a Kubernetes cluster with 1 controller and 2 workers. Check the `multi-controller.tfvars.example` for an example which defines 3 controllers and one worker.
|
||||
You may set certain optional variables to override defaults. Set `experimental_self_hosted_etcd = "true"` to deploy "self-hosted" etcd atop Kubernetes instead of running etcd on hosts directly.
|
||||
|
||||
```hcl
|
||||
# install_disk = "/dev/sda"
|
||||
# container_linux_oem = ""
|
||||
# experimental_self_hosted_etcd = "true"
|
||||
```
|
||||
|
||||
The default is to create a Kubernetes cluster with 1 controller and 2 workers as an example, but check `multi-controller.tfvars.example` for an example which defines 3 controllers and 1 worker.
|
||||
|
||||
## Apply
|
||||
|
||||
@@ -95,8 +103,6 @@ Apply complete! Resources: 37 added, 0 changed, 0 destroyed.
|
||||
|
||||
You can now move on to the "Machines" section. Apply will loop until it can successfully copy the kubeconfig to each node and start the one-time Kubernetes bootstrapping process on a controller. In practice, you may see `apply` fail if it connects before the disk install has completed. Run terraform apply until it reconciles successfully.
|
||||
|
||||
Note: The `cached-container-linux-install` profile will PXE boot and install Container Linux from matchbox [assets](https://github.com/coreos/matchbox/blob/master/Documentation/api.md#assets). If you have not populated the assets cache, use the `container-linux-install` profile to use public images (slower).
|
||||
|
||||
## Machines
|
||||
|
||||
Power on each machine (with PXE boot device on next boot). Machines should network boot, install Container Linux to disk, reboot, and provision themselves as bootkube controllers or workers.
|
||||
|
||||
@@ -18,10 +18,11 @@ module "cluster" {
|
||||
worker_domains = "${var.worker_domains}"
|
||||
|
||||
# bootkube assets
|
||||
k8s_domain_name = "${var.k8s_domain_name}"
|
||||
asset_dir = "${var.asset_dir}"
|
||||
k8s_domain_name = "${var.k8s_domain_name}"
|
||||
asset_dir = "${var.asset_dir}"
|
||||
|
||||
# Optional
|
||||
install_disk = "${var.install_disk}"
|
||||
container_linux_oem = "${var.container_linux_oem}"
|
||||
experimental_self_hosted_etcd = "${var.experimental_self_hosted_etcd}"
|
||||
}
|
||||
|
||||
@@ -19,5 +19,6 @@ k8s_domain_name = "cluster.example.com"
|
||||
asset_dir = "assets"
|
||||
|
||||
# Optional
|
||||
# install_disk = "/dev/sda"
|
||||
# container_linux_oem = ""
|
||||
# experimental_self_hosted_etcd = "true"
|
||||
|
||||
@@ -78,8 +78,17 @@ variable "service_cidr" {
|
||||
CIDR IP range to assign Kubernetes services.
|
||||
The 1st IP will be reserved for kube_apiserver, the 10th IP will be reserved for kube-dns, the 15th IP will be reserved for self-hosted etcd, and the 200th IP will be reserved for bootstrap self-hosted etcd.
|
||||
EOD
|
||||
|
||||
type = "string"
|
||||
default = "10.3.0.0/16"
|
||||
}
|
||||
|
||||
# optional
|
||||
|
||||
variable "install_disk" {
|
||||
type = "string"
|
||||
default = "10.3.0.0/16"
|
||||
default = "/dev/sda"
|
||||
description = "Disk device to which the install profiles should install Container Linux (e.g. /dev/sda)"
|
||||
}
|
||||
|
||||
variable "container_linux_oem" {
|
||||
|
||||
@@ -37,6 +37,19 @@ ssh_authorized_key = "ADD ME"
|
||||
|
||||
Configs in `etcd3-install` configure the matchbox provider, define profiles (e.g. `cached-container-linux-install`, `etcd3`), and define 3 groups which match machines by MAC address to a profile. These resources declare that the machines should PXE boot, install Container Linux to disk, and provision themselves into peers in a 3-node etcd3 cluster.
|
||||
|
||||
Note: The `cached-container-linux-install` profile will PXE boot and install Container Linux from matchbox [assets](https://github.com/coreos/matchbox/blob/master/Documentation/api.md#assets). If you have not populated the assets cache, use the `container-linux-install` profile to use public images (slower).
|
||||
|
||||
### Optional
|
||||
|
||||
You may set certain optional variables to override defaults.
|
||||
|
||||
```hcl
|
||||
# install_disk = "/dev/sda"
|
||||
# container_linux_oem = ""
|
||||
```
|
||||
|
||||
## Apply
|
||||
|
||||
Fetch the [profiles](../README.md#modules) Terraform [module](https://www.terraform.io/docs/modules/index.html) which let's you use common machine profiles maintained in the matchbox repo (like `etcd3`).
|
||||
|
||||
```sh
|
||||
@@ -52,8 +65,6 @@ $ terraform apply
|
||||
Apply complete! Resources: 10 added, 0 changed, 0 destroyed.
|
||||
```
|
||||
|
||||
Note: The `cached-container-linux-install` profile will PXE boot and install Container Linux from matchbox [assets](https://github.com/coreos/matchbox/blob/master/Documentation/api.md#assets). If you have not populated the assets cache, use the `container-linux-install` profile to use public images (slower).
|
||||
|
||||
## Machines
|
||||
|
||||
Power on each machine (with PXE boot device on next boot). Machines should network boot, install Container Linux to disk, reboot, and provision themselves as a 3-node etcd3 cluster.
|
||||
|
||||
@@ -4,6 +4,7 @@ module "profiles" {
|
||||
matchbox_http_endpoint = "${var.matchbox_http_endpoint}"
|
||||
container_linux_version = "1353.7.0"
|
||||
container_linux_channel = "stable"
|
||||
install_disk = "${var.install_disk}"
|
||||
}
|
||||
|
||||
// Install Container Linux to disk before provisioning
|
||||
|
||||
@@ -3,4 +3,5 @@ matchbox_rpc_endpoint = "matchbox.example.com:8081"
|
||||
# ssh_authorized_key = "ADD ME"
|
||||
|
||||
# Optional
|
||||
# install_disk = "/dev/sda"
|
||||
# container_linux_oem = ""
|
||||
|
||||
@@ -13,6 +13,12 @@ variable "ssh_authorized_key" {
|
||||
description = "SSH public key to set as an authorized_key on machines"
|
||||
}
|
||||
|
||||
variable "install_disk" {
|
||||
type = "string"
|
||||
default = "/dev/sda"
|
||||
description = "Disk device to which the install profiles should install Container Linux (e.g. /dev/sda)"
|
||||
}
|
||||
|
||||
variable "container_linux_oem" {
|
||||
type = "string"
|
||||
default = ""
|
||||
|
||||
@@ -4,4 +4,5 @@ module "profiles" {
|
||||
matchbox_http_endpoint = "${var.matchbox_http_endpoint}"
|
||||
container_linux_version = "${var.container_linux_version}"
|
||||
container_linux_channel = "${var.container_linux_channel}"
|
||||
install_disk = "${var.install_disk}"
|
||||
}
|
||||
|
||||
@@ -77,6 +77,14 @@ EOD
|
||||
default = "10.3.0.0/16"
|
||||
}
|
||||
|
||||
# optional
|
||||
|
||||
variable "install_disk" {
|
||||
type = "string"
|
||||
default = "/dev/sda"
|
||||
description = "Disk device to which the install profiles should install Container Linux (e.g. /dev/sda)"
|
||||
}
|
||||
|
||||
variable "container_linux_oem" {
|
||||
type = "string"
|
||||
default = ""
|
||||
|
||||
@@ -21,7 +21,7 @@ storage:
|
||||
inline: |
|
||||
#!/bin/bash -ex
|
||||
curl "${ignition_endpoint}?{{.request.raw_query}}&os=installed" -o ignition.json
|
||||
coreos-install -d /dev/sda -C ${container_linux_channel} -V ${container_linux_version} -i ignition.json {{if index . "baseurl"}}-b {{.baseurl}}{{end}} {{if index . "container_linux_oem"}}-o {{.container_linux_oem}}{{end}}
|
||||
coreos-install -d ${install_disk} -C ${container_linux_channel} -V ${container_linux_version} -i ignition.json {{if index . "baseurl"}}-b {{.baseurl}}{{end}} {{if index . "container_linux_oem"}}-o {{.container_linux_oem}}{{end}}
|
||||
udevadm settle
|
||||
systemctl reboot
|
||||
passwd:
|
||||
|
||||
@@ -44,6 +44,7 @@ data "template_file" "container-linux-install-config" {
|
||||
container_linux_channel = "${var.container_linux_channel}"
|
||||
container_linux_version = "${var.container_linux_version}"
|
||||
ignition_endpoint = "${format("%s/ignition", var.matchbox_http_endpoint)}"
|
||||
install_disk = "${var.install_disk}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,3 +12,11 @@ variable "container_linux_channel" {
|
||||
type = "string"
|
||||
description = "Container Linux channel corresponding to the container_linux_version"
|
||||
}
|
||||
|
||||
# optional
|
||||
|
||||
variable "install_disk" {
|
||||
type = "string"
|
||||
default = "/dev/sda"
|
||||
description = "Disk device to which the install profiles should install Container Linux (e.g. /dev/sda)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user