-
Notifications
You must be signed in to change notification settings - Fork 35
Document Nebari Security Config Options #539
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2e82b8a
Create enhanced-security.md
tylergraff 04fc5c5
Create container-sources-2024-09-1.md
tylergraff 0c35f6c
add more containers
tylergraff 150541e
Update enhanced-security.md
tylergraff 1e19131
Update and rename container-sources-2024-09-1.md to container-sources.md
tylergraff 331ec51
Update index.mdx
tylergraff 460716f
yarn run format:fix
aa7ee5d
fix broken link
d4d3f9a
update to wholesale repo specification
tylergraff 92a4cb2
update to as-merged features
tylergraff 2ced8d3
Merge branch 'main' into security-options
tylergraff be8f153
yarn format:fix
8dddb65
yarn format:fix for files peripheral to my changes
ec5e354
remove unmerged feature
tylergraff ed6190b
Clarify load balancer subnet notes
tylergraff 7e92f17
Note calling out image repository token auth considerations
tylergraff 528123a
format:fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| ## Deploying and Running Nebari from a Private Container Repository | ||
|
|
||
| Nebari deploys and runs FOSS components as containers running in Kubernetes. | ||
| By default, Nebari sources each container from the container's respective public repository, typically `docker.io` or `quay.io`. | ||
| This introduces supply-chain concerns for security-focused customers. | ||
|
|
||
| One solution to these supply-chain concerns is to deploy Nebari from private locally-mirrored containers: | ||
|
|
||
| - Create a controlled private container repository (e.g. ECR) | ||
| - Mirror all containers used by Nebari into this private container repository | ||
| - Use the `pre_bootstrap_command` mechanism in `nebari-config.yaml` to specify the mirrored container repo | ||
|
|
||
| Deploying Nebari in this fashion eliminates significant supply chain surface-area, but requires identifying all containers used by Nebari. | ||
|
|
||
| The following configurations demonstrate how to specify a private repo denoted by the string `[PRIVATE_REPO]`. | ||
|
|
||
| **Note:** Authorization tokens are used in the examples below. It is important for administrators to understand the expiration policy of these tokens, because the Nebari k8s cluster may in some cases need to **use these tokens to pull container images at any time during run-time operation**. | ||
|
|
||
| ### Set ECR as default container registry mirror | ||
|
|
||
| ``` | ||
| amazon_web_services: | ||
| node_groups: | ||
| general: | ||
| instance: m5.2xlarge | ||
| launch_template: | ||
| pre_bootstrap_command: | | ||
| #!/bin/bash | ||
| # Verify that IP forwarding is enabled for worker nodes, as is required for containerd | ||
| if [[ $(sysctl net.ipv4.ip_forward | grep "net.ipv4.ip_forward = 1") ]]; then echo "net.ipv4.ip_forward is on"; else sysctl -w net.ipv4.ip_forward=1; fi | ||
| # Set ECR as default container registry mirror | ||
| mkdir -p /etc/containerd/certs.d/_default | ||
| ECR_TOKEN="$(aws ecr get-login-password --region us-east-1)" | ||
| BASIC_AUTH="$(echo -n "AWS:$ECR_TOKEN" | base64 -w 0)" | ||
| cat <<-EOT > /etc/containerd/certs.d/_default/hosts.toml | ||
| [host."https://[PRIVATE_REPO].dkr.ecr.us-east-1.amazonaws.com"] | ||
| capabilities = ["pull", "resolve"] | ||
| [host."https://[PRIVATE_REPO].dkr.ecr.us-east-1.amazonaws.com".header] | ||
| authorization = "Basic $BASIC_AUTH" | ||
| EOT | ||
|
|
||
| ``` | ||
|
|
||
| ### Set GitLab CR as default container registry mirror | ||
|
|
||
| ``` | ||
| # Set GitLab CR as default container registry mirror in hosts.toml; | ||
| # must have override_path set if project/group names don't match upstream container | ||
| amazon_web_services: | ||
| node_groups: | ||
| general: | ||
| instance: m5.2xlarge | ||
| launch_template: | ||
| pre_bootstrap_command: | | ||
| #!/bin/bash | ||
| # Verify that IP forwarding is enabled for worker nodes, as is required for containerd | ||
| if [[ $(sysctl net.ipv4.ip_forward | grep "net.ipv4.ip_forward = 1") ]]; then echo "net.ipv4.ip_forward is on"; else sysctl -w net.ipv4.ip_forward=1; fi | ||
| # Set default container registry mirror in hosts.toml; must have override_path set if project/group names don't match upstream container | ||
| CONTAINER_REGISTRY_URL="[PRIVATE_REPO]" | ||
| CONTAINER_REGISTRY_USERNAME="[username]" | ||
| CONTAINER_REGISTRY_TOKEN="[token]" | ||
| CONTAINER_REGISTRY_GROUP=as-nebari | ||
| CONTAINER_REGISTRY_PROJECT=nebari-test | ||
| mkdir -p /etc/containerd/certs.d/_default | ||
| cat <<-EOT > /etc/containerd/certs.d/_default/hosts.toml | ||
| [host."https://$CONTAINER_REGISTRY_URL/v2/$CONTAINER_REGISTRY_GROUP/$CONTAINER_REGISTRY_PROJECT"] | ||
| override_path = true | ||
| capabilities = ["pull", "resolve"] | ||
| EOT | ||
|
|
||
| # Set containerd registry config auth in config.d .toml import dir | ||
| mkdir -p /etc/containerd/config.d | ||
| cat <<EOT | sudo tee /etc/containerd/config.d/config-import.toml | ||
| version = 2 | ||
| [plugins."io.containerd.grpc.v1.cri".registry] | ||
| config_path = "/etc/containerd/certs.d:/etc/docker/certs.d" | ||
| [plugins."io.containerd.grpc.v1.cri".registry.auths] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.configs] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.configs."$CONTAINER_REGISTRY_URL".auth] | ||
| username = "$CONTAINER_REGISTRY_USERNAME" | ||
| password = "$CONTAINER_REGISTRY_TOKEN" | ||
| EOT | ||
| ``` | ||
|
|
||
| ### Set GitLab CR as default container registry mirror, with custom Client SSL/TLS Certs | ||
|
|
||
| ``` | ||
| # must have override_path set if project/group names don't match upstream container | ||
| # Also add/set GitLab Client SSL/TLS Certificate for Containerd | ||
| amazon_web_services: | ||
| node_groups: | ||
| general: | ||
| instance: m5.2xlarge | ||
| launch_template: | ||
| pre_bootstrap_command: | | ||
| #!/bin/bash | ||
| # Verify that IP forwarding is enabled for worker nodes, as is required for containerd | ||
| if [[ $(sysctl net.ipv4.ip_forward | grep "net.ipv4.ip_forward = 1") ]]; then echo "net.ipv4.ip_forward is on"; else sysctl -w net.ipv4.ip_forward=1; fi | ||
| # Set default container registry mirror in hosts.toml; must have override_path set if project/group names don't match upstream container | ||
| CONTAINER_REGISTRY_URL="[PRIVATE_REPO]" | ||
| CONTAINER_REGISTRY_USERNAME="[username]" | ||
| CONTAINER_REGISTRY_TOKEN="[token]" | ||
| CONTAINER_REGISTRY_GROUP=as-nebari | ||
| CONTAINER_REGISTRY_PROJECT=nebari-test | ||
| mkdir -p /etc/containerd/certs.d/_default | ||
| cat <<-EOT > /etc/containerd/certs.d/_default/hosts.toml | ||
| [host."https://$CONTAINER_REGISTRY_URL/v2/$CONTAINER_REGISTRY_GROUP/$CONTAINER_REGISTRY_PROJECT"] | ||
| override_path = true | ||
| capabilities = ["pull", "resolve"] | ||
| client = ["/etc/containerd/certs.d/$CONTAINER_REGISTRY_URL/client.pem"] | ||
| EOT | ||
|
|
||
| # Set containerd registry config auth in config.d .toml import dir | ||
| mkdir -p /etc/containerd/config.d | ||
| cat <<EOT | sudo tee /etc/containerd/config.d/config-import.toml | ||
| version = 2 | ||
| [plugins."io.containerd.grpc.v1.cri".registry] | ||
| config_path = "/etc/containerd/certs.d:/etc/docker/certs.d" | ||
| [plugins."io.containerd.grpc.v1.cri".registry.auths] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.configs] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.configs."$CONTAINER_REGISTRY_URL".auth] | ||
| username = "$CONTAINER_REGISTRY_USERNAME" | ||
| password = "$CONTAINER_REGISTRY_TOKEN" | ||
| EOT | ||
|
|
||
| # Add client key/cert to containerd | ||
| mkdir -p /etc/containerd/certs.d/$CONTAINER_REGISTRY_URL | ||
| cat <<-EOT >> /etc/containerd/certs.d/$CONTAINER_REGISTRY_URL/client.pem | ||
| -----BEGIN CERTIFICATE----- | ||
| XzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzZx | ||
| ZxyzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzXz | ||
| -----END CERTIFICATE----- | ||
| -----BEGIN PRIVATE KEY----- | ||
| XzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzZx | ||
| ZxyzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzXz | ||
| -----END PRIVATE KEY----- | ||
| EOT | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| ## Nebari Security Considerations | ||
|
|
||
| The security of _AWS Nebari_ deployments can be enhanced through the following deployment configuration options in `nebari-config.yaml`: | ||
|
|
||
| - **Explicit definition of container sources** | ||
| This option allows for the use of locally mirrored, security-hardened, or otherwise customized container images in place of the containers used by default. | ||
| See: [container-sources](container-sources.md) | ||
|
|
||
| - **Installation of custom SSL certificate(s) into EKS hosts** | ||
| Install private certificates used by (e.g.) in-line content inspection engines which re-encrypt traffic. | ||
|
|
||
| ``` | ||
| # Add client certificate to CA trust on node | ||
| amazon_web_services: | ||
| node_groups: | ||
| general: | ||
| instance: m5.2xlarge | ||
| launch_template: | ||
| pre_bootstrap_command: | | ||
| #!/bin/bash | ||
| cat <<-EOT >> /etc/pki/ca-trust/source/anchors/client.pem | ||
| -----BEGIN CERTIFICATE----- | ||
| XzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzZx | ||
| ZxyzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzXz | ||
| -----END CERTIFICATE----- | ||
| EOT | ||
| sudo update-ca-trust extract | ||
| ``` | ||
|
|
||
| - **Private EKS endpoint configuration** | ||
| Mirrors the corresponding AWS console option, which routes all EKS traffic within the VPC. | ||
|
|
||
| ``` | ||
| amazon_web_services: | ||
| eks_endpoint_access: private # valid values: [public, private, public_and_private] | ||
| ``` | ||
|
|
||
| - **Deploy into existing subnets** | ||
| Instructs Nebari to be deployed into existing subnets, rather than creating its own new subnets. | ||
| An advantage of deploying to existing subnets is the ability to use private subnets. Note that the **ingress load-balancer-annotation** must be set appropriately based on the type (private or public) of subnet. | ||
|
|
||
| ``` | ||
| existing_subnet_ids: | ||
| - subnet-0123456789abcdef | ||
| - subnet-abcdef0123456789 | ||
| existing_security_group_id: sg-0123456789abcdef | ||
| ingress: | ||
| terraform_overrides: | ||
| load-balancer-annotations: | ||
| service.beta.kubernetes.io/aws-load-balancer-internal: "true" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tylergraff |
||
| # Ensure the subnet IDs are also set below | ||
| service.beta.kubernetes.io/aws-load-balancer-subnets: "subnet-0123456789abcdef,subnet-abcdef0123456789" | ||
| ``` | ||
|
|
||
| - **Use existing SSL certificate** | ||
| Instructs Nebari to use the SSL certificate specified by `[k8s-custom-secret-name]` | ||
|
|
||
| ``` | ||
| certificate: | ||
| type: existing | ||
| secret_name: [k8s-custom-secret-name] | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylergraff
The following feature, although tested, was never merged
Lines 9-15
The following feature
amazon_web_services.extra_ssl_certificateswas tested but not merged:Lines 17-28
...Instead, the same feature can be implemented since PR#2668 as follows:
Also, the
Private EKS endpoint configurationfeauture (Lines 30-36) was implemented in PR#2618 but needs to be configured as follows, with a string value as 1 of [public, private, public_and_private]: