-
Notifications
You must be signed in to change notification settings - Fork 821
Feat/enterprise readiness #2753
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
Open
jpjamespeterson
wants to merge
2
commits into
alibaba:main
Choose a base branch
from
jpjamespeterson:feat/enterprise-readiness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [ feat/**, main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22.x' | ||
- name: Tidy | ||
run: | | ||
go mod tidy | ||
- name: Unit tests | ||
run: | | ||
go test ./pkg/... ./test/... -run Test -v |
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Autoscaling for AI Workloads (KEDA) | ||
|
||
Enable KEDA-driven autoscaling from Prometheus metrics: | ||
|
||
```bash | ||
helm upgrade --install higress ./helm/core \ | ||
--set keda.enabled=true \ | ||
--set keda.metric.name=higress_ai_token_usage_total \ | ||
--set keda.metric.threshold=100 | ||
``` | ||
|
||
At runtime, the ai-proxy plugin emits metrics which can be scraped by Prometheus and used by KEDA ScaledObject. | ||
|
||
To manage ScaledObjects programmatically, build with `-tags keda` and use `pkg/autoscaler.NewKedaScaler`. |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Multi-Cluster with Karmada | ||
|
||
This guide shows how to enable multi-cluster configuration sync for Higress using Karmada. | ||
|
||
## Prerequisites | ||
- A running Karmada control plane and at least one member cluster. See `https://karmada.io/docs`. | ||
- Higress installed via Helm. | ||
|
||
## Enable Helm options | ||
|
||
Set the following values: | ||
|
||
```bash | ||
helm upgrade --install higress ./helm/core \ | ||
--set karmada.enabled=true | ||
``` | ||
|
||
This installs a ClusterPropagationPolicy that propagates the Higress ConfigMap to all clusters. | ||
|
||
## Programmatic usage | ||
|
||
Build Higress with Karmada integration to use the `pkg/karmada` package: | ||
|
||
```bash | ||
CGO_ENABLED=0 go build -tags karmada ./... | ||
``` | ||
|
||
Then use `karmada.NewKarmadaSync(client)` and call `SyncConfigMap` / `SyncCRD`. |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Observability for AI Workloads | ||
|
||
Higress can export AI-specific metrics and traces. | ||
|
||
## Metrics (Prometheus) | ||
- Counter: `higress_ai_token_usage_total` | ||
- Histogram: `higress_ai_model_latency_milliseconds` | ||
|
||
Enable Prometheus scraping with Helm: | ||
|
||
```bash | ||
helm upgrade --install higress ./helm/core \ | ||
--set observability.prometheus.enabled=true | ||
``` | ||
|
||
## Tracing (OpenTelemetry) | ||
Enable the built-in OpenTelemetry Collector via Helm: | ||
|
||
```bash | ||
helm upgrade --install higress ./helm/core \ | ||
--set observability.otelCollector.enabled=true | ||
``` | ||
|
||
Programmatically, initialize tracing via `pkg/observability.SetupTracing`. |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Multi-Tenancy | ||
|
||
Higress can isolate resources by Kubernetes namespace. Use `pkg/tenancy.TenantManager` to validate and check namespace access. | ||
|
||
RBAC: ensure each tenant has access only to their namespace resources. | ||
|
||
Future work: integrate filters in the gateway reconcilers to enforce tenant scoping. |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Volcano Integration for Batch AI Workloads | ||
|
||
Enable the Volcano sample job with Helm: | ||
|
||
```bash | ||
helm upgrade --install higress ./helm/core \ | ||
--set volcano.enabled=true | ||
``` | ||
|
||
To programmatically submit jobs from code, build with `-tags volcano` and use `pkg/volcano.NewVolcanoScheduler`. |
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{- if .Values.karmada.enabled }} | ||
apiVersion: policy.karmada.io/v1alpha1 | ||
kind: ClusterPropagationPolicy | ||
metadata: | ||
name: higress-configmaps | ||
spec: | ||
resourceSelectors: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
name: higress-config | ||
namespace: {{ .Release.Namespace }} | ||
placement: | ||
clusterAffinity: {} | ||
{{- end }} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.keda.enabled }} | ||
apiVersion: keda.sh/v1alpha1 | ||
kind: ScaledObject | ||
metadata: | ||
name: {{ include "controller.name" . }}-scaledobject | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
scaleTargetRef: | ||
kind: Deployment | ||
name: {{ include "controller.name" . }} | ||
triggers: | ||
- type: prometheus | ||
metadata: | ||
serverAddress: {{ .Values.keda.prometheus.serverAddress | quote }} | ||
metricName: {{ .Values.keda.metric.name | quote }} | ||
threshold: {{ .Values.keda.metric.threshold | quote }} | ||
{{- end }} |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{{- if .Values.observability.otelCollector.enabled }} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "higress.fullname" . }}-otel-collector | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: {{ include "higress.fullname" . }}-otel-collector | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ include "higress.fullname" . }}-otel-collector | ||
spec: | ||
containers: | ||
- name: otel-collector | ||
image: {{ .Values.observability.otelCollector.image | default "otel/opentelemetry-collector:0.102.1" | quote }} | ||
args: ["--config=/etc/otel/config.yaml"] | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/otel | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: {{ include "higress.fullname" . }}-otel-config | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "higress.fullname" . }}-otel-config | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
config.yaml: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
http: | ||
exporters: | ||
logging: {} | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
exporters: [logging] | ||
{{- end }} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.observability.prometheus.enabled }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
name: {{ include "higress.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
release: prometheus | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: {{ include "higress.name" . }} | ||
endpoints: | ||
- port: metrics | ||
path: /metrics | ||
interval: 30s | ||
{{- end }} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{{- if .Values.volcano.enabled }} | ||
apiVersion: batch.volcano.sh/v1alpha1 | ||
kind: Job | ||
metadata: | ||
name: {{ include "higress.fullname" . }}-sample-batch | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
minAvailable: 1 | ||
tasks: | ||
- replicas: 1 | ||
name: infer | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: infer | ||
image: {{ .Values.volcano.image | default "busybox" | quote }} | ||
command: ["/bin/sh", "-c", "echo sample batch job"] | ||
{{- end }} |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//go:build keda | ||
|
||
package autoscaler | ||
|
||
import ( | ||
context "context" | ||
"fmt" | ||
|
||
kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type KedaScaler struct { | ||
Client client.Client | ||
Namespace string | ||
Deployment string | ||
} | ||
|
||
func NewKedaScaler(c client.Client, namespace, deployment string) *KedaScaler { | ||
return &KedaScaler{Client: c, Namespace: namespace, Deployment: deployment} | ||
} | ||
|
||
// ScaleByLLMMetrics creates/updates a ScaledObject using a Prometheus trigger on a given metric. | ||
func (s *KedaScaler) ScaleByLLMMetrics(metricName string, targetValue int) error { | ||
if s == nil || s.Client == nil || metricName == "" { | ||
return nil | ||
} | ||
ctx := context.TODO() | ||
so := &kedav1alpha1.ScaledObject{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "higress-" + s.Deployment + "-scaledobject", | ||
Namespace: s.Namespace, | ||
}, | ||
Spec: kedav1alpha1.ScaledObjectSpec{ | ||
ScaleTargetRef: &kedav1alpha1.ScaleTarget{ | ||
Kind: "Deployment", | ||
Name: s.Deployment, | ||
}, | ||
Triggers: []kedav1alpha1.ScaleTriggers{ | ||
{ | ||
Type: "prometheus", | ||
Metadata: map[string]string{ | ||
"serverAddress": "http://prometheus-server.monitoring.svc.cluster.local", | ||
"metricName": metricName, | ||
"threshold": fmt.Sprintf("%d", targetValue), | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
var existing kedav1alpha1.ScaledObject | ||
if err := s.Client.Get(ctx, client.ObjectKey{Name: so.Name, Namespace: s.Namespace}, &existing); err == nil { | ||
existing.Spec = so.Spec | ||
return s.Client.Update(ctx, &existing) | ||
} | ||
return s.Client.Create(ctx, so) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
KEDA自动伸缩器应允许配置Prometheus服务器地址,而不是硬编码。
📋 问题详情
当前代码在
ScaleByLLMMetrics
方法中硬编码了Prometheus服务器地址,这使得配置不够灵活。应该允许通过参数或环境变量来配置服务器地址。💡 解决方案
应该允许通过参数或环境变量来配置Prometheus服务器地址,而不是硬编码。这样可以提高配置的灵活性。
有用意见👍 | 无用意见👎 | 错误意见❌