Skip to content

fix(examples): use more precise example kubernetes template labels #14028

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

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

geniass
Copy link
Contributor

@geniass geniass commented Jul 26, 2024

The current example template doesn't have the selector labels to correct identify the pods created by the workspace kubernetes deployment.

I.e. when multiple workspaces are created from a template, the deployment resources incorrectly try to manage pods from the other workspace's deployment.

This fix also changes persistent resource names to use immutable IDs instead of names as per the docs: https://coder.com/docs/templates/resource-persistence

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Jul 26, 2024
Copy link

github-actions bot commented Jul 26, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@geniass geniass changed the title Fix kubernetes template example labels fix(examples): use more preceise example kubernetes template labels Jul 26, 2024
@geniass geniass changed the title fix(examples): use more preceise example kubernetes template labels fix(examples): use more precise example kubernetes template labels Jul 26, 2024
@geniass
Copy link
Contributor Author

geniass commented Jul 26, 2024

I have read the CLA Document and I hereby sign the CLA

@geniass
Copy link
Contributor Author

geniass commented Jul 26, 2024

recheck

@matifali matifali requested review from johnstcn and kylecarbs July 27, 2024 12:00
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

I agree with the overall intent, but Kubernetes PVCs have a length limit of 63 characters. The workspace_instance local will be 73 characters long as it consists of 2 UUIDs joined by a hyphen.

How about we instead use data.coder_workspace.me.id to act as a stable identifier?

@geniass
Copy link
Contributor Author

geniass commented Jul 30, 2024

I agree with the overall intent, but Kubernetes PVCs have a length limit of 63 characters. The workspace_instance local will be 73 characters long as it consists of 2 UUIDs joined by a hyphen.

How about we instead use data.coder_workspace.me.id to act as a stable identifier?

Good catch, I think data.coder_workspace.me.id is good for the PVC name. Do you think there's any reason to keep workspace_instance for the labels or should I just make everything use the workspace ID?

@johnstcn
Copy link
Member

Good catch, I think data.coder_workspace.me.id is good for the PVC name. Do you think there's any reason to keep workspace_instance for the labels or should I just make everything use the workspace ID?

I think you'll run into the same issue if you try to use that workspace_instance local as a label value:

A label key and value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters each.

https://kubernetes.io/docs/reference/kubectl/generated/kubectl_label/

@geniass geniass force-pushed the fix-kubernetes-template-example-labels branch from fb0805a to bf1ea39 Compare July 31, 2024 10:32
@geniass
Copy link
Contributor Author

geniass commented Jul 31, 2024

Sorry I didn't realise labels had the same restriction. I've changed everything to just use the workspace ID.

@matifali matifali requested a review from johnstcn August 7, 2024 13:40
@matifali
Copy link
Member

matifali commented Aug 7, 2024

@geniass, it looks like CLA is still not signed by you. This can happen if your GitHub email and your commuter email are different.

@geniass
Copy link
Contributor Author

geniass commented Aug 8, 2024

recheck

cdrcommunity added a commit to coder/cla that referenced this pull request Aug 8, 2024
@geniass geniass force-pushed the fix-kubernetes-template-example-labels branch from fb6fb0f to bf1ea39 Compare August 8, 2024 09:31
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

👍 Smoke-tested on my personal deployment (v2.14.1)

@johnstcn johnstcn merged commit f50e1d5 into coder:main Aug 8, 2024
47 of 48 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Pull Requests and issues created by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants