Skip to content

Commit c63d741

Browse files
authored
Merge branch 'main' into dawn-tenancy
2 parents 359556c + f8db5fe commit c63d741

33 files changed

Lines changed: 1319 additions & 218 deletions

infra/aks/Pulumi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ config:
1818
type: string
1919
description: The CIDR for the access cluster nodes subnet
2020
default: "10.10.1.0/24"
21+
admin_ip_allowlist:
22+
type: array
23+
description: List of CIDR blocks to allow access to the API proxy SSH server
24+
items:
25+
type: string
2126
cluster_name:
2227
type: string
2328
description: The name of the AKS cluster

infra/aks/components/networking.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def __init__(
9696
protocol=network.SecurityRuleProtocol.TCP,
9797
source_port_range="*",
9898
destination_port_range="2500",
99-
source_address_prefix="Internet",
99+
source_address_prefixes=args.config.require_object(
100+
"admin_ip_allowlist"
101+
),
100102
destination_address_prefix="*",
101103
description="Allow SSH traffic to API Proxy SSH server",
102104
),

infra/fridge/access-cluster/Pulumi.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ config:
2424
base_fqdn:
2525
type: string
2626
description: Base FQDN for the access cluster
27+
admin_ip_allowlist:
28+
type: array
29+
description: List of CIDR blocks to allow access to the API proxy SSH server
30+
items:
31+
type: string
32+
dawn_load_balancer_ip:
33+
type: string
34+
description: Load balancer IP for Dawn access cluster - use a dummy value when not deploying to Dawn
2735
harbor_fqdn_prefix:
2836
type: string
2937
description: FQDN prefix for Harbor

infra/fridge/access-cluster/__main__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pulumi
22

33
from pulumi import ResourceOptions
4-
from pulumi_kubernetes.batch.v1 import CronJobPatch, CronJobSpecPatchArgs
54
from pulumi_kubernetes.core.v1 import NamespacePatch
65
from pulumi_kubernetes.meta.v1 import ObjectMetaPatchArgs
76
from pulumi_kubernetes.yaml import ConfigFile
@@ -117,9 +116,12 @@ def patch_namespace(name: str, pss: PodSecurityStandard) -> NamespacePatch:
117116
]
118117

119118
network_policies = components.NetworkPolicies(
120-
name=f"{stack_name}-network-policies",
121-
config=config,
122-
k8s_environment=k8s_environment,
119+
f"{stack_name}-network-policies",
120+
components.NetworkPoliciesArgs(
121+
config=config,
122+
k8s_environment=k8s_environment,
123+
harbor_fqdn=harbor.harbor_fqdn,
124+
),
123125
opts=ResourceOptions(
124126
depends_on=resources,
125127
),
@@ -128,6 +130,7 @@ def patch_namespace(name: str, pss: PodSecurityStandard) -> NamespacePatch:
128130
# Pulumi exports
129131
pulumi.export("fridge_api_ip_address", config.require("fridge_api_ip_address"))
130132
pulumi.export("harbor_fqdn", harbor.harbor_fqdn)
131-
pulumi.export("harbor_ip_address", harbor.harbor_lb_ip)
132-
pulumi.export("ingress_ip", ingress_nginx.ingress_ip)
133-
pulumi.export("ingress_ports", ingress_nginx.ingress_ports)
133+
if k8s_environment == K8sEnvironment.AKS:
134+
pulumi.export("harbor_ip_address", harbor.harbor_ip)
135+
pulumi.export("ingress_ip", ingress_nginx.ingress_ip)
136+
pulumi.export("ingress_ports", ingress_nginx.ingress_ports)

infra/fridge/access-cluster/components/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from .container_registry import ContainerRegistry, ContainerRegistryArgs
33
from .fridge_api_jumpbox import FridgeAPIJumpbox, FridgeAPIJumpboxArgs
44
from .ingress import Ingress, IngressArgs
5-
from .network_policies import NetworkPolicies
5+
from .network_policies import NetworkPolicies, NetworkPoliciesArgs
66
from .storage_classes import StorageClasses, StorageClassesArgs

infra/fridge/access-cluster/components/cert_manager.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import pulumi
22

3-
from pulumi import ComponentResource, ResourceOptions
3+
from pulumi import ComponentResource, Output, ResourceOptions
44
from pulumi_kubernetes.apiextensions import CustomResource
5-
from pulumi_kubernetes.core.v1 import Namespace
5+
from pulumi_kubernetes.core.v1 import Namespace, Service
66
from pulumi_kubernetes.helm.v3 import Release
7-
from pulumi_kubernetes.helm.v4 import Chart, RepositoryOptsArgs
7+
from pulumi_kubernetes.helm.v4 import RepositoryOptsArgs
88
from pulumi_kubernetes.meta.v1 import ObjectMetaArgs
99

1010
from enums import K8sEnvironment, PodSecurityStandard, TlsEnvironment, tls_issuer_names
@@ -32,7 +32,7 @@ def __init__(
3232
k8s_environment = args.k8s_environment
3333

3434
match k8s_environment:
35-
case K8sEnvironment.AKS | K8sEnvironment.K3S | K8sEnvironment.DAWN:
35+
case K8sEnvironment.AKS | K8sEnvironment.K3S:
3636
# AKS specific configuration
3737
# CertManager (TLS automation)
3838
cert_manager_ns = Namespace(
@@ -65,6 +65,23 @@ def __init__(
6565
),
6666
),
6767
)
68+
case K8sEnvironment.DAWN:
69+
cert_manager_ns = Namespace.get(
70+
"cert-manager-ns",
71+
"cert-manager",
72+
opts=child_opts,
73+
)
74+
cert_manager = Service.get(
75+
"cert-manager",
76+
Output.concat(
77+
cert_manager_ns.metadata.name,
78+
"/",
79+
"cert-manager",
80+
),
81+
opts=ResourceOptions.merge(
82+
child_opts, ResourceOptions(depends_on=[cert_manager_ns])
83+
),
84+
)
6885

6986
# Create ClusterIssuers
7087
issuer_outputs = {}

infra/fridge/access-cluster/components/container_registry.py

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def __init__(
6464
super().__init__("fridge:ContainerRegistry", name, {}, opts)
6565
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))
6666

