-
Notifications
You must be signed in to change notification settings - Fork 888
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,17 @@ resource "kubernetes_persistent_volume_claim" "home" { | |
metadata { | ||
name = "coder-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}-home" | ||
namespace = var.namespace | ||
labels = { | ||
"app.kubernetes.io/name" = "coder-pvc" | ||
"app.kubernetes.io/instance" = "coder-pvc-${lower(data.coder_workspace.me.owner)}-${lower(data.coder_workspace.me.name)}" | ||
"app.kubernetes.io/part-of" = "coder" | ||
// Coder specific labels. | ||
"com.coder.resource" = "true" | ||
"com.coder.workspace.id" = data.coder_workspace.me.id | ||
"com.coder.workspace.name" = data.coder_workspace.me.name | ||
"com.coder.user.id" = data.coder_workspace.me.owner_id | ||
"com.coder.user.username" = data.coder_workspace.me.owner | ||
} | ||
} | ||
wait_until_bound = false | ||
spec { | ||
|
@@ -106,6 +117,17 @@ 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" | ||
Comment on lines
+121
to
+123
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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. Added the labels I could from v1 $ kdpo coder-colin-gea
Name: coder-colin-gea
Namespace: colin-coder
Priority: 0
Service Account: default
Node: gke-dev-4-2-coder-node-pool-8b0aaa9c-wfg6/10.1.0.102
Start Time: Wed, 18 Jan 2023 10:49:01 -0600
Labels: app.kubernetes.io/instance=coder-workspace-colin-gea
app.kubernetes.io/name=coder-workspace
app.kubernetes.io/part-of=coder
com.coder.resource=true
com.coder.user=b851db54-9827-45bc-b453-72138b46f99c
com.coder.username=colin
com.coder.workspace.id=8118ca50-2edc-4b7c-8b70-61b3c7c3673d
com.coder.workspace.name=gea $ kd pvc coder-colin-gea-home
Name: coder-colin-gea-home
Namespace: colin-coder
StorageClass: standard
Status: Bound
Volume: pvc-d6612185-b553-459a-9c85-acce9bf33cc2
Labels: app.kubernetes.io/instance=coder-pvc-colin-gea
app.kubernetes.io/name=coder-pvc
app.kubernetes.io/part-of=coder
com.coder.resource=true
com.coder.workspace.id=8118ca50-2edc-4b7c-8b70-61b3c7c3673d
com.coder.workspace.name=gea |
||
// Coder specific labels. | ||
"com.coder.resource" = "true" | ||
"com.coder.workspace.id" = data.coder_workspace.me.id | ||
"com.coder.workspace.name" = data.coder_workspace.me.name | ||
"com.coder.user.id" = data.coder_workspace.me.owner_id | ||
"com.coder.user.username" = data.coder_workspace.me.owner | ||
} | ||
} | ||
spec { | ||
security_context { | ||
|
@@ -137,5 +159,26 @@ resource "kubernetes_pod" "main" { | |
read_only = false | ||
} | ||
} | ||
|
||
|
||
affinity { | ||
pod_anti_affinity { | ||
// This affinity attempts to spread out all workspace pods evenly across | ||
// nodes. | ||
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"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
email too, we provide email as
owner_email