mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-03 04:07:51 +08:00
fix xdsHost condition
This commit is contained in:
parent
fe4450de6f
commit
780b9b5202
@ -158,12 +158,8 @@ func conversionServicePlugin(as *typesv1.AppService, dbmanager db.Manager) ([]v1
|
||||
|
||||
func createTCPDefaultPluginContainer(as *typesv1.AppService, pluginID string, envs []v1.EnvVar) v1.Container {
|
||||
envs = append(envs, v1.EnvVar{Name: "PLUGIN_ID", Value: pluginID})
|
||||
_, xdsHostPort, apiHostPort := getXDSHostIPAndPort()
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_IP", ValueFrom: &corev1.EnvVarSource{
|
||||
FieldRef: &corev1.ObjectFieldSelector{
|
||||
FieldPath: "status.hostIP",
|
||||
},
|
||||
}})
|
||||
xdsHost, xdsHostPort, apiHostPort := getXDSHostIPAndPort()
|
||||
envs = append(envs, xdsHostIPEnv(xdsHost))
|
||||
envs = append(envs, v1.EnvVar{Name: "API_HOST_PORT", Value: apiHostPort})
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_PORT", Value: xdsHostPort})
|
||||
|
||||
@ -177,12 +173,8 @@ func createTCPDefaultPluginContainer(as *typesv1.AppService, pluginID string, en
|
||||
|
||||
func createProbeMeshInitContainer(as *typesv1.AppService, pluginID, serviceAlias string, envs []v1.EnvVar) v1.Container {
|
||||
envs = append(envs, v1.EnvVar{Name: "PLUGIN_ID", Value: pluginID})
|
||||
_, xdsHostPort, apiHostPort := getXDSHostIPAndPort()
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_IP", ValueFrom: &corev1.EnvVarSource{
|
||||
FieldRef: &corev1.ObjectFieldSelector{
|
||||
FieldPath: "status.hostIP",
|
||||
},
|
||||
}})
|
||||
xdsHost, xdsHostPort, apiHostPort := getXDSHostIPAndPort()
|
||||
envs = append(envs, xdsHostIPEnv(xdsHost))
|
||||
envs = append(envs, v1.EnvVar{Name: "API_HOST_PORT", Value: apiHostPort})
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_PORT", Value: xdsHostPort})
|
||||
return v1.Container{
|
||||
@ -340,15 +332,7 @@ func createPluginEnvs(pluginID, tenantID, serviceAlias string, mainEnvs []v1.Env
|
||||
envs = append(envs, v1.EnvVar{Name: e.EnvName, Value: e.EnvValue})
|
||||
}
|
||||
xdsHost, xdsHostPort, apiHostPort := getXDSHostIPAndPort()
|
||||
if xdsHost == "" {
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_IP", ValueFrom: &corev1.EnvVarSource{
|
||||
FieldRef: &corev1.ObjectFieldSelector{
|
||||
FieldPath: "status.hostIP",
|
||||
},
|
||||
}})
|
||||
} else {
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_IP", Value: xdsHost})
|
||||
}
|
||||
envs = append(envs, xdsHostIPEnv(xdsHost))
|
||||
envs = append(envs, v1.EnvVar{Name: "API_HOST_PORT", Value: apiHostPort})
|
||||
envs = append(envs, v1.EnvVar{Name: "XDS_HOST_PORT", Value: xdsHostPort})
|
||||
discoverURL := fmt.Sprintf(
|
||||
@ -413,3 +397,14 @@ func createTCPUDPMeshRecources(as *typesv1.AppService) v1.ResourceRequirements {
|
||||
return cpu
|
||||
}())
|
||||
}
|
||||
|
||||
func xdsHostIPEnv(xdsHost string) corev1.EnvVar {
|
||||
if xdsHost == "" {
|
||||
return v1.EnvVar{Name: "XDS_HOST_IP", ValueFrom: &corev1.EnvVarSource{
|
||||
FieldRef: &corev1.ObjectFieldSelector{
|
||||
FieldPath: "status.hostIP",
|
||||
},
|
||||
}}
|
||||
}
|
||||
return v1.EnvVar{Name: "XDS_HOST_IP", Value: xdsHost}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user