67+
k8s_environment = K8sEnvironment(args.config.get("k8s_env"))
68+
6769
self.harbor_ns = Namespace(
6870
"harbor-ns",
6971
metadata=ObjectMetaArgs(
@@ -88,15 +90,6 @@ def __init__(
8890
else "ReadWriteOnce",
8991
}
9092

91-
api_service_annotations = (
92-
{
93-
"service.beta.kubernetes.io/azure-load-balancer-internal": "true",
94-
"service.beta.kubernetes.io/azure-load-balancer-internal-subnet": "networking-access-nodes",
95-
}
96-
if K8sEnvironment(args.config.get("k8s_env")) == K8sEnvironment.AKS
97-
else {}
98-
)
99-
10093
self.harbor = Release(
10194
"harbor",
10295
ReleaseArgs(
@@ -188,34 +181,40 @@ def __init__(
188181
),
189182
)
190183

191-
self.harbor_internal_loadbalancer = Service(
192-
"harbor-internal-lb",
193-
metadata=ObjectMetaArgs(
194-
name="harbor-lb",
195-
namespace=self.harbor_ns.metadata.name,
196-
annotations=api_service_annotations,
197-
),
198-
spec=ServiceSpecArgs(
199-
type="LoadBalancer",
200-
selector={"app": "harbor", "component": "nginx"},
201-
ports=[ServicePortArgs(port=80, target_port=8080)],
202-
),
203-
opts=ResourceOptions.merge(
204-
child_opts,
205-
ResourceOptions(
206-
depends_on=[
207-
self.harbor,
208-
]
184+
if k8s_environment == K8sEnvironment.AKS:
185+
self.harbor_internal_loadbalancer = Service(
186+
"harbor-internal-lb",
187+
metadata=ObjectMetaArgs(
188+
name="harbor-lb",
189+
namespace=self.harbor_ns.metadata.name,
190+
annotations={
191+
"service.beta.kubernetes.io/azure-load-balancer-internal": "true",
192+
"service.beta.kubernetes.io/azure-load-balancer-internal-subnet": "networking-access-nodes",
193+
},
209194
),
210-
),
211-
)
212-
213-
# Extract the dynamically assigned IP address
214-
self.harbor_lb_ip = self.harbor_internal_loadbalancer.status.apply(
215-
lambda status: status.load_balancer.ingress[0].ip
216-
if status and status.load_balancer and status.load_balancer.ingress
217-
else None
218-
)
195+
spec=ServiceSpecArgs(
196+
type="LoadBalancer",
197+
selector={"app": "harbor", "component": "nginx"},
198+
ports=[ServicePortArgs(port=80, target_port=8080)],
199+
),
200+
opts=ResourceOptions.merge(
201+
child_opts,
202+
ResourceOptions(
203+
depends_on=[
204+
self.harbor,
205+
]
206+
),
207+
),
208+
)
209+
# Extract the dynamically assigned LoadBalancer IP address
210+
self.harbor_ip = self.harbor_internal_loadbalancer.status.apply(
211+
lambda status: status.load_balancer.ingress[0].ip
212+
if status and status.load_balancer and status.load_balancer.ingress
213+
else None
214+
)
215+
elif k8s_environment == K8sEnvironment.DAWN:
216+
# Extract the ClusterIP for DAWN environment
217+
self.harbor_ip = args.config.require("dawn_load_balancer_ip")
219218

220219
# Create a daemonset to skip TLS verification for the harbor registry
221220
# This is needed while using staging/self-signed certificates for Harbor

infra/fridge/access-cluster/components/fridge_api_jumpbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def __init__(
166166
),
167167
spec=ServiceSpecArgs(
168168
selector=self.api_jumpbox.spec.template.metadata.labels,
169-
ports=[{"protocol": "TCP", "port": 2500, "targetPort": 2222}],
169+
ports=[{"protocol": "TCP", "port": 2222, "targetPort": 2222}],
170170
type="ClusterIP",
171171
),
172172
opts=ResourceOptions.merge(

infra/fridge/access-cluster/components/ingress.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(
2323
k8s_environment = args.k8s_environment
2424

2525
match k8s_environment:
26-
case K8sEnvironment.AKS | K8sEnvironment.K3S | K8sEnvironment.DAWN:
26+
case K8sEnvironment.AKS | K8sEnvironment.K3S:
2727
ingress_nginx_ns = Namespace(
2828
"ingress-nginx-ns",
2929
metadata=ObjectMetaArgs(
@@ -51,12 +51,12 @@ def __init__(
5151
},
5252
},
5353
"tcp": {
54-
"2500": Output.concat(
54+
"2222": Output.concat(
5555
args.api_jumpbox.api_jumpbox_ns.metadata.name,
5656
"/",
5757
args.api_jumpbox.api_jumpbox_service.metadata.name,
5858
":",
59-
"2500",
59+
"2222",
6060
),
6161
},
6262
},
@@ -65,27 +65,37 @@ def __init__(
6565
child_opts, ResourceOptions(depends_on=ingress_nginx_ns)
6666
),
6767
)
68-
case K8sEnvironment.DAWN:
69-
# Dawn specific configuration
70-
ingress_nginx_ns = Namespace.get("ingress-nginx-ns", "ingress-nginx")
71-
ingress_nginx = Release.get("ingress-nginx", "ingress-nginx")
7268

73-
controller_name = Output.concat(
74-
ingress_nginx_ns.metadata.name,
75-
"/",
76-
ingress_nginx.status.name,
77-
"-controller",
78-
)
69+
controller_name = Output.concat(
70+
ingress_nginx_ns.metadata.name,
71+
"/",
72+
ingress_nginx.status.name,
73+
"-controller",
74+
)
75+
ingress_service = Service.get(
76+
"ingress-nginx-controller-service",
77+
controller_name,
78+
)
7979

80-
ingress_service = Service.get(
81-
"ingress-nginx-controller-service",
82-
controller_name,
83-
)
80+
self.ingress_ip = ingress_service.status.load_balancer.ingress[0].ip
81+
self.ingress_ports = ingress_service.spec.ports.apply(
82+
lambda ports: [item.port for item in ports]
83+
)
8484

85-
self.ingress_ip = ingress_service.status.load_balancer.ingress[0].ip
86-
self.ingress_ports = ingress_service.spec.ports.apply(
87-
lambda ports: [item.port for item in ports]
88-
)
85+
case K8sEnvironment.DAWN:
86+
# Dawn specific configuration
87+
ingress_nginx_ns = Namespace.get("ingress-nginx-ns", "ingress-nginx")
88+
ingress_nginx = Service.get(
89+
"ingress-nginx",
90+
Output.concat(
91+
ingress_nginx_ns.metadata.name,
92+
"/ingress-nginx-controller",
93+
),
94+
opts=ResourceOptions.merge(
95+
child_opts,
96+
ResourceOptions(depends_on=ingress_nginx_ns),
97+
),
98+
)
8999

90100
self.register_outputs(
91101
{"ingress_nginx_ns": ingress_nginx_ns, "ingress_nginx": ingress_nginx}

0 commit comments

Comments
 (0)