better service names
This commit is contained in:
parent
438c4271e1
commit
19d466d5d6
|
@ -564,7 +564,7 @@ namespace KubernetesWorkflow
|
||||||
var serviceSpec = new V1Service
|
var serviceSpec = new V1Service
|
||||||
{
|
{
|
||||||
ApiVersion = "v1",
|
ApiVersion = "v1",
|
||||||
Metadata = CreateServiceMetadata(),
|
Metadata = CreateServiceMetadata(containerRecipes),
|
||||||
Spec = new V1ServiceSpec
|
Spec = new V1ServiceSpec
|
||||||
{
|
{
|
||||||
Type = "NodePort",
|
Type = "NodePort",
|
||||||
|
@ -614,11 +614,18 @@ namespace KubernetesWorkflow
|
||||||
client.Run(c => c.DeleteNamespacedService(serviceName, K8sNamespace));
|
client.Run(c => c.DeleteNamespacedService(serviceName, K8sNamespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
private V1ObjectMeta CreateServiceMetadata()
|
private V1ObjectMeta CreateServiceMetadata(ContainerRecipe[] containerRecipes)
|
||||||
{
|
{
|
||||||
|
var exposedRecipe = containerRecipes.FirstOrDefault(c => c.ExposedPorts.Any());
|
||||||
|
var name = "service-" + workflowNumberSource.WorkflowNumber;
|
||||||
|
if (exposedRecipe != null)
|
||||||
|
{
|
||||||
|
name = K8sNameUtils.Format(exposedRecipe.Name) + "-" + workflowNumberSource.WorkflowNumber;
|
||||||
|
}
|
||||||
|
|
||||||
return new V1ObjectMeta
|
return new V1ObjectMeta
|
||||||
{
|
{
|
||||||
Name = "service-" + workflowNumberSource.WorkflowNumber,
|
Name = name,
|
||||||
NamespaceProperty = K8sNamespace
|
NamespaceProperty = K8sNamespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue