Skip to content

Commit

Permalink
fix: change the annotation key for enabling LB type service
Browse files Browse the repository at this point in the history
  • Loading branch information
Fei-Guo committed Nov 6, 2023
1 parent b25218e commit ff444e9
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 10 deletions.
7 changes: 2 additions & 5 deletions api/v1alpha1/workspace_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ const (
// KAITOPrefix Kubernetes Data Mining prefix.
KAITOPrefix = "kaito.sh/"

// AnnotationServiceType determines whether kaito creates ClusterIP or LoadBalancer type service.
AnnotationServiceType = KAITOPrefix + "service-type"
// AnnotationEnableLB determines whether kaito creates LoadBalancer type service.for testing.
AnnotationEnableLB = KAITOPrefix + "enablelb"

// LabelWorkspaceName is the label for workspace name.
LabelWorkspaceName = KAITOPrefix + "workspace"

// LabelWorkspaceName is the label for workspace namespace.
LabelWorkspaceNamespace = KAITOPrefix + "workspacenamespace"

ServiceTypeClusterIP = "cluster-ip"
ServiceTypeLoadBalancer = "load-balancer"
)
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Notes:
For **testing** purposes, users can add the `kaito.sh/enablelb: "True"` annotation to the workspace custom resource. As a result, a `loadbalancer` type service will be created for the inference service with a public IP being assigned. However, this is **NOT** recommended for production use. An [ingress controller](https://learn.microsoft.com/en-us/azure/aks/ingress-basic?tabs=azure-cli) is recommended to expose the service to public.
2 changes: 2 additions & 0 deletions examples/kaito_workspace_falcon_7b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apiVersion: kaito.sh/v1alpha1
kind: Workspace
metadata:
name: workspace-falcon-7b
annotations:
kaito.sh/enablelb: "True"
resource:
instanceType: "Standard_NC12s_v3"
labelSelector:
Expand Down
2 changes: 1 addition & 1 deletion examples/kaito_workspace_llama2_13b-chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource:
instanceType: "Standard_NC12s_v3"
labelSelector:
matchLabels:
apps: llama-2-13b
apps: llama-2-13b-chat
inference:
preset:
name: "llama-2-13b-chat"
Expand Down
15 changes: 15 additions & 0 deletions examples/kaito_workspace_llama2_13b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kaito.sh/v1alpha1
kind: Workspace
metadata:
name: workspace-llama-2-13b
resource:
instanceType: "Standard_NC12s_v3"
labelSelector:
matchLabels:
apps: llama-2-13b
inference:
preset:
name: "llama-2-13b"
accessMode: private
presetOptions:
image: <YOUR IMAGE URL>
2 changes: 1 addition & 1 deletion examples/kaito_workspace_llama2_70b-chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource:
count: 2
labelSelector:
matchLabels:
apps: llama-2-70b
apps: llama-2-70b-chat
inference:
preset:
name: "llama-2-70b-chat"
Expand Down
16 changes: 16 additions & 0 deletions examples/kaito_workspace_llama2_70b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: kaito.sh/v1alpha1
kind: Workspace
metadata:
name: workspace-llama-2-70b
resource:
instanceType: "Standard_NC96ads_A100_v4"
count: 2
labelSelector:
matchLabels:
apps: llama-2-70b
inference:
preset:
name: "llama-2-70b"
accessMode: private
presetOptions:
image: <YOUR IMAGE URL>
2 changes: 1 addition & 1 deletion examples/kaito_workspace_llama2_7b-chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource:
instanceType: "Standard_NC12s_v3"
labelSelector:
matchLabels:
apps: llama-2-7b
apps: llama-2-7b-chat
inference:
preset:
name: "llama-2-7b-chat"
Expand Down
15 changes: 15 additions & 0 deletions examples/kaito_workspace_llama2_7b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kaito.sh/v1alpha1
kind: Workspace
metadata:
name: workspace-llama-2-7b
resource:
instanceType: "Standard_NC12s_v3"
labelSelector:
matchLabels:
apps: llama-2-7b
inference:
preset:
name: "llama-2-7b"
accessMode: private
presetOptions:
image: <YOUR IMAGE URL>
4 changes: 2 additions & 2 deletions pkg/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ func (c *WorkspaceReconciler) ensureService(ctx context.Context, wObj *kaitov1al
wAnnotation := wObj.GetAnnotations()

if len(wAnnotation) != 0 {
_, found := lo.FindKey(wAnnotation, kaitov1alpha1.ServiceTypeLoadBalancer)
if found {
val, found := wAnnotation[kaitov1alpha1.AnnotationEnableLB]
if found && val == "True" {
serviceType = corev1.ServiceTypeLoadBalancer
}
}
Expand Down

0 comments on commit ff444e9

Please sign in to comment.