Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set selector and label specific to platform service #341

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions controllers/platform/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,10 @@ func createDeployment(ctx context.Context, client client.Client, platform *opera
dataDeployContainer.Name = ps.GetContainerName()

replicas := ps.GetReplicaCount()
lbl := map[string]string{
workflowproj.LabelApp: platform.Name,
}
lbl, selectorLbl := getLabels(platform, ps)
dataDeploySpec := appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: lbl,
MatchLabels: selectorLbl,
},
Replicas: &replicas,
Template: corev1.PodTemplateSpec{
Expand Down Expand Up @@ -195,9 +193,7 @@ func createDeployment(ctx context.Context, client client.Client, platform *opera
}

func createService(ctx context.Context, client client.Client, platform *operatorapi.SonataFlowPlatform, ps services.Platform) error {
lbl := map[string]string{
workflowproj.LabelApp: platform.Name,
}
lbl, selectorLbl := getLabels(platform, ps)
dataSvcSpec := corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Expand All @@ -207,7 +203,7 @@ func createService(ctx context.Context, client client.Client, platform *operator
TargetPort: common.DefaultHTTPWorkflowPortIntStr,
},
},
Selector: lbl,
Selector: selectorLbl,
}
dataSvc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -233,18 +229,28 @@ func createService(ctx context.Context, client client.Client, platform *operator
return nil
}

func getLabels(platform *operatorapi.SonataFlowPlatform, ps services.Platform) (map[string]string, map[string]string) {
lbl := map[string]string{
workflowproj.LabelApp: platform.Name,
workflowproj.LabelService: ps.GetServiceName(),
}
selectorLbl := map[string]string{
workflowproj.LabelService: ps.GetServiceName(),
}
return lbl, selectorLbl
}

func createConfigMap(ctx context.Context, client client.Client, platform *operatorapi.SonataFlowPlatform, ps services.Platform) error {
handler, err := services.NewServiceAppPropertyHandler(ps)
if err != nil {
return err
}
lbl, _ := getLabels(platform, ps)
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: ps.GetServiceCmName(),
Namespace: platform.Namespace,
Labels: map[string]string{
workflowproj.LabelApp: platform.Name,
},
Labels: lbl,
},
Data: map[string]string{
workflowproj.ApplicationPropertiesFileName: handler.Build(),
Expand Down
2 changes: 2 additions & 0 deletions workflowproj/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const (
ApplicationPropertiesFileName = "application.properties"
// LabelApp key to use among object selectors, "app" is used among k8s applications to group objects in some UI consoles
LabelApp = "app"
// LabelService key to use among object selectors
LabelService = "sonataflow.org/service"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@masayag can you please fix this in a follow up PR?

LabelService = metadata.Domain + "/service"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricardozanini done here: #351

// LabelWorkflow specialized label managed by the controller
LabelWorkflow = metadata.Domain + "/workflow-app"
)
Expand Down
Loading