Skip to content

Commit 1874a5c

Browse files
authored
Merge branch 'main' into 536-eks-cluster-encryption
2 parents 61e4006 + 98e79a6 commit 1874a5c

File tree

5 files changed

+205
-3
lines changed

5 files changed

+205
-3
lines changed

docs/docs/how-tos/nebari-gcp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ management.
6666

6767
If it's your first time creating a service account, please follow
6868
[these detailed instructions](https://cloud.google.com/iam/docs/creating-managing-service-accounts) to create a Google Service Account with the following roles attached:
69+
6970
- [`roles/editor`](https://cloud.google.com/iam/docs/understanding-roles#editor)
7071
- [`roles/resourcemanager.projectIamAdmin`](https://cloud.google.com/iam/docs/understanding-roles#resourcemanager.projectIamAdmin)
7172
- [`roles/container.admin`](https://cloud.google.com/iam/docs/understanding-roles#container.admin)
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
## Deploying and Running Nebari from a Private Container Repository
2+
3+
Nebari deploys and runs FOSS components as containers running in Kubernetes.
4+
By default, Nebari sources each container from the container's respective public repository, typically `docker.io` or `quay.io`.
5+
This introduces supply-chain concerns for security-focused customers.
6+
7+
One solution to these supply-chain concerns is to deploy Nebari from private locally-mirrored containers:
8+
9+
- Create a controlled private container repository (e.g. ECR)
10+
- Mirror all containers used by Nebari into this private container repository
11+
- Use the `pre_bootstrap_command` mechanism in `nebari-config.yaml` to specify the mirrored container repo
12+
13+
Deploying Nebari in this fashion eliminates significant supply chain surface-area, but requires identifying all containers used by Nebari.
14+
15+
The following configurations demonstrate how to specify a private repo denoted by the string `[PRIVATE_REPO]`.
16+
17+
**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**.
18+
19+
### Set ECR as default container registry mirror
20+
21+
```
22+
amazon_web_services:
23+
node_groups:
24+
general:
25+
instance: m5.2xlarge
26+
launch_template:
27+
pre_bootstrap_command: |
28+
#!/bin/bash
29+
# Verify that IP forwarding is enabled for worker nodes, as is required for containerd
30+
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
31+
# Set ECR as default container registry mirror
32+
mkdir -p /etc/containerd/certs.d/_default
33+
ECR_TOKEN="$(aws ecr get-login-password --region us-east-1)"
34+
BASIC_AUTH="$(echo -n "AWS:$ECR_TOKEN" | base64 -w 0)"
35+
cat <<-EOT > /etc/containerd/certs.d/_default/hosts.toml
36+
[host."https://[PRIVATE_REPO].dkr.ecr.us-east-1.amazonaws.com"]
37+
capabilities = ["pull", "resolve"]
38+
[host."https://[PRIVATE_REPO].dkr.ecr.us-east-1.amazonaws.com".header]
39+
authorization = "Basic $BASIC_AUTH"
40+
EOT
41+
42+
```
43+
44+
### Set GitLab CR as default container registry mirror
45+
46+
```
47+
# Set GitLab CR as default container registry mirror in hosts.toml;
48+
# must have override_path set if project/group names don't match upstream container
49+
amazon_web_services:
50+
node_groups:
51+
general:
52+
instance: m5.2xlarge
53+
launch_template:
54+
pre_bootstrap_command: |
55+
#!/bin/bash
56+
# Verify that IP forwarding is enabled for worker nodes, as is required for containerd
57+
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
58+
# Set default container registry mirror in hosts.toml; must have override_path set if project/group names don't match upstream container
59+
CONTAINER_REGISTRY_URL="[PRIVATE_REPO]"
60+
CONTAINER_REGISTRY_USERNAME="[username]"
61+
CONTAINER_REGISTRY_TOKEN="[token]"
62+
CONTAINER_REGISTRY_GROUP=as-nebari
63+
CONTAINER_REGISTRY_PROJECT=nebari-test
64+
mkdir -p /etc/containerd/certs.d/_default
65+
cat <<-EOT > /etc/containerd/certs.d/_default/hosts.toml
66+
[host."https://$CONTAINER_REGISTRY_URL/v2/$CONTAINER_REGISTRY_GROUP/$CONTAINER_REGISTRY_PROJECT"]
67+
override_path = true
68+
capabilities = ["pull", "resolve"]
69+
EOT
70+
71+
# Set containerd registry config auth in config.d .toml import dir
72+
mkdir -p /etc/containerd/config.d
73+
cat <<EOT | sudo tee /etc/containerd/config.d/config-import.toml
74+
version = 2
75+
[plugins."io.containerd.grpc.v1.cri".registry]
76+
config_path = "/etc/containerd/certs.d:/etc/docker/certs.d"
77+
[plugins."io.containerd.grpc.v1.cri".registry.auths]
78+
[plugins."io.containerd.grpc.v1.cri".registry.configs]
79+
[plugins."io.containerd.grpc.v1.cri".registry.configs."$CONTAINER_REGISTRY_URL".auth]
80+
username = "$CONTAINER_REGISTRY_USERNAME"
81+
password = "$CONTAINER_REGISTRY_TOKEN"
82+
EOT
83+
```
84+
85+
### Set GitLab CR as default container registry mirror, with custom Client SSL/TLS Certs
86+
87+
```
88+
# must have override_path set if project/group names don't match upstream container
89+
# Also add/set GitLab Client SSL/TLS Certificate for Containerd
90+
amazon_web_services:
91+
node_groups:
92+
general:
93+
instance: m5.2xlarge
94+
launch_template:
95+
pre_bootstrap_command: |
96+
#!/bin/bash
97+
# Verify that IP forwarding is enabled for worker nodes, as is required for containerd
98+
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
99+
# Set default container registry mirror in hosts.toml; must have override_path set if project/group names don't match upstream container
100+
CONTAINER_REGISTRY_URL="[PRIVATE_REPO]"
101+
CONTAINER_REGISTRY_USERNAME="[username]"
102+
CONTAINER_REGISTRY_TOKEN="[token]"
103+
CONTAINER_REGISTRY_GROUP=as-nebari
104+
CONTAINER_REGISTRY_PROJECT=nebari-test
105+
mkdir -p /etc/containerd/certs.d/_default
106+
cat <<-EOT > /etc/containerd/certs.d/_default/hosts.toml
107+
[host."https://$CONTAINER_REGISTRY_URL/v2/$CONTAINER_REGISTRY_GROUP/$CONTAINER_REGISTRY_PROJECT"]
108+
override_path = true
109+
capabilities = ["pull", "resolve"]
110+
client = ["/etc/containerd/certs.d/$CONTAINER_REGISTRY_URL/client.pem"]
111+
EOT
112+
113+
# Set containerd registry config auth in config.d .toml import dir
114+
mkdir -p /etc/containerd/config.d
115+
cat <<EOT | sudo tee /etc/containerd/config.d/config-import.toml
116+
version = 2
117+
[plugins."io.containerd.grpc.v1.cri".registry]
118+
config_path = "/etc/containerd/certs.d:/etc/docker/certs.d"
119+
[plugins."io.containerd.grpc.v1.cri".registry.auths]
120+
[plugins."io.containerd.grpc.v1.cri".registry.configs]
121+
[plugins."io.containerd.grpc.v1.cri".registry.configs."$CONTAINER_REGISTRY_URL".auth]
122+
username = "$CONTAINER_REGISTRY_USERNAME"
123+
password = "$CONTAINER_REGISTRY_TOKEN"
124+
EOT
125+
126+
# Add client key/cert to containerd
127+
mkdir -p /etc/containerd/certs.d/$CONTAINER_REGISTRY_URL
128+
cat <<-EOT >> /etc/containerd/certs.d/$CONTAINER_REGISTRY_URL/client.pem
129+
-----BEGIN CERTIFICATE-----
130+
XzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzZx
131+
ZxyzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzXz
132+
-----END CERTIFICATE-----
133+
-----BEGIN PRIVATE KEY-----
134+
XzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzZx
135+
ZxyzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzXz
136+
-----END PRIVATE KEY-----
137+
EOT
138+
```
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## Nebari Security Considerations
2+
3+
The security of _AWS Nebari_ deployments can be enhanced through the following deployment configuration options in `nebari-config.yaml`:
4+
5+
- **Explicit definition of container sources**
6+
This option allows for the use of locally mirrored, security-hardened, or otherwise customized container images in place of the containers used by default.
7+
See: [container-sources](container-sources.md)
8+
9+
- **Installation of custom SSL certificate(s) into EKS hosts**
10+
Install private certificates used by (e.g.) in-line content inspection engines which re-encrypt traffic.
11+
12+
```
13+
# Add client certificate to CA trust on node
14+
amazon_web_services:
15+
node_groups:
16+
general:
17+
instance: m5.2xlarge
18+
launch_template:
19+
pre_bootstrap_command: |
20+
#!/bin/bash
21+
cat <<-EOT >> /etc/pki/ca-trust/source/anchors/client.pem
22+
-----BEGIN CERTIFICATE-----
23+
XzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzZx
24+
ZxyzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxxzxzxzxzxzxzxzxzxzxxzxzXz
25+
-----END CERTIFICATE-----
26+
EOT
27+
sudo update-ca-trust extract
28+
```
29+
30+
- **Private EKS endpoint configuration**
31+
Mirrors the corresponding AWS console option, which routes all EKS traffic within the VPC.
32+
33+
```
34+
amazon_web_services:
35+
eks_endpoint_access: private # valid values: [public, private, public_and_private]
36+
```
37+
38+
- **Deploy into existing subnets**
39+
Instructs Nebari to be deployed into existing subnets, rather than creating its own new subnets.
40+
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.
41+
42+
```
43+
existing_subnet_ids:
44+
- subnet-0123456789abcdef
45+
- subnet-abcdef0123456789
46+
existing_security_group_id: sg-0123456789abcdef
47+
ingress:
48+
terraform_overrides:
49+
load-balancer-annotations:
50+
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
51+
# Ensure the subnet IDs are also set below
52+
service.beta.kubernetes.io/aws-load-balancer-subnets: "subnet-0123456789abcdef,subnet-abcdef0123456789"
53+
```
54+
55+
- **Use existing SSL certificate**
56+
Instructs Nebari to use the SSL certificate specified by `[k8s-custom-secret-name]`
57+
58+
```
59+
certificate:
60+
type: existing
61+
secret_name: [k8s-custom-secret-name]
62+
```

docs/docs/references/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
1111
/>
1212
</div>
1313

14-
Nitty-gritty technical descriptions of how Nebari works.
14+
Technical descriptions of how Nebari works.
1515

16+
- [Enhanced Security](enhanced-security.md) - Nebari security configuration guide
17+
- [Local Container Repo](container-sources.md) - Deploying Nebari from a Local Container Repo
1618
<DocCardList items={useCurrentSidebarCategory().items}/>

docs/nebari-slurm/configuration.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ _Note_: All slurm related configuration needs to be passed down as a string.
186186
### Services
187187
188188
Additional services can be added to the `jupyterhub_services`
189-
variable. Currently this is only `<service-name>:
190-
<service-apikey>`. You must keep the `dask_gateway` section.
189+
variable. Currently this is only `<service-name>: <service-apikey>`. You must keep the `dask_gateway` section.
191190

192191
```yaml
193192
jupyterhub_services:

0 commit comments

Comments
 (0)