tencent cloud

Tencent Cloud Elastic Microservice

Release Notes and Announcements
Announcements
Release Notes
Product Introduction
Overview
Strengths
Scenarios
Purchase Guide
Billing Overview
Product Pricing
Overdue Policies
Getting Started
Step 1. Get the Access Permission
Step 2. Create an Environment
Step 3. Create an Application
Step 4. Deploy the Application
Operation Guide
Environment Management
Application Management
Permission Management
View Change Record
Practical Tutorial
Use of GitHub Actions in TEM
Hosting a Static Website
Public Network Access of TEM Applications
TEM Application Access to Public Network (Through API Gateway)
TEM Application Failure Troubleshooting Guide
Quick Access to TEM Application Through API Gateway
Java Application Fine-Tuning
Migration from Java 8 to Java 11
API Documentation
History
Introduction
API Category
Making API Requests
Environment APIs
ModifyIngress
Resource APIs
Application APIs
Service APIs
RollingUpdateApplicationByVersion
Access Policy APIs
Configuration file APIs
Log collecting APIs
Scaling Rule APIs
Application Version APIs
Other APIs
Workload APIs
Data Types
Error Codes
FAQs
TEM Configuration
Contact Us
Glossary
TEM Policy
Privacy Policy
Data Privacy and Security Agreement

Service Registration and Discovery

PDF
Focus Mode
Font Size
Last updated: 2024-01-09 12:40:53

Overview

This document describes how to register and discover a Spring Cloud application service in the TEM console.

Directions

Operations in console

1. Log in to the TEM console.
2. On the left sidebar, click Application management to enter the application management page and select a deployment region for your application.
3. Click Create to go to the application creation page and enter the application information for deployment. For more information, see Creating and Deploying Application.
4. For a Spring Cloud application, if a registry is associated with the selected release environment, you can select Auto Inject Registry Info.

Specific configuration

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 ConfigMap named 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:
apiVersion: v1
kind: Deployment
metadata:
name: my-service
spec:
containers:
- name: my-service
image: my-image
env:
- name: SPRING_CONFIG_ADDITIONAL-LOCATION
value: file:/config/tse-default-spring-cloud-config.properties
volumeMounts:
- name: tse-config
mountPath: /config/tse-default-spring-cloud-config.properties
subPath: tse-default-spring-cloud-config.properties
volumes:
- name: tse-config
configMap:
name: tse-config
items:
- key: tse-default-spring-cloud-config.properties
path: tse-default-spring-cloud-config.properties

TEM will inject different parameters for different registries:
zookeeper
nacos
Suppose the requested ZooKeeper address is 10.0.1.30:2181:
apiVersion: v1
data:
tse-default-spring-cloud-config.properties: |
spring.cloud.zookeeper.connectString=10.0.1.30:2181
spring.cloud.zookeeper.discovery.preferIpAddress=true
kind: ConfigMap
metadata:
name: tse-config

Suppose the requested Nacos address is 10.0.120.11:8848:
apiVersion: v1
data:
tse-default-spring-cloud-config.properties: |
spring.cloud.nacos.discovery.server-addr=10.0.120.11:8848
kind: ConfigMap
metadata:
name: tse-config


Notes and Precautions

Notes on preferIpAddress

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.
If a 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 PodName.

Notes on Spring Boot additional location

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 1.x, 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:
zookeeper
nacos
# 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 Nacos address is `10.0.120.11:8848`
-Dspring.cloud.nacos.discovery.server-addr=10.0.120.11:8848


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback