def __init__(self, scope: Construct, ns: str): super().__init__(scope, ns) label = {"app": "hello-k8s"} k8s.Service(self, 'service', spec=k8s.ServiceSpec( type='LoadBalancer', ports=[ k8s.ServicePort( port=80, target_port=k8s.IntOrString.from_number(8080)) ], selector=label)) k8s.Deployment( self, 'deployment', spec=k8s.DeploymentSpec( replicas=2, selector=k8s.LabelSelector(match_labels=label), template=k8s.PodTemplateSpec( metadata=k8s.ObjectMeta(labels=label), spec=k8s.PodSpec(containers=[ k8s.Container( name='hello-kubernetes', image='paulbouwer/hello-kubernetes:1.7', ports=[k8s.ContainerPort(container_port=8080)]) ]))))
def __init__(self, scope: Construct, ns: str): super().__init__(scope, ns) label = {"app": "guestbook-ui"} k8s.Service(self, 'service', spec=k8s.ServiceSpec( type='LoadBalancer', ports=[ k8s.ServicePort( port=80, target_port=k8s.IntOrString.from_number(80)) ], selector=label)) k8s.Deployment( self, 'deployment', spec=k8s.DeploymentSpec( replicas=1, selector=k8s.LabelSelector(match_labels=label), template=k8s.PodTemplateSpec( metadata=k8s.ObjectMeta(labels=label), spec=k8s.PodSpec(containers=[ k8s.Container( name='guestbook-ui', image='gcr.io/heptio-images/ks-guestbook-demo:0.2', ports=[k8s.ContainerPort(container_port=80)]) ]))))
def __init__(self, scope: Construct, ns: str, *, image: str, replicas: typing.Optional[int] = 1, port: typing.Optional[int] = 80, container_port: typing.Optional[int] = 8000): super().__init__(scope, ns) label = {'app': Node.of(self).unique_id} k8s.Service(self, 'service', spec=k8s.ServiceSpec( type='NodePort', ports=[k8s.ServicePort(port=port, target_port=k8s.IntOrString.from_number(container_port))], selector=label)) k8s.Deployment(self, 'deployment', spec=k8s.DeploymentSpec( replicas=replicas, selector=k8s.LabelSelector(match_labels=label), template=k8s.PodTemplateSpec( metadata=k8s.ObjectMeta(labels=label), spec=k8s.PodSpec( containers=[ k8s.Container( name='app', image=image, ports=[k8s.ContainerPort(container_port=container_port)])]))))
def __init__(self, scope: Construct, ns: str, *, image: str, replicas: int = 1, port: int = 80, container_port: int = 8080): super().__init__(scope, ns) label = {"app": Node.of(self).unique_id} k8s.Service( self, "service", spec=k8s.ServiceSpec( type="LoadBalancer", ports=[ k8s.ServicePort( port=port, target_port=k8s.IntOrString.from_number( container_port), ) ], selector=label, ), ) k8s.Deployment( self, "deployment", spec=k8s.DeploymentSpec( replicas=replicas, selector=k8s.LabelSelector(match_labels=label), template=k8s.PodTemplateSpec( metadata=k8s.ObjectMeta(labels=label), spec=k8s.PodSpec(containers=[ k8s.Container( name="app", image=image, ports=[ k8s.ContainerPort( container_port=container_port) ], ) ]), ), ), )
def __init__(self, scope: Construct, ns: str): super().__init__(scope, ns) labels = {"app": "cdk8s-python"} k8s.Service( self, 'service', spec=k8s.ServiceSpec( type='LoadBalancer', ports=[ k8s.ServicePort( port=80, target_port=k8s.IntOrString.from_number(80) ), ], selector=labels, ), ) k8s.Deployment( self, 'deployment', spec=k8s.DeploymentSpec( replicas=2, selector=k8s.LabelSelector(match_labels=labels), template=k8s.PodTemplateSpec( metadata=k8s.ObjectMeta(labels=labels), spec=k8s.PodSpec( containers=[ k8s.Container( name=ns, image='nginxdemos/hello', ports=[ k8s.ContainerPort(container_port=80), ], ), ], ), ), ), )
def render_k8s_resource(self, chart: Chart) -> k8s.ServicePort: cont_port_int_string = k8s.IntOrString.from_number(self.port) return k8s.ServicePort(name=self.name, port=self.port, protocol=self.protocol, target_port=cont_port_int_string)