Skip to content

Commit d929811

Browse files
initial drop of the activator code
Co-authored-by: Braulio Dumba <[email protected]> Signed-off-by: Lionel Villard <[email protected]>
1 parent 5176573 commit d929811

File tree

33 files changed

+2280
-1
lines changed

33 files changed

+2280
-1
lines changed

Dockerfile.activator

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Multistage build
2+
FROM quay.io/projectquay/golang:1.25 AS builder
3+
ARG COMMIT_SHA=unknown
4+
ARG BUILD_REF
5+
ARG TARGETOS=linux
6+
ARG TARGETARCH=amd64
7+
ENV CGO_ENABLED=0
8+
ENV GOOS=$TARGETOS
9+
ENV GOARCH=$TARGETARCH
10+
11+
# Dependencies
12+
WORKDIR /src
13+
COPY go.mod go.sum ./
14+
RUN go mod download
15+
16+
# Sources
17+
COPY cmd/activator ./cmd/activator
18+
COPY pkg/activator ./pkg/activator
19+
WORKDIR /src/cmd/activator
20+
RUN go build -ldflags="-X sigs.k8s.io/gateway-api-inference-extension/version.CommitSHA=${COMMIT_SHA} -X sigs.k8s.io/gateway-api-inference-extension/version.BuildRef=${BUILD_REF}" -o /activator
21+
22+
## Multistage deploy
23+
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
24+
25+
WORKDIR /
26+
COPY --from=builder /activator /activator
27+
28+
ENTRYPOINT ["/activator"]

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ SIDECAR_IMAGE_TAG_BASE ?= ghcr.io/llm-d/$(SIDECAR_IMAGE_NAME)
1818
SIDECAR_IMG = $(SIDECAR_IMAGE_TAG_BASE):$(SIDECAR_TAG)
1919
NAMESPACE ?= hc4ai-operator
2020

21+
ACTIVATOR_IMAGE_TAG_BASE ?= $(IMAGE_REGISTRY)/$(PROJECT_NAME)-activator
22+
ACTIVATOR_IMG = $(ACTIVATOR_IMAGE_TAG_BASE):$(EPP_TAG)
23+
2124
# Map go arch to typos arch
2225
ifeq ($(TARGETARCH),amd64)
2326
TYPOS_TARGET_ARCH = x86_64
@@ -134,6 +137,14 @@ sidecar-build: check-go ## Build the Sidecar
134137
@printf "\033[33;1m==== Building the Sidecar ====\033[0m\n"
135138
go build -o bin/$(SIDECAR_NAME) cmd/$(SIDECAR_NAME)/main.go
136139

140+
##@ Build Activator
141+
142+
.PHONY: activator-build
143+
activator-build: check-go install-dependencies download-tokenizer ## Build the project
144+
@printf "\033[33;1m==== Building ====\033[0m\n"
145+
go build -ldflags="$(LDFLAGS)" -o bin/activator cmd/activator/main.go
146+
147+
137148
##@ Container Build/Push
138149

139150
.PHONY: image-build
@@ -167,6 +178,22 @@ sidecar-image-push: check-container-tool load-version-json ## Push Sidecar Docke
167178
@printf "\033[33;1m==== Pushing Sidecar Docker image $(SIDECAR_IMG) ====\033[0m\n"
168179
$(CONTAINER_TOOL) push $(SIDECAR_IMG)
169180

181+
.PHONY: activator-image-build
182+
activator-image-build: ## Build the activator image using Docker Buildx.
183+
$(CONTAINER_TOOL) build \
184+
--platform linux/$(TARGETARCH) \
185+
--build-arg TARGETOS=linux \
186+
--build-arg TARGETARCH=${TARGETARCH} \
187+
--build-arg COMMIT_SHA=${GIT_COMMIT_SHA} \
188+
--build-arg BUILD_REF=${BUILD_REF} \
189+
-t $(ACTIVATOR_IMG) \
190+
-f Dockerfile.activator .
191+
192+
.PHONY: activator-image-push
193+
activator-image-push: check-container-tool load-version-json ## Push Activator Docker image $(ACTIVATOR_IMG) to registry
194+
@printf "\033[33;1m==== Pushing Activator Docker image $(ACTIVATOR_IMG) ====\033[0m\n"
195+
$(CONTAINER_TOOL) push $(ACTIVATOR_IMG)
196+
170197
##@ Install/Uninstall Targets
171198

