K8STARS is a convenient solution to run TARS services in kubernetes.
Three interfaces are added in the tarsregistry, which are used for automatic registration, heartbeat reporting and node offline. For details, please refer to interface definition。
A 'tarscli' command-line tool is provided to allocate ports, generate configuration, report heartbeat and node offline.
curl https://raw.githubusercontent.com/TarsCloud/K8STARS/master/baseserver/install_all.sh | sh
Deployment service example -Deploy sample simpleserver
cd examples/simple && kubectl apply -f simpleserver.yaml
Example description:
examples/simple/dockerfile
file, and the basic image is created by cmd/tarscli/dockerfile
tarscli genconf
in is used to generate the tars service startup configurationapp/genconf/config.go
structure ServerConf
. Endpoint defaults to tcp -h ${local_ip} -p ${random_port}
, supports automatic filling of IP and random ports.
-ased on Golang HelloWorld program TestApp.HelloGo
See examples/README.md
Verify the deployment
Login db_tars
, then execute select * from t_server_conf\G
The node information of simpleserver has been registered automatically.
tarscli
based on environment variable TARS_PATH
(default/tars) to manage services. The directory functions are as follows:
${TARS_PATH}/bin
:Startup scripts and binaries${TARS_PATH}/conf
:Configuration file${TARS_PATH}/log
: Log file${TARS_PATH}/data
:Runtime, Cache filetarscli
provides a set of command tools to facilitate container deployment of TARS services. Parameters can be specified through environment variables. For details, see tarscli help
.
Here are the sub commands supported by tarscli
genconf
is used to generate the startup configuration file of the TARS service. The supported environment variables are:
TARS_APPLICATION
the application name specified. By default, the_ server_ meta.yaml
Read fromTARS_SERVER
is the service name specified by the_ server_ meta.yaml
Read fromTARS_BUILD_SERVER
the service name at compile time. It will be used when the compiled service name is different from the running service nameTARS_LOCATOR
can specify the address of registry. The default is tars.tarsregistry.QueryObj@tcp -h tars-registry.tars-system.svc.cluster.local -p 17890
(address of service)TARS_SET_ID
can specify service setTARS_MERGE_Conf
can specify the configuration template file and merge the configuration into the service startup configuration filesupervisor
executes the genconf
command by default, and then starts and monitors the service. The supported environment variables are:
TARS_START_PATH
The startup script of the service $TARS_PATH/bin/start.sh
TARS_STOP_PATH
The stop script, by default, kill all service processes under path $TARS_PATH
TARS_REPORT_INTERVAL
reports the interval heartbeat to registryTARS_DISABLE_FLOW
whether to enable traffic when registering with registry. If it is not empty, it means it is off. It is enabled by defaultTARS_CHECK_INTERVAL
check the service status interval. If the status changes, it will be synchronized to the registry in real timeTARS_BEFORE_CHECK_SCRIPT
the shell command that runs before each checkTARS_CHECK_SCRIPT_TIMEOUT
the timeout to run the shell command before each checkTARS_PRESTOP_WAITTIME
turn off traffic - the waiting time before stopping the service. It is used for lossless changes. The default value is 80 secondshzcheck
is used to synchronize the service status and the pod status of k8s. You need to set the readiness Probe
of pod to tarscli hzcheck
command
prestop
is used to delete the configuration corresponding to the registry before the service exits
TARS_PRESTOP_WAITTIME
turn off traffic - the waiting time before stopping the service. It is used for lossless changes. The default value is 80 secondsnotify
is used to send management commands. The common commands are: tars.setloglevel/tars.pprof, etc
TARS related basic services provide rich service governance functions. Please refer to baseserver for deployment.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。