Service (Internal Traffic)
In short, there are three things you need to know:
- Containers in the same component will be started within a Kubernetes pod which allows these containers to communicate via
localhost
. - If you want containers to communicate across components (cluster-internal traffic), you need to define services for these components.
- If you want to connect a domain to a service (external internet traffic), you need to configure an ingress for this service.
To allow other containers to access this component within the cluster-internal network (2.), you can configure the service
section for the component:
containers:- image: dscr.io/${DEVSPACE_USERNAME}/databaseservice: ports: - port: 3000
Now, the component is accessible via:
[HELM_RELEASE_NAME]:3000 # e.g. database:3000
ports
The ports
option is mandatory and expects an array of port definitions.
port
The port
option is mandatory and expect an integer with a port number. The service will be available on this port.
containerPort
The containerPort
option is optional and tells the service to forward the traffic from the service port (defined in port
) to a different containerPort
of a pod.
containerPort
Default for containerPort: [same as `port` option]
name
The name
option is optional and allows you to customize the name of the port.
name
Default for By default the port name will be "port-0", "port-1" etc.
name: port-0
protocol
The protocol
option is optional and expects a string that defines the network protocol for this service port.
protocol
Default for protocol: TCP
type
The type
option is optional and expects a string that defines the type of the service.
type
Default for type: ClusterIP
externalIPs
The externalIPs
option is optional and expects an array of IP addresses for the service.
name
The name
option is optional and expects a string that defines the name of the service.
name
Default for name: [HELM_RELEASE_NAME]
labels
The labels
option is optional and expects an array of additional Kubernetes labels for the service.
annotations
The annotations
option is optional and expects an array of additional Kubernetes annotations for the service.