172199
# Default install/uninstall (Docker)
@@ -283,7 +310,7 @@ check-typos: $(TYPOS) ## Check for spelling errors using typos (exits with error
283310
echo "$$TYPOS_OUTPUT"; \
284311
exit 1; \
285312
fi
286-
313+
287314
##@ Tools
288315

289316
.PHONY: check-tools
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/activator-filter/Chart.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v2
2+
name: activator
3+
description: A Helm chart for the activator extension
4+
5+
type: application
6+
7+
version: 0.1.0
8+
9+
appVersion: "0.2.0"

charts/activator-filter/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Activator Chart
2+
3+
A chart to deploy the activator HTTP filter for an InferenceGateway and RBAC for all per route activator deployments.
4+
5+
## Install
6+
7+
To install an activator-filter named `activator-filter`, you can run the following command:
8+
9+
```txt
10+
$ helm install activator-filter ./charts/activator-filter
11+
```
12+
13+
## Uninstall
14+
15+
Run the following command to uninstall the chart:
16+
17+
```txt
18+
$ helm uninstall activator-filter
19+
```
20+
21+
## Configuration
22+
23+
The following table list the configurable parameters of the chart.
24+
25+
| **Parameter Name** | **Description** |
26+
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
27+
| `name` | Name of the activator RBAC resources. Defaults to `activator`. |
28+
29+
## Notes
30+
31+
This chart should only be deployed once.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Activator HTTP Filter deployed.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: networking.istio.io/v1alpha3
2+
kind: EnvoyFilter
3+
metadata:
4+
name: {{ .Values.name }}-ext-proc
5+
namespace: {{ .Release.Namespace }}
6+
spec:
7+
configPatches:
8+
- applyTo: HTTP_FILTER
9+
match:
10+
# context omitted so that this applies to both sidecars and gateways
11+
listener:
12+
filterChain:
13+
filter:
14+
name: "envoy.filters.network.http_connection_manager"
15+
patch:
16+
operation: INSERT_FIRST # TODO: insert before EPP
17+
value:
18+
name: envoy.filters.http.activator.ext_proc
19+
typed_config:
20+
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor
21+
failure_mode_allow: true
22+
grpc_service:
23+
envoy_grpc:
24+
cluster_name: no-op
25+
message_timeout: 120s
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: {{ .Values.name }}
5+
namespace: {{ .Release.Namespace }}
6+
---
7+
kind: Role
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
metadata:
10+
name: {{ .Values.name }}
11+
namespace: {{ .Release.Namespace }}
12+
rules: # TODO: These can probably be trimmed down
13+
- apiGroups:
14+
- "inference.networking.x-k8s.io"
15+
resources:
16+
- "inferencepools"
17+
verbs:
18+
- "get"
19+
- "watch"
20+
- "list"
21+
- apiGroups:
22+
- ""
23+
resources:
24+
- "pods"
25+
verbs:
26+
- "get"
27+
- "watch"
28+
- "list"
29+
- apiGroups:
30+
- "discovery.k8s.io"
31+
resources:
32+
- "endpointslices"
33+
verbs:
34+
- "get"
35+
- "watch"
36+
- "list"
37+
- apiGroups:
38+
- "authentication.k8s.io"
39+
resources:
40+
- "tokenreviews"
41+
verbs:
42+
- "create"
43+
- apiGroups:
44+
- "authorization.k8s.io"
45+
resources:
46+
- "subjectaccessreviews"
47+
verbs:
48+
- "create"
49+
- apiGroups:
50+
- "apps"
51+
resources:
52+
- "deployments"
53+
verbs:
54+
- "create"
55+
- "get"
56+
- "list"
57+
- "watch"
58+
- "update"
59+
- "patch"
60+
- "delete"
61+
- apiGroups:
62+
- apps
63+
resources:
64+
- deployments/scale
65+
verbs:
66+
- get
67+
- update
68+
---
69+
apiVersion: rbac.authorization.k8s.io/v1
70+
kind: RoleBinding
71+
metadata:
72+
name: {{ .Values.name }}
73+
namespace: {{ .Release.Namespace }}
74+
subjects:
75+
- kind: ServiceAccount
76+
name: {{ .Values.name }}
77+
namespace: {{ .Release.Namespace }}
78+
roleRef:
79+
apiGroup: rbac.authorization.k8s.io
80+
kind: Role
81+
name: {{ .Values.name }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: activator

charts/activator/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

0 commit comments

Comments
 (0)