@@ -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
0 commit comments