Add HTTPService rendering for Ingress configuration
This commit is contained in:
		
							parent
							
								
									6edd214baf
								
							
						
					
					
						commit
						98e324c586
					
				
							
								
								
									
										37
									
								
								base/ingress.k
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								base/ingress.k
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					import k8s.api.networking.v1 as networkingv1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					schema HTTPService:
 | 
				
			||||||
 | 
					    """http service"""
 | 
				
			||||||
 | 
					    service: str
 | 
				
			||||||
 | 
					    domain: str
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					httpServiceRender = lambda h: HTTPService {
 | 
				
			||||||
 | 
					    """Render http service to Ingress"""
 | 
				
			||||||
 | 
					    ingress = networkingv1.Ingress {
 | 
				
			||||||
 | 
					        apiVersion = "networking.k8s.io/v1"
 | 
				
			||||||
 | 
					        kind = "Ingress"
 | 
				
			||||||
 | 
					        metadata = {
 | 
				
			||||||
 | 
					            name = h.service
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        spec = {
 | 
				
			||||||
 | 
					            rules = [{
 | 
				
			||||||
 | 
					                host = h.domain
 | 
				
			||||||
 | 
					                http = {
 | 
				
			||||||
 | 
					                    paths = [{
 | 
				
			||||||
 | 
					                        path = "/"
 | 
				
			||||||
 | 
					                        pathType = "Prefix"
 | 
				
			||||||
 | 
					                        backend = {
 | 
				
			||||||
 | 
					                            service = {
 | 
				
			||||||
 | 
					                                name = h.service
 | 
				
			||||||
 | 
					                                port = {
 | 
				
			||||||
 | 
					                                    number = 80
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }]
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    [ingress]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										5
									
								
								main.k
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								main.k
									
									
									
									
									
								
							@ -24,6 +24,11 @@ envs = base.Envs {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					https = base.HTTPService {
 | 
				
			||||||
 | 
					    service = "nginxxx"
 | 
				
			||||||
 | 
					    domain = "nginxxx.suyiiyii.top"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
deploys = sum([base.appRender(a) for a in apps], [])
 | 
					deploys = sum([base.appRender(a) for a in apps], [])
 | 
				
			||||||
# print(yaml.encode(deploys))
 | 
					# print(yaml.encode(deploys))
 | 
				
			||||||
apps_manifests = [base.envInjector(envs, deploy) for deploy in deploys]
 | 
					apps_manifests = [base.envInjector(envs, deploy) for deploy in deploys]
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user