Networking Velocity Services
To enable in-cluster communication, Velocity provides a flexible configuration model based on your existing K8s definitions extended with Velocity's Exposures annotation.
The Exposures entity automatically generates pre-built parameters that you can use in your configuration. The basic 'host' and 'port' parameters are defined by your Kubernetes Service Port specifications, while complex parameters such as 'URI' combine the 'host' and 'port' with the relevant application properties.
{velocity.v1:<id>.exposures(port=<port_id>).<internal_url_segment>}
uri
-> scheme://user:[email protected]:portscheme
-> scheme (http, https, etc...)user
-> user (the username segment of the exposure)password
-> password (the password segment of the exposure)host
-> host (service name)port
-> port (service port)
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
annotations:
velocity.tech.v1/dependsOn: mysql
velocity.tech.v1/id: backend
spec:
containers:
- name: backend
env:
- name: DB_CONNECTION_STRING
value: '{velocity.v1:mysql.exposures(port=mysqlport).uri}'
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
annotations:
velocity.tech.v1/id: mysql
velocity.tech.v1/exposures-mysqlport-user: const="username"
velocity.tech.v1/exposures-mysqlport-password: const="password"
velocity.tech.v1/exposures-mysqlport-scheme: const="https"
spec:
containers:
- name: mysql
env:
- name: DATABASE_NAME
value: 'orders'
ports:
- name: mysql
containerPort: 3306
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
selector:
app: mysql
ports:
- name: mysqlport
port: 3306
targetPort: mysql
protocol: TCP
Last modified 2mo ago