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 Support, with Autodetection of AWS ECR Endpoint #1028

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKER_BINARY ?= packer
PACKER_VARIABLES := aws_region ami_name binary_bucket_name binary_bucket_region kubernetes_version kubernetes_build_date kernel_version docker_version containerd_version runc_version cni_plugin_version source_ami_id source_ami_owners source_ami_filter_name arch instance_type security_group_id additional_yum_repos pull_cni_from_github sonobuoy_e2e_registry ami_regions
PACKER_VARIABLES := aws_region ami_name binary_bucket_name binary_bucket_region kubernetes_version kubernetes_build_date kernel_version docker_version containerd_version runc_version cni_plugin_version source_ami_id source_ami_owners source_ami_filter_name arch instance_type security_group_id additional_yum_repos pull_cni_from_github sonobuoy_e2e_registry ami_regions enable_fips_mode

K8S_VERSION_PARTS := $(subst ., ,$(kubernetes_version))
K8S_VERSION_MINOR := $(word 1,${K8S_VERSION_PARTS}).$(word 2,${K8S_VERSION_PARTS})
Expand Down
17 changes: 15 additions & 2 deletions eks-worker-al2.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"runc_version": "1.1.3-1.amzn2",
"cni_plugin_version": "v0.8.6",
"pull_cni_from_github": "true",
"enable_fips_mode": "false",
"source_ami_id": "",
"source_ami_owners": "137112412989",
"source_ami_filter_name": "amzn2-ami-minimal-hvm-*",
Expand Down Expand Up @@ -115,7 +116,6 @@
{
"type": "shell",
"remote_folder": "{{ user `remote_folder`}}",
"expect_disconnect": true,
"script": "{{template_dir}}/scripts/upgrade_kernel.sh",
"environment_vars": [
"KUBERNETES_VERSION={{user `kubernetes_version`}}",
Expand All @@ -124,7 +124,20 @@
},
{
"type": "shell",
"pause_before": "90s",
"remote_folder": "{{ user `remote_folder`}}",
"script": "{{template_dir}}/scripts/enable_fips.sh",
"environment_vars": [
"ENABLE_FIPS_MODE={{user `enable_fips_mode`}}",
]
},
{
"type": "shell",
"inline": ["sudo reboot"],
"expect_disconnect": true,
"pause_after": "90s"
},
{
"type": "shell",
"remote_folder": "{{ user `remote_folder`}}",
"inline": [
"mkdir -p /tmp/worker/log-collector-script/"
Expand Down
8 changes: 7 additions & 1 deletion files/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@ if [[ "$MACHINE" != "x86_64" && "$MACHINE" != "aarch64" ]]; then
exit 1
fi

AWS_ECR_SUBDOMAIN="ecr"
# If FIPS is enabled on the machine, use the FIPS endpoint for AWS ECR.
if grep "fips=1" /etc/default/grub; then
AWS_ECR_SUBDOMAIN="ecr-fips"
fi

PAUSE_CONTAINER_ACCOUNT=$(get_pause_container_account_for_region "${AWS_DEFAULT_REGION}")
PAUSE_CONTAINER_IMAGE=${PAUSE_CONTAINER_IMAGE:-$PAUSE_CONTAINER_ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.$AWS_SERVICES_DOMAIN/eks/pause}
PAUSE_CONTAINER_IMAGE=${PAUSE_CONTAINER_IMAGE:-$PAUSE_CONTAINER_ACCOUNT.dkr.$AWS_ECR_SUBDOMAIN.$AWS_DEFAULT_REGION.$AWS_SERVICES_DOMAIN/eks/pause}
celestialorb marked this conversation as resolved.
Show resolved Hide resolved
PAUSE_CONTAINER="$PAUSE_CONTAINER_IMAGE:$PAUSE_CONTAINER_VERSION"

### kubelet kubeconfig
Expand Down
13 changes: 13 additions & 0 deletions scripts/enable_fips.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Install the necessary software and rebuild GRUB if we're instructed to enable FIPS support.
if [[ "$ENABLE_FIPS_MODE" == "true" ]]; then
# install and enable fips modules
sudo yum install -y dracut-fips openssl
sudo dracut -f

# enable fips in the boot command
sudo sed -i 's/^\(GRUB_CMDLINE_LINUX_DEFAULT=.*\)"$/\1 fips=1"/' /etc/default/grub

# rebuild grub
sudo grub2-mkconfig -o /etc/grub2.cfg
fi
2 changes: 0 additions & 2 deletions scripts/upgrade_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ else
echo "$KERNEL_VERSION is not a valid kernel version"
exit 1
fi

sudo reboot