-
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
Changes from 14 commits
2e82b8a
04fc5c5
0c35f6c
150541e
1e19131
331ec51
460716f
aa7ee5d
d4d3f9a
92a4cb2
2ced8d3
be8f153
8dddb65
ec5e354
ed6190b
7e92f17
528123a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| ## 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]`. | ||
|
|
||
| ### 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 | ||
| ``` |
|
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 The following feature ...Instead, the same feature can be implemented since PR#2668 as follows: Also, the |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| ## 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. | ||
|
|
||
| ``` | ||
| 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] | ||
| ``` | ||
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 tested updates for featuring a nebari-config.yaml that enables options to override, exhaustively, every Nebari container image were never merged for the following reasons:
nebari-config.yamlWe took a different approach towards mirroring container images based on pointing to default mirrors for private registries (e.g. ECR, GitLab, etc.) as overrides/imports to the EKS nodes' containerD configs.
The enabling PR for this approach was PR#2668, which added the feature to run
pre_bootstrap_commandon nodes.The following config options are examples of mirroring container images by means of customizing ContainerD at the k8s node: