Service
Define how a service for the Workload is configured.
Refer to the service feature for configuration details.
You may optionally set annotations and labels on the Kubernetes Service
object through a Score extension file.
Other workloads of the same Application may access a workload’s service through a service
Resource declared in Score. That resource’s name
output will resolve to the Kubernetes-internal DNS name of the other workload’s service. See the Score files for the specific setup.
humanitec.score.yaml
(
view on GitHub
)
:
apiVersion: humanitec.org/v1b1
spec:
service:
# Set annotations on the Kubernetes Service
annotations:
serviceannotationkey: serviceannotationvalue
# Set labels on the Kubernetes Service
labels:
servicelabelkey: servicelabelvalue
score-consuming-a-service.yaml
(
view on GitHub
)
:
# This Score file defines a workload accessing another workload through its service
apiVersion: score.dev/v1b1
metadata:
name: workload-consuming-a-service
containers:
demo:
image: .
variables:
# This placeholder will resolve to the K8s-internal DNS name of the other workload's service
SERVICE_ADDR: "${resources.my-workload.name}:8080"
resources:
# The name of this resource needs to correspond with the name
# of the workload whose service you wish to access
my-workload:
type: service
score.yaml
(
view on GitHub
)
:
# This Score file defines a workload declaring a service
apiVersion: score.dev/v1b1
metadata:
name: my-workload
containers:
demo:
image: .
service:
ports:
www:
port: 8080
targetPort: 3001
stream:
port: 19245
targetPort: 19245
protocol: UDP