-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving webhook to its own service (#2849)
* Moving webhook to its own service * Fix webhook tests * Fix duplicated port * Apply suggestions from code review Co-authored-by: Sylvain Lesage <[email protected]> * Apply code review suggestions * Address code review observations --------- Co-authored-by: Sylvain Lesage <[email protected]>
- Loading branch information
1 parent
6efa88b
commit 9ba61fc
Showing
46 changed files
with
4,204 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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 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 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,35 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2024 The HuggingFace Authors. | ||
|
||
name: services/webhook | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "libs/libapi/**" | ||
- "libs/libcommon/**" | ||
- "services/webhook/**" | ||
- ".github/workflows/s-webhook.yml" | ||
- ".github/workflows/_quality-python.yml" | ||
- ".github/workflows/_unit-tests-python.yml" | ||
- "tools/docker-compose-mongo.yml" | ||
pull_request: | ||
paths: | ||
- "libs/libapi/**" | ||
- "libs/libcommon/**" | ||
- "services/webhook/**" | ||
- ".github/workflows/s-webhook.yml" | ||
- ".github/workflows/_quality-python.yml" | ||
- ".github/workflows/_unit-tests-python.yml" | ||
- "tools/docker-compose-mongo.yml" | ||
jobs: | ||
quality: | ||
uses: ./.github/workflows/_quality-python.yml | ||
with: | ||
working-directory: services/webhook | ||
unit-tests: | ||
uses: ./.github/workflows/_unit-tests-python.yml | ||
with: | ||
working-directory: services/webhook |
This file contains 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 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 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 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 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 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 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,55 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2022 The HuggingFace Authors. | ||
|
||
{{- define "containerWebhook" -}} | ||
- name: "{{ include "name" . }}-webhook" | ||
image: {{ include "services.webhook.image" . }} | ||
imagePullPolicy: {{ .Values.images.pullPolicy }} | ||
env: | ||
{{ include "envCache" . | nindent 2 }} | ||
{{ include "envS3" . | nindent 2 }} | ||
{{ include "envCloudfront" . | nindent 2 }} | ||
{{ include "envQueue" . | nindent 2 }} | ||
{{ include "envCommon" . | nindent 2 }} | ||
{{ include "envHf" . | nindent 2 }} | ||
{{ include "envLog" . | nindent 2 }} | ||
{{ include "envNumba" . | nindent 2 }} | ||
# storage | ||
{{ include "envAssets" . | nindent 2 }} | ||
{{ include "envCachedAssets" . | nindent 2 }} | ||
# service | ||
- name: API_MAX_AGE_LONG | ||
value: {{ .Values.webhook.maxAgeLong | quote }} | ||
- name: API_MAX_AGE_SHORT | ||
value: {{ .Values.webhook.maxAgeShort | quote }} | ||
# prometheus | ||
- name: PROMETHEUS_MULTIPROC_DIR | ||
value: {{ .Values.webhook.prometheusMultiprocDirectory | quote }} | ||
# uvicorn | ||
- name: API_UVICORN_HOSTNAME | ||
value: {{ .Values.webhook.uvicornHostname | quote }} | ||
- name: API_UVICORN_NUM_WORKERS | ||
value: {{ .Values.webhook.uvicornNumWorkers | quote }} | ||
- name: API_UVICORN_PORT | ||
value: {{ .Values.webhook.uvicornPort | quote }} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
readinessProbe: | ||
failureThreshold: 30 | ||
periodSeconds: 5 | ||
httpGet: | ||
path: /healthcheck | ||
port: {{ .Values.webhook.uvicornPort }} | ||
livenessProbe: | ||
failureThreshold: 30 | ||
periodSeconds: 5 | ||
httpGet: | ||
path: /healthcheck | ||
port: {{ .Values.webhook.uvicornPort }} | ||
ports: | ||
- containerPort: {{ .Values.webhook.uvicornPort }} | ||
name: http | ||
protocol: TCP | ||
resources: | ||
{{ toYaml .Values.webhook.resources | nindent 4 }} | ||
{{- end -}} |
This file contains 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,30 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2022 The HuggingFace Authors. | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: {{ include "labels.webhook" . | nindent 4 }} | ||
name: "{{ include "name" . }}-webhook" | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
progressDeadlineSeconds: 600 | ||
replicas: {{ .Values.webhook.replicas }} | ||
revisionHistoryLimit: 10 | ||
selector: | ||
matchLabels: {{ include "labels.webhook" . | nindent 6 }} | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 25% | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: {{ include "labels.webhook" . | nindent 8 }} | ||
spec: | ||
{{- include "dnsConfig" . | nindent 6 }} | ||
{{- include "image.imagePullSecrets" . | nindent 6 }} | ||
containers: {{ include "containerWebhook" . | nindent 8 }} | ||
nodeSelector: {{ toYaml .Values.webhook.nodeSelector | nindent 8 }} | ||
tolerations: {{ toYaml .Values.webhook.tolerations | nindent 8 }} | ||
securityContext: {{ include "securityContext" . | nindent 8 }} |
This file contains 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,23 @@ | ||
{{- if and .Values.global.huggingface.ingress.enabled .Values.ingress.enabled .Values.webhook.ingress.enabled -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
{{- $annotations := fromYaml (include "datasetsServer.instance.ingress.annotations" (dict "instance" .Values.webhook "context" $ )) }} | ||
annotations: {{ toYaml $annotations | nindent 4}} | ||
labels: {{ include "labels.webhook" . | nindent 4 }} | ||
name: "{{ include "name" . }}-webhook" | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
rules: | ||
- host: {{ include "datasetsServer.ingress.hostname" . }} | ||
http: | ||
paths: | ||
- backend: | ||
service: | ||
name: "{{ include "name" . }}-webhook" | ||
port: | ||
name: http | ||
path: /webhook | ||
pathType: Prefix | ||
{{- include "ingress.tls" (merge (dict "annotations" $annotations) $ ) | indent 2}} | ||
{{- end }} |
This file contains 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 @@ | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
labels: {{ include "labels.webhook" . | nindent 4 }} | ||
name: "{{ include "name" . }}-webhook" | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
maxUnavailable: 1 | ||
selector: | ||
matchLabels: {{ include "labels.webhook" . | nindent 6 }} |
This file contains 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,22 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2022 The HuggingFace Authors. | ||
|
||
{{ $serviceType := .Values.webhook.service.type | default .Values.global.huggingface.service.type }} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "{{ include "name" . }}-webhook" | ||
annotations: {{ toYaml .Values.webhook.service.annotations | nindent 4 }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{ include "labels.webhook" . | nindent 4 }} | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
protocol: TCP | ||
{{- if eq "NodePort" $serviceType }} | ||
nodePort: {{ .Values.global.huggingface.service.ports.datasetsServer.webhook }} | ||
{{- end }} | ||
targetPort: {{ .Values.webhook.uvicornPort }} | ||
selector: {{ include "labels.webhook" . | nindent 4 }} | ||
type: {{ $serviceType }} |
This file contains 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,20 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2022 The HuggingFace Authors. | ||
|
||
{{- if .Values.monitoring.enabled }} | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
labels: {{ include "labels.webhook" . | nindent 4 }} | ||
name: "{{ include "name" . }}-webhook" | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
endpoints: | ||
- path: /metrics | ||
port: http | ||
namespaceSelector: | ||
matchNames: | ||
- {{ .Release.Namespace }} | ||
selector: | ||
matchLabels: {{ include "labels.webhook" . | nindent 6 }} | ||
{{- end }} |
Oops, something went wrong.