Class Service.Builder
- java.lang.Object
-
- org.cdk8s.plus24.Service.Builder
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Service
build()
Service.Builder
clusterIp(String clusterIp)
The IP address of the service and is usually assigned randomly by the master.static Service.Builder
create(software.constructs.Construct scope, String id)
Service.Builder
externalIPs(List<String> externalIPs)
A list of IP addresses for which nodes in the cluster will also accept traffic for this service.Service.Builder
externalName(String externalName)
The externalName to be used when ServiceType.EXTERNAL_NAME is set.Service.Builder
loadBalancerSourceRanges(List<String> loadBalancerSourceRanges)
A list of CIDR IP addresses, if specified and supported by the platform, will restrict traffic through the cloud-provider load-balancer to the specified client IPs.Service.Builder
metadata(org.cdk8s.ApiObjectMetadata metadata)
Metadata that all persisted resources must have, which includes all objects users must create.Service.Builder
ports(List<? extends ServicePort> ports)
The ports this service binds to.Service.Builder
selector(IPodSelector selector)
Which pods should the service select and route to.Service.Builder
type(ServiceType type)
Determines how the Service is exposed.
-
-
-
Method Detail
-
create
@Stability(Stable) public static Service.Builder create(software.constructs.Construct scope, String id)
- Parameters:
scope
- This parameter is required.id
- This parameter is required.- Returns:
- a new instance of
Service.Builder
.
-
metadata
@Stability(Stable) public Service.Builder metadata(org.cdk8s.ApiObjectMetadata metadata)
Metadata that all persisted resources must have, which includes all objects users must create.- Parameters:
metadata
- Metadata that all persisted resources must have, which includes all objects users must create. This parameter is required.- Returns:
this
-
clusterIp
@Stability(Stable) public Service.Builder clusterIp(String clusterIp)
The IP address of the service and is usually assigned randomly by the master.If an address is specified manually and is not in use by others, it will be allocated to the service; otherwise, creation of the service will fail. This field can not be changed through updates. Valid values are "None", empty string (""), or a valid IP address. "None" can be specified for headless services when proxying is not required. Only applies to types ClusterIP, NodePort, and LoadBalancer. Ignored if type is ExternalName.
Default: - Automatically assigned.
- Parameters:
clusterIp
- The IP address of the service and is usually assigned randomly by the master. This parameter is required.- Returns:
this
- See Also:
- https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
-
externalIPs
@Stability(Stable) public Service.Builder externalIPs(List<String> externalIPs)
A list of IP addresses for which nodes in the cluster will also accept traffic for this service.These IPs are not managed by Kubernetes. The user is responsible for ensuring that traffic arrives at a node with this IP. A common example is external load-balancers that are not part of the Kubernetes system.
Default: - No external IPs.
- Parameters:
externalIPs
- A list of IP addresses for which nodes in the cluster will also accept traffic for this service. This parameter is required.- Returns:
this
-
externalName
@Stability(Stable) public Service.Builder externalName(String externalName)
The externalName to be used when ServiceType.EXTERNAL_NAME is set.Default: - No external name.
- Parameters:
externalName
- The externalName to be used when ServiceType.EXTERNAL_NAME is set. This parameter is required.- Returns:
this
-
loadBalancerSourceRanges
@Stability(Stable) public Service.Builder loadBalancerSourceRanges(List<String> loadBalancerSourceRanges)
A list of CIDR IP addresses, if specified and supported by the platform, will restrict traffic through the cloud-provider load-balancer to the specified client IPs.More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/
- Parameters:
loadBalancerSourceRanges
- A list of CIDR IP addresses, if specified and supported by the platform, will restrict traffic through the cloud-provider load-balancer to the specified client IPs. This parameter is required.- Returns:
this
-
ports
@Stability(Stable) public Service.Builder ports(List<? extends ServicePort> ports)
The ports this service binds to.If the selector of the service is a managed pod / workload, its ports will are automatically extracted and used as the default value. Otherwise, no ports are bound.
Default: - either the selector ports, or none.
- Parameters:
ports
- The ports this service binds to. This parameter is required.- Returns:
this
-
selector
@Stability(Stable) public Service.Builder selector(IPodSelector selector)
Which pods should the service select and route to.You can pass one of the following:
- An instance of
Pod
or any workload resource (e.gDeployment
,StatefulSet
, ...) - Pods selected by the
Pods.select
function. Note that in this case only labels can be specified.
Default: - unset, the service is assumed to have an external process managing its endpoints, which Kubernetes will not modify.
Example:
// select the pods of a specific deployment const backend = new kplus.Deployment(this, 'Backend', ...); new kplus.Service(this, 'Service', { selector: backend }); // select all pods labeled with the `tier=backend` label const backend = kplus.Pod.labeled({ tier: 'backend' }); new kplus.Service(this, 'Service', { selector: backend });
- Parameters:
selector
- Which pods should the service select and route to. This parameter is required.- Returns:
this
- An instance of
-
type
@Stability(Stable) public Service.Builder type(ServiceType type)
Determines how the Service is exposed.More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
Default: ServiceType.ClusterIP
- Parameters:
type
- Determines how the Service is exposed. This parameter is required.- Returns:
this
-
-