This document describes how to register and discover a Spring Cloud application service in the TEM console.
If you selected Auto Inject Registry Info, when you submit the service for deployment, TEM will automatically save the default parameters of the registry as a
.properties file to the
tse-config in the environment and mount it to the
/config/tse-default-spring-cloud-config.properties directory of the application in the form of VolumeMounts.
At the same time, TEM will add the directory to the SPRING_CONFIG_ADDITIONAL-LOCATION environment variable of the application. If the variable does not exist in the application, it will be created.
The basic configuration is as follows:
- name: my-service
- name: SPRING_CONFIG_ADDITIONAL-LOCATION
- name: tse-config
- name: tse-config
- key: tse-default-spring-cloud-config.properties
TEM will inject different parameters for different registries:
Suppose the requested ZooKeeper address is
xxx.preferIpAddress=true is added to all injected registry parameters, as when Spring Cloud gets the local server IP (i.e., Pod IP in TEM), it will automatically query the domain name based on the IP; if
preferIpAddress is determined to be
false (default value), the service will be registered through the domain name; otherwise, it will be registered through the IP.
PodName is mapped by the Pod IP in TEM, that is, if
preferIpAddress=true is not set, then the address registered with the registry will be a
PodName, which will be the service instance address pulled by other services from the registry, making the instance inaccessible through the
The SPRING_CONFIG_ADDITIONAL-LOCATION environment variable automatically added by TEM enables you to externally customize the configuration of a Spring Boot application, but it takes effect only in Spring Boot v2.0 or later.
If you use Spring Boot v1.x, please add the mounted directory
/config/tse-default-spring-cloud-config.properties to the SPRING_CONFIG_LOCATION environment variable on your own.
You can also set this by directly adding the JVM launch parameters as follows:
# Suppose the requested ZooKeeper address is `10.0.1.30:2181` -Dspring.cloud.zookeeper.connectString=10.0.1.30:2181 -Dspring.cloud.zookeeper.discovery.preferIpAddress=true
# Suppose the requested Eureka address is `10.0.1.31:8083` -Deureka.client.serviceUrl.defaultZone=http://10.0.1.31:8083/eureka/ -Deureka.instance.preferIpAddress=true