Ingress (External Traffic)
To automatically create an ingress for a component, you can configure the ingress section for the component:
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
tls: true
rules:
- host: my-static-host.tld
- host: other-domain.tld
path: /login
You need to define a service with at least one port to be able to use the ingress option (see example above).
rules
The rules option expects an array of ingress rules that define how the incoming external traffic is routed by the ingress.
disabled
The disabled option can be set to true to disable the ingress without removing the rules definitions.
In devspace it can be configured by a environmental variable or flag.
host
The host option expects a string stating the hostname (domain name) that the component should be made available on.
The component chart automatically makes sure that all hosts specified via ingress.rules[].host are connected to the service of the component.
If the service of this component defines multiple ports, the component chart will use the first one unless you specify the servicePort option.
Example: Defining Hosts
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
rules:
- host: my-static-host.tld
- host: other-domain.tld
path
The path option expects a URL path which is used for routing. Only requests to this path will be forwarded to the service of this component.
Default Value For path
path: /
Example: Defining Ingress Paths
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
rules:
- host: my-static-host.tld
path: /login
pathType
Since v1.18.0 of kubernetes each path in an Ingress is required to have a corresponding path type
There are three supported path types:
ImplementationSpecific: With this path type, matching is up to the IngressClass. Implementations can treat this as a separate pathType or treat it identically to Prefix or Exact path types.Exact: Matches the URL path exactly and with case sensitivity.Prefix: Matches based on a URL path prefix split by /. Matching is case sensitive and done on a path element by element basis. A path element refers to the list of labels in the path split by the / separator. A request is a match for path p if every p is an element-wise prefix of p of the request path.
Example: Defining Ingress Path type
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
rules:
- host: my-static-host.tld
path: /login
pathType: Prefix
servicePort
The servicePort option expects an integer stating the port of the service to which the traffic should be routed for the hostname stated in host.
By default, the ingress will automatically route to the first port specified under service.ports within this component.
Example: Custom Service Port
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
rules:
- host: my-static-host.tld
servicePort: 8080
serviceName
The serviceName option expects a string stating the name of the Kubernetes service to which the traffic should be routed for the hostname stated in host.
By default, the ingress will automatically route to the service defined in the service section within this component. Defining serviceName is generally only useful if you want to create a simple ingress for another service that has not been created by a component, e.g. from using one of the Helm charts from the stable repository.
If serviceName is defined, servicePort must also be defined.
Example: Custom Service Name
containers:
- name: frontend
image: mendhak/http-https-echo
ingress:
rules:
- host: my-static-host.tld
serviceName: my-custom-k8s-service
servicePort: 8080
Explanation:
This example configuration would only create an ingress for a service called my-custom-k8s-service and forward the traffic from my-static-host.tld to port 8080 of this service.
tls
The tls option expects either:
- a string stating the name of a Kubernetes secret which contains the TLS certificate to use for SSL
- a boolean to enable/disable TLS (an auto-generated name of a secret will be created referencing a Kubernetes secret containing the TLS certificate to use for SSL)
Default Value For tls
tls: false
Example: Enabling TLS for Ingress
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
tls: true
rules:
- host: my-static-host.tld
- host: my-static-host2.tld
tlsClusterIssuer
The tlsClusterIssuer option expects a string with the name of the cluster issuer for cert-manager.
Default Value For tlsClusterIssuer
tlsClusterIssuer: cert-manager-letsencrypt
Example: Custom Cluster Issuer
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
tls: true
tlsClusterIssuer: staging-issuer
rules:
- host: my-static-host.tld
- host: my-static-host2.tld
ingressClass
The ingressClass option expects a string with a Kubernetes ingress class used for a cert-manager annotation.
Default Value For ingressClass
ingressClass: nginx
Example: Custom Ingress Class
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
ingressClassName: traefik
tls: true
rules:
- host: my-static-host.tld
- host: my-static-host2.tld
name
The name option is optional and expects a string that will be used as a name for the ingress that is being created for this component.
Example: Custom Name for Ingress
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
name: custom-ingress-name
tls: true
rules:
- host: my-static-host.tld
- host: my-static-host2.tld
Explanation:
Instead of the default name frontend, the ingress of this component would be named custom-ingress-name.
labels
The labels option expects a map with Kubernetes labels.
By default, the component chart sets a couple of labels following the best practices described in the Kubernetes documentation:
app.kubernetes.io/name: devspace-appapp.kubernetes.io/component: [DEPLOYMENT_NAME]
You can specify additional labels using the labels option but the default / best practice labels will still be set for the component.
All additional labels will be added to the ingress created for this component.
Default Value For labels
labels: []
Example: Additional Labels
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
tls: true
rules:
- host: my-static-host.tld
- host: my-static-host2.tld
labels:
label1: label-value-1
label2: label-value-2
annotations
The annotations option expects a map with Kubernetes annotations.
By default, the component chart sets a couple of annotations following the best practices described in the Kubernetes documentation:
helm.sh/chart: component-chart-vX.Y.Z
You can specify additional annotations using the annotations option but the default / best practice annotations will still be set for the component.
All additional annotations will be added to the ingress created for this component.
Default Value For annotations
annotations: []
Example: Additional Annotations
containers:
- name: frontend
image: mendhak/http-https-echo
service:
ports:
- port: 8080
ingress:
tls: true
rules:
- host: my-static-host.tld
- host: my-static-host2.tld
annotations:
annotation1: annotation-value-1
annotation2: annotation-value-2