Expose Velocity Services Externally
To enable public access from the internet to your Velocity Services, you can use your existing Kubernetes Ingress definition.
Velocity uses your Ingress definition and creates an Ingress resource in every new environment created in your cluster.
To make your Ingress definition unique for each Velocity Environment, Velocity provides the
{velocity.v1.domainSuffix}
template that generates a different domain suffix for each new Velocity Environment that you create.Velocity Template | Description |
---|---|
{velocity.v1.domainSuffix} | A combination of the environment name and the domain name in the form of: environmentName.domainName
|
Please note that using Ingress requires installing an Ingress Controller in your cluster.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls: "true"
name: backend-ingress
spec:
rules:
- host: "backend-{velocity.v1.domainSuffix}"
http:
paths:
- backend:
service:
name: viron-backend
port:
number: 80
path: /
pathType: Prefix
There are cases where
Ingress
kinds are replaced by a CRD (take for example Ambassador's Mapping + Host CRDs). For those cases, to help Velocity identify the public hostname of a given exposure, you can specify the hostname on the main resource (Deployment
, Statefulset
, Job
) manifest using the annotation: velocity.tech.v1/exposures-<port_id>-publicHostname: const="<hostname>"
Moreover, you will need to mark the CRD resources as associated to the relevant Velocity Services (comma seperated ids). This will help Velocity know which resource to include for a given Development Candidate when creating a new Velocity Environment.
You can do it using the annotation:
velocity.tech.v1/associateTo
.apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
annotations:
velocity.tech.v1/dependsOn: mysql
velocity.tech.v1/id: backend
velocity.tech.v1/exposures-http-publicHostname: "backend-{velocity.v1.domainSuffix}"
spec:
containers:
- name: backend
---
apiVersion: v1
kind: Service
metadata:
name: backend
spec:
selector:
app: backend
ports:
- name: http
port: 8080
targetPort: 8080
protocol: TCP
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
name: backend-hostname
annotations:
velocity.tech.v1/associateTo: backend
spec:
hostname: "backend-{velocity.v1.domainSuffix}"
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
name: backend-mapping
annotations:
velocity.tech.v1/associateTo: backend
spec:
hostname: "backend-{velocity.v1.domainSuffix}"
prefix: /
service: backend:8080
Last modified 2mo ago