Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FIPS building support #1458

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ ifeq ($(call vercmp,$(kubernetes_version),gteq,1.25.0), true)
ami_component_description ?= (k8s: {{ user `kubernetes_version` }}, containerd: {{ user `containerd_version` }})
endif

OS=
AMI_VERSION ?= v$(shell date '+%Y%m%d')
AMI_VARIANT ?= amazon-eks
ifneq (,$(findstring al2023, $(PACKER_TEMPLATE_FILE)))
OS=-al2023
AMI_VARIANT := $(AMI_VARIANT)-al2023
endif

arch ?= x86_64
ifeq ($(arch), arm64)
instance_type ?= m6g.large
ami_name ?= amazon-eks-arm64-node$(OS)-$(K8S_VERSION_MINOR)-v$(shell date +'%Y%m%d')
AMI_VARIANT := $(AMI_VARIANT)-arm64
else
instance_type ?= m5.large
ami_name ?= amazon-eks-node$(OS)-$(K8S_VERSION_MINOR)-v$(shell date +'%Y%m%d')
endif
AlexSchultz-clumio marked this conversation as resolved.
Show resolved Hide resolved
ifeq ($(enable_fips), true)
AMI_VARIANT := $(AMI_VARIANT)-fips
endif
ami_name ?= $(AMI_VARIANT)-node-$(K8S_VERSION_MINOR)-$(AMI_VERSION)

ifeq ($(aws_region), cn-northwest-1)
source_ami_owners ?= 141808717104
Expand Down
1 change: 1 addition & 0 deletions doc/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Users have the following options for specifying their own values:
| `creator` | ```{{env `USER`}}``` | |
| `docker_version` | ```20.10.23-1.amzn2.0.1``` | |
| `encrypted` | ```false``` | |
| `enable_fips` | ```false``` | Install openssl and enable fips related kernel parameters |
| `instance_type` | *None* | |
| `kernel_version` | `""` | |
| `kms_key_id` | `""` | |
Expand Down
1 change: 1 addition & 0 deletions eks-worker-al2-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"containerd_version": "1.6.*",
"creator": "{{env `USER`}}",
"docker_version": "20.10.23-1.amzn2.0.1",
"enable_fips": "false",
"encrypted": "false",
"kernel_version": "",
"kms_key_id": "",
Expand Down
17 changes: 15 additions & 2 deletions eks-worker-al2.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"creator": null,
"docker_version": null,
"encrypted": null,
"enable_fips": null,
"instance_type": null,
"kernel_version": null,
"kms_key_id": null,
Expand Down Expand Up @@ -152,14 +153,26 @@
{
"type": "shell",
"remote_folder": "{{ user `remote_folder`}}",
"expect_disconnect": true,
"pause_after": "90s",
"script": "{{template_dir}}/scripts/upgrade_kernel.sh",
"environment_vars": [
"KUBERNETES_VERSION={{user `kubernetes_version`}}",
"KERNEL_VERSION={{user `kernel_version`}}"
]
},
{
"type": "shell",
"remote_folder": "{{ user `remote_folder`}}",
"script": "{{template_dir}}/scripts/enable-fips.sh",
"environment_vars": [
"ENABLE_FIPS={{user `enable_fips`}}"
]
},
{
"type": "shell",
"inline": ["sudo reboot"],
"expect_disconnect": true,
"pause_after": "90s"
},
cartermckinnon marked this conversation as resolved.
Show resolved Hide resolved
{
"type": "shell",
"remote_folder": "{{ user `remote_folder`}}",
Expand Down
8 changes: 7 additions & 1 deletion files/get-ecr-uri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ else
esac
fi

echo "${acct}.dkr.ecr.${region}.${aws_domain}"
AWS_ECR_SUBDOMAIN="ecr"
# if FIPS is enabled on the machine, use the FIPS endpoint.
if [[ "$(sysctl -n crypto.fips_enabled)" == 1 ]]; then
AWS_ECR_SUBDOMAIN="ecr-fips"
fi

echo "${acct}.dkr.${AWS_ECR_SUBDOMAIN}.${region}.${aws_domain}"
10 changes: 10 additions & 0 deletions scripts/enable-fips.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# https://aws.amazon.com/blogs/publicsector/enabling-fips-mode-amazon-linux-2/
if [[ "$ENABLE_FIPS" == "true" ]]; then
# install and enable fips modules
sudo yum install -y dracut-fips openssl
sudo dracut -f

# enable fips in the boot command
sudo /sbin/grubby --update-kernel=ALL --args="fips=1"
fi
2 changes: 0 additions & 2 deletions scripts/upgrade_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ sudo grubby \
sudo grubby \
--update-kernel=ALL \
--args="clocksource=tsc tsc=reliable"

sudo reboot