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

workload Select() function updates the selector, but not the toPodSelectorConfig function #2238

Open
sthomson-wyn opened this issue Nov 7, 2024 · 3 comments
Labels
bug Something isn't working @component/cdk8s-plus Issue related to cdk8s-plus effort/medium 1 week tops feature-request New/Enhanced functionality wanted

Comments

@sthomson-wyn
Copy link

Description of the bug:

When updating the matchlabels for a workload (say, a deployment), updating the pod selector does not update the output of the toPodSelectorConfig function

Reproduction Steps:

Create a deployment, and update the selector labels:

deployment := cdk8splus31.NewDeployment(chart, &deploymentName, &cdk8splus31.DeploymentProps{
		Select:                       boolPtr(false),
...
})
deployment.Select(cdk8splus31.LabelSelector_Of(&cdk8splus31.LabelSelectorOptions{
		Labels: &selectorLabels,
	}))

Results in the correct matchLabels in my deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  selector:
    matchLabels:
      my-selectors: hello-world

However, when trying to use said deployment for a Service (or any other thing that uses an IPodSelector)

svc := cdk8splus31.NewService(chart, strPtr(*config.ServiceName+"-svc"), &cdk8splus31.ServiceProps{
  Selector: deployment,
})

Results in

apiVersion: v1
kind: Service
metadata:
  name: my-svc
spec:
  ports:
    - name: http
      port: 80
      protocol: TCP
  selector:
    cdk8s.io/metadata.addr: my-deployment-c8aaf3f2
  type: ClusterIP

Environment:

  • Framework Version: 2.198.254
  • OS: Ubuntu

Other:


This is 🐛 Bug Report

@sthomson-wyn sthomson-wyn added bug Something isn't working needs-triage Priority and effort undetermined yet labels Nov 7, 2024
@iliapolo
Copy link
Member

@sthomson-wyn Just to make I understand, did you expect to see:

apiVersion: v1
kind: Service
metadata:
  name: my-svc
spec:
  ports:
    - name: http
      port: 80
      protocol: TCP
  selector:
    my-selectors: hello-world
  type: ClusterIP

?

@iliapolo iliapolo added the response-requested Awaiting response from author label Dec 10, 2024
@sthomson-wyn
Copy link
Author

@iliapolo yep, that's what I would expect

@github-actions github-actions bot removed the response-requested Awaiting response from author label Dec 10, 2024
@iliapolo iliapolo added priority/p2 Dependent on community feedback. PR's are welcome :) needs-triage Priority and effort undetermined yet and removed needs-triage Priority and effort undetermined yet priority/p2 Dependent on community feedback. PR's are welcome :) labels Feb 24, 2025
@iliapolo
Copy link
Member

iliapolo commented Feb 24, 2025

I see. Does this have undesired affects though? does the cdk8s.io/metadata.addr: my-deployment-c8aaf3f2 selector exist on the pod template metadata? If it does, it still uniquely selects the deployment you tell it to.

I'll mark this as a feature request as this is behaving as intended, the question now is there a gap in functionality here or not. Agree its confusing though because the cdk8s.io/metadata.addr gets special treatment where maybe it shouldn't.

@iliapolo iliapolo added feature-request New/Enhanced functionality wanted effort/medium 1 week tops @component/cdk8s-plus Issue related to cdk8s-plus and removed needs-triage Priority and effort undetermined yet labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @component/cdk8s-plus Issue related to cdk8s-plus effort/medium 1 week tops feature-request New/Enhanced functionality wanted
Projects
None yet
Development

No branches or pull requests

2 participants