Skip to content

Commit

Permalink
Add experimental Fedora CoreOS arm64 support on AWS
Browse files Browse the repository at this point in the history
* Add experimental `arch` variable to Fedora CoreOS AWS,
accepting amd64 (default) or arm64 to support native
arm64/aarch64 clusters or mixed/hybrid clusters with
a worker pool of arm64 workers
* Use experimental Poseidon-built aarch64 Fedora CoreOS AMIs
published to us-east-1, us-east-2, and us-west-1
* WARN: Our AMIs are experimental, may be removed at any
time, and will be removed when Fedora CoreOS publishes
official arm64 AMIs. Do NOT use in production
* Requires use of compatible CNI providers (currently,
flannel)
  • Loading branch information
dghubble committed Nov 13, 2020
1 parent 1113a22 commit a302daa
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 5 deletions.
24 changes: 24 additions & 0 deletions aws/fedora-coreos/kubernetes/ami.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ data "aws_ami" "fedora-coreos" {
values = ["Fedora CoreOS ${var.os_stream} *"]
}
}

# Experimental Fedora CoreOS arm64 / aarch64 AMIs from Poseidon
# WARNING: These AMIs will be removed when Fedora CoreOS publishes arm64 AMIs
# and may be removed for any reason before then as well. Do not use.
data "aws_ami" "fedora-coreos-arm" {
most_recent = true
owners = ["099663496933"]

filter {
name = "architecture"
values = ["arm64"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

filter {
name = "name"
values = ["fedora-coreos-*"]
}
}

6 changes: 3 additions & 3 deletions aws/fedora-coreos/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ resource "aws_instance" "controllers" {
}

instance_type = var.controller_type

ami = data.aws_ami.fedora-coreos.image_id
user_data = data.ct_config.controller-ignitions.*.rendered[count.index]
ami = var.arch == "arm64" ? data.aws_ami.fedora-coreos-arm.image_id : data.aws_ami.fedora-coreos.image_id
user_data = data.ct_config.controller-ignitions.*.rendered[count.index]

# storage
root_block_device {
Expand Down Expand Up @@ -63,6 +62,7 @@ data "template_file" "controller-configs" {

vars = {
# Cannot use cyclic dependencies on controllers or their DNS records
etcd_arch = var.arch == "arm64" ? "-arm64" : ""
etcd_name = "etcd${count.index}"
etcd_domain = "${var.cluster_name}-etcd${count.index}.${var.dns_zone}"
# etcd0=https://cluster-etcd0.example.com,etcd1=https://cluster-etcd1.example.com,...
Expand Down
3 changes: 2 additions & 1 deletion aws/fedora-coreos/kubernetes/fcc/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ systemd:
Wants=network-online.target network.target
After=network-online.target
[Service]
Environment=ETCD_IMAGE=quay.io/coreos/etcd:v3.4.12
Environment=ETCD_IMAGE=quay.io/coreos/etcd:v3.4.12${etcd_arch}
Type=exec
ExecStartPre=/bin/mkdir -p /var/lib/etcd
ExecStartPre=-/usr/bin/podman rm etcd
Expand Down Expand Up @@ -214,6 +214,7 @@ storage:
ETCD_PEER_CERT_FILE=/etc/ssl/certs/etcd/peer.crt
ETCD_PEER_KEY_FILE=/etc/ssl/certs/etcd/peer.key
ETCD_PEER_CLIENT_CERT_AUTH=true
ETCD_UNSUPPORTED_ARCH=arm64
passwd:
users:
- name: core
Expand Down
11 changes: 11 additions & 0 deletions aws/fedora-coreos/kubernetes/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,14 @@ variable "cluster_domain_suffix" {
default = "cluster.local"
}

variable "arch" {
type = string
description = "Container architecture (amd64 or arm64)"
default = "amd64"

validation {
condition = var.arch == "amd64" || var.arch == "arm64"
error_message = "The host arch must be amd64 or arm64."
}
}

1 change: 1 addition & 0 deletions aws/fedora-coreos/kubernetes/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module "workers" {
worker_count = var.worker_count
instance_type = var.worker_type
os_stream = var.os_stream
arch = var.arch
disk_size = var.disk_size
spot_price = var.worker_price
target_groups = var.worker_target_groups
Expand Down
24 changes: 24 additions & 0 deletions aws/fedora-coreos/kubernetes/workers/ami.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ data "aws_ami" "fedora-coreos" {
values = ["Fedora CoreOS ${var.os_stream} *"]
}
}

# Experimental Fedora CoreOS arm64 / aarch64 AMIs from Poseidon
# WARNING: These AMIs will be removed when Fedora CoreOS publishes arm64 AMIs
# and may be removed for any reason before then as well. Do not use.
data "aws_ami" "fedora-coreos-arm" {
most_recent = true
owners = ["099663496933"]

filter {
name = "architecture"
values = ["arm64"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

filter {
name = "name"
values = ["fedora-coreos-*"]
}
}

13 changes: 13 additions & 0 deletions aws/fedora-coreos/kubernetes/workers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,16 @@ variable "node_labels" {
description = "List of initial node labels"
default = []
}

# unofficial, undocumented, unsupported

variable "arch" {
type = string
description = "Container architecture (amd64 or arm64)"
default = "amd64"

validation {
condition = var.arch == "amd64" || var.arch == "arm64"
error_message = "The host arch must be amd64 or arm64."
}
}
2 changes: 1 addition & 1 deletion aws/fedora-coreos/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "aws_autoscaling_group" "workers" {

# Worker template
resource "aws_launch_configuration" "worker" {
image_id = data.aws_ami.fedora-coreos.image_id
image_id = var.arch == "arm64" ? data.aws_ami.fedora-coreos-arm.image_id : data.aws_ami.fedora-coreos.image_id
instance_type = var.instance_type
spot_price = var.spot_price > 0 ? var.spot_price : null
enable_monitoring = false
Expand Down

0 comments on commit a302daa

Please sign in to comment.