2018-02-26 23:06:18 +01:00
# Worker Pools
2018-02-27 07:16:34 +01:00
Typhoon AWS and Google Cloud allow additional groups of workers to be defined and joined to a cluster. For example, add worker pools of instances with different types, disk sizes, Container Linux channels, or preemptibility modes.
Internal Terraform Modules:
* `aws/container-linux/kubernetes/workers`
2018-04-26 11:41:04 +02:00
* `aws/fedora-atomic/kubernetes/workers`
2018-02-27 07:16:34 +01:00
* `google-cloud/container-linux/kubernetes/workers`
2018-04-26 11:41:04 +02:00
* `google-cloud/fedora-atomic/kubernetes/workers`
2018-02-27 07:16:34 +01:00
## AWS
2018-04-24 04:55:28 +02:00
Create a cluster following the AWS [tutorial ](../cl/aws.md#cluster ). Define a worker pool using the AWS internal `workers` module.
2018-02-27 07:16:34 +01:00
```tf
module "tempest-worker-pool" {
2018-07-20 09:36:58 +02:00
source = "git::https://github.com/poseidon/typhoon//aws/container-linux/kubernetes/workers?ref=v1.11.1"
2018-02-27 07:16:34 +01:00
providers = {
aws = "aws.default"
}
# AWS
vpc_id = "${module.aws-tempest.vpc_id}"
subnet_ids = "${module.aws-tempest.subnet_ids}"
security_groups = "${module.aws-tempest.worker_security_groups}"
# configuration
2018-03-04 02:52:01 +01:00
name = "tempest-worker-pool"
2018-02-27 07:16:34 +01:00
kubeconfig = "${module.aws-tempest.kubeconfig}"
ssh_authorized_key = "${var.ssh_authorized_key}"
count = 2
instance_type = "m5.large"
2018-05-09 07:38:05 +02:00
os_image = "coreos-beta"
2018-02-27 07:16:34 +01:00
}
```
Apply the change.
```
terraform apply
```
Verify an auto-scaling group of workers join the cluster within a few minutes.
### Variables
The AWS internal `workers` module supports a number of [variables ](https://github.com/poseidon/typhoon/blob/master/aws/container-linux/kubernetes/workers/variables.tf ).
#### Required
| Name | Description | Example |
|:-----|:------------|:--------|
| vpc_id | Must be set to `vpc_id` output by cluster | "${module.cluster.vpc_id}" |
| subnet_ids | Must be set to `subnet_ids` output by cluster | "${module.cluster.subnet_ids}" |
| security_groups | Must be set to `worker_security_groups` output by cluster | "${module.cluster.worker_security_groups}" |
2018-03-04 02:52:01 +01:00
| name | Unique name (distinct from cluster name) | "tempest-m5s" |
2018-02-27 07:16:34 +01:00
| kubeconfig | Must be set to `kubeconfig` output by cluster | "${module.cluster.kubeconfig}" |
2018-03-26 06:36:10 +02:00
| ssh_authorized_key | SSH public key for user 'core' | "ssh-rsa AAAAB3NZ..." |
2018-02-27 07:16:34 +01:00
#### Optional
| Name | Description | Default | Example |
|:-----|:------------|:--------|:--------|
| count | Number of instances | 1 | 3 |
| instance_type | EC2 instance type | "t2.small" | "t2.medium" |
2018-05-09 07:38:05 +02:00
| os_image | AMI channel for a Container Linux derivative | coreos-stable | coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta, flatcar-alpha |
2018-02-27 07:16:34 +01:00
| disk_size | Size of the disk in GB | 40 | 100 |
2018-04-29 22:19:00 +02:00
| spot_price | Spot price in USD for workers. Leave as default empty string for regular on-demand instances | "" | "0.10" |
2018-02-27 07:16:34 +01:00
| service_cidr | Must match `service_cidr` of cluster | "10.3.0.0/16" | "10.3.0.0/24" |
| cluster_domain_suffix | Must match `cluster_domain_suffix` of cluster | "cluster.local" | "k8s.example.com" |
2018-04-29 22:19:00 +02:00
Check the list of valid [instance types ](https://aws.amazon.com/ec2/instance-types/ ) or per-region and per-type [spot prices ](https://aws.amazon.com/ec2/spot/pricing/ ).
2018-02-26 23:06:18 +01:00
## Google Cloud
2018-04-24 04:55:28 +02:00
Create a cluster following the Google Cloud [tutorial ](../cl/google-cloud.md#cluster ). Define a worker pool using the Google Cloud internal `workers` module.
2018-02-26 23:06:18 +01:00
```tf
module "yavin-worker-pool" {
2018-07-20 09:36:58 +02:00
source = "git::https://github.com/poseidon/typhoon//google-cloud/container-linux/kubernetes/workers?ref=v1.11.1"
2018-02-26 23:06:18 +01:00
2018-03-04 01:21:38 +01:00
providers = {
google = "google.default"
}
2018-02-26 23:06:18 +01:00
# Google Cloud
2018-03-04 01:21:38 +01:00
region = "us-central1"
network = "${module.google-cloud-yavin.network_name}"
cluster_name = "yavin"
2018-02-27 07:16:34 +01:00
# configuration
2018-03-04 01:21:38 +01:00
name = "yavin-16x"
2018-02-27 07:16:34 +01:00
kubeconfig = "${module.google-cloud-yavin.kubeconfig}"
ssh_authorized_key = "${var.ssh_authorized_key}"
2018-02-26 23:06:18 +01:00
count = 2
machine_type = "n1-standard-16"
2018-02-27 07:16:34 +01:00
os_image = "coreos-beta"
2018-02-26 23:06:18 +01:00
preemptible = true
}
```
Apply the change.
```
terraform apply
```
Verify a managed instance group of workers joins the cluster within a few minutes.
```
$ kubectl get nodes
NAME STATUS AGE VERSION
2018-07-20 09:36:58 +02:00
yavin-controller-0.c.example-com.internal Ready 6m v1.11.1
yavin-worker-jrbf.c.example-com.internal Ready 5m v1.11.1
yavin-worker-mzdm.c.example-com.internal Ready 5m v1.11.1
yavin-16x-worker-jrbf.c.example-com.internal Ready 3m v1.11.1
yavin-16x-worker-mzdm.c.example-com.internal Ready 3m v1.11.1
2018-02-26 23:06:18 +01:00
```
### Variables
The Google Cloud internal `workers` module supports a number of [variables ](https://github.com/poseidon/typhoon/blob/master/google-cloud/container-linux/kubernetes/workers/variables.tf ).
#### Required
| Name | Description | Example |
|:-----|:------------|:--------|
2018-02-27 07:16:34 +01:00
| region | Must be set to `region` of cluster | "us-central1" |
| network | Must be set to `network_name` output by cluster | "${module.cluster.network_name}" |
2018-03-04 01:21:38 +01:00
| name | Unique name (distinct from cluster name) | "yavin-16x" |
| cluster_name | Must be set to `cluster_name` of cluster | "yavin" |
2018-02-27 07:16:34 +01:00
| kubeconfig | Must be set to `kubeconfig` output by cluster | "${module.cluster.kubeconfig}" |
2018-03-26 06:36:10 +02:00
| ssh_authorized_key | SSH public key for user 'core' | "ssh-rsa AAAAB3NZ..." |
2018-02-26 23:06:18 +01:00
#### Optional
| Name | Description | Default | Example |
|:-----|:------------|:--------|:--------|
2018-02-27 07:16:34 +01:00
| count | Number of instances | 1 | 3 |
| machine_type | Compute instance machine type | "n1-standard-1" | See below |
2018-03-26 06:36:10 +02:00
| os_image | Container Linux image for compute instances | "coreos-stable" | "coreos-alpha", "coreos-beta" |
2018-02-26 23:06:18 +01:00
| disk_size | Size of the disk in GB | 40 | 100 |
2018-02-27 07:16:34 +01:00
| preemptible | If true, Compute Engine will terminate instances randomly within 24 hours | false | true |
| service_cidr | Must match `service_cidr` of cluster | "10.3.0.0/16" | "10.3.0.0/24" |
| cluster_domain_suffix | Must match `cluster_domain_suffix` of cluster | "cluster.local" | "k8s.example.com" |
2018-02-26 23:06:18 +01:00
Check the list of valid [machine types ](https://cloud.google.com/compute/docs/machine-types ).