-
Notifications
You must be signed in to change notification settings - Fork 897
feat(examples): add labels and antiAffinity to k8s example #5763
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,11 @@ resource "kubernetes_pod" "main" { | |
metadata { | ||
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" | ||
namespace = var.namespace | ||
labels = { | ||
"app.kubernetes.io/name" = "coder-workspace" | ||
"app.kubernetes.io/instance" = "coder-workspace-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" | ||
"app.kubernetes.io/part-of" = "coder" | ||
} | ||
} | ||
spec { | ||
security_context { | ||
|
@@ -137,5 +142,23 @@ resource "kubernetes_pod" "main" { | |
read_only = false | ||
} | ||
} | ||
|
||
affinity { | ||
pod_anti_affinity { | ||
preferred_during_scheduling_ignored_during_execution { | ||
weight = 1 | ||
pod_affinity_term { | ||
topology_key = "kubernetes.io/hostname" | ||
label_selector { | ||
match_expressions { | ||
key = "app.kubernetes.io/name" | ||
operator = "In" | ||
values = ["coder-workspace"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused, because wouldn't this fail for the defaults on most Kubernetes cluster that don't have the hostname of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's matching pods that have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, I see. So even if you didn't deploy Coder with Kubernetes, this would still work? We should add a comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the spec, so I imagine any k8s-like apis would also implement this. I found some references to it in the openshift docs: https://docs.openshift.com/container-platform/4.8/nodes/scheduling/nodes-scheduler-node-selectors.html#nodes-scheduler-node-selectors-about_nodes-scheduler-node-selectors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I think I understand your question. This doesn't have anything to do with how Coder itself is deployed. |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add some more labels similar to what we do in v1 for workspace details. Should add these to the PVC too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the labels I could from v1