Skip to content
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

Fix selector label incompatibility #39

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions charts/guardrails/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning]
(https://semver.org/spec/v2.0.0.html).

## [0.5.0] - 2024-12-02

### Added
## [0.5.1] - 2024-12-09

- Add caching support, enabled with `cache.enable: true` (default is `true`)
- HPA support for configuring scaling behavior
### Fixed

## [0.4.0] - 2024-11-26
- Reverted guardrails deployment selector labels change to be consistent with
previous chart versions. The cache layer deployment selector labels have been
updated to be independently unique.

### Changed

- Default image tag from `2.0.1` to `2.2.2`
- Conditionally set `WHYLABS_API_CACHE_ENDPOINT` environment variable based on
the `cache.enable` value.

## [0.5.0] - 2024-12-02

### Added

- Caching support enabled with `cache.enable: true`
- Horizontal Pod Autoscaler (HPA) support for configuring scaling behavior
- Startup probe to support more graceful startup and scaling behavior
- Add caching support, enabled with `cache.enable: true` (default is `true`)
- HPA support for configuring scaling behavior

## [0.3.1] - 2024-10-31

Expand Down
2 changes: 1 addition & 1 deletion charts/guardrails/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: guardrails
description: A Helm chart for WhyLabs Guardrails
type: application
version: 0.5.0
version: 0.5.1
appVersion: "2.2.2"
icon: "https://whylabs.ai/_next/static/images/whylabs-favicon-192c009321aebbb96c19921a170fc880.png"
12 changes: 6 additions & 6 deletions charts/guardrails/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# guardrails

![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.2.2](https://img.shields.io/badge/AppVersion-2.2.2-informational?style=flat-square)
![Version: 0.5.1](https://img.shields.io/badge/Version-0.5.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.2.2](https://img.shields.io/badge/AppVersion-2.2.2-informational?style=flat-square)

A Helm chart for WhyLabs Guardrails

Expand Down Expand Up @@ -118,14 +118,14 @@ release_name=""
# the working directory or --destination path
helm pull \
oci://ghcr.io/whylabs/guardrails \
--version 0.5.0
--version 0.5.1

# Requires the helm-diff plugin to be installed:
# helm plugin install https://github.com/databus23/helm-diff
helm diff upgrade \
--allow-unreleased \
--namespace "${target_namespace}" \
"${release_name}" guardrails-0.5.0.tgz
"${release_name}" guardrails-0.5.1.tgz
```

After you've installed the repo you can install the chart.
Expand All @@ -134,7 +134,7 @@ After you've installed the repo you can install the chart.
helm upgrade --install \
--create-namespace \
--namespace "${target_namespace}" \
"${release_name}" guardrails-0.5.0.tgz
"${release_name}" guardrails-0.5.1.tgz
```

## Exposing Guardrails Outside Kubernetes
Expand Down Expand Up @@ -290,7 +290,7 @@ autoscaling:
| cache.labels | object | `{}` | Labels for the cache. |
| cache.replicaCount | int | `1` | Number of replicas for the cache. |
| commonLabels | object | `{}` | Labels to add to all chart resources. |
| env | object | `{}` | [Environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for the `guardrails` container. **Supports Helm templating syntax**, e.g. you can use `{{ .Release.Name }}` or other templating variables, functions, and conditions within the the value of each environment variable. |
| env | object | `{"CONFIG_SYNC_INTERVAL":"1","TENANCY_MODE":"{{ .Values.tenancyMode | default \"SINGLE\" }}","WHYLABS_API_CACHE_ENDPOINT":"{{ if .Values.cache.enable }}{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local{{ else }}{{ end }}"}` | [Environment variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for the `guardrails` container. **Supports Helm templating syntax**, e.g. you can use `{{ .Release.Name }}` or other templating variables, functions, and conditions within the the value of each environment variable. |
| envFrom | list | `[{"secretRef":{"name":"whylabs-guardrails-api-key","optional":true}},{"secretRef":{"name":"whylabs-guardrails-api-secret","optional":true}}]` | Create environment variables from Kubernetes secrets or config maps. |
| envFrom[0].secretRef.name | string | `"whylabs-guardrails-api-key"` | Name of the Kubernetes secret containing the API key. The secret must be in the same namespace as the release and should be created prior to installing the chart. |
| envFrom[1].secretRef.name | string | `"whylabs-guardrails-api-secret"` | Name of the Kubernetes secret containing the container password, the value used when executing requests against the guardrails container. The secret must be in the same namespace as the release and should be created prior to installing the chart. |
Expand Down Expand Up @@ -322,7 +322,7 @@ autoscaling:
| serviceAccount.labels | object | `{}` | Labels to add to the service account. |
| serviceAccount.name | string | `""` | If this is set and `serviceAccount.create` is `true` this will be used for the created `ServiceAccount` name, if set and `serviceAccount.create` is `false` then this will define an existing `ServiceAccount` to use. |
| startupProbe | object | `{"failureThreshold":20,"httpGet":{"path":"/health","port":8000},"initialDelaySeconds":20,"periodSeconds":10}` | [Readiness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) configuration for the `guardrails` container. Liveness and readiness probes are suppressed until the startup probe succeeds. |
| tenancyMode | string | `"MULTI"` | tenancyMode for the guardrails service. Must be `SINGLE` or `MULTI`. |
| tenancyMode | string | `"SINGLE"` | tenancyMode for the guardrails service. Must be `SINGLE` or `MULTI`. |
| tolerations | list | `[]` | Node taints which will be tolerated for `Pod` [scheduling](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/). |

----------------------------------------------
Expand Down
24 changes: 24 additions & 0 deletions charts/guardrails/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.commonLabels }}
{{ toYaml . }}
{{- end }}
{{ include "guardrails.selectorLabels" . }}
{{- end }}

{{/*
Cache labels
*/}}
{{- define "guardrails.cacheLabels" -}}
helm.sh/chart: {{ include "guardrails.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.commonLabels }}
{{ toYaml . }}
{{- end }}
{{ include "guardrails.cacheSelectorLabels" . }}
{{- end }}

{{/*
Expand All @@ -52,6 +68,14 @@ app.kubernetes.io/name: {{ include "guardrails.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Cache Selector labels
*/}}
{{- define "guardrails.cacheSelectorLabels" -}}
app.kubernetes.io/name: {{ include "guardrails.name" . }}-nginx
app.kubernetes.io/instance: {{ .Release.Name }}-nginx
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down
9 changes: 3 additions & 6 deletions charts/guardrails/templates/deployment-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ kind: Deployment
metadata:
name: {{ .Release.Name }}-nginx
labels:
{{- include "guardrails.labels" . | nindent 4 }}
{{- include "guardrails.cacheLabels" . | nindent 4 }}
spec:
replicas: {{ .Values.cache.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-nginx
{{- include "guardrails.cacheSelectorLabels" . | nindent 8 }}
template:
metadata:
{{- with .Values.cache.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "guardrails.labels" . | nindent 8 }}
app: {{ .Release.Name }}-nginx
app.kubernetes.io/name: {{ include "guardrails.name" . }}-nginx
app.kubernetes.io/instance: {{ .Release.Name }}-nginx
{{- include "guardrails.cacheLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "guardrails.serviceAccountName" . }}
securityContext:
Expand Down
7 changes: 2 additions & 5 deletions charts/guardrails/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
{{- end }}
selector:
matchLabels:
app: {{ .Release.Name }}
{{- include "guardrails.selectorLabels" . | nindent 8 }}
template:
metadata:
{{- with .Values.podAnnotations }}
Expand All @@ -23,9 +23,6 @@ spec:
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
app: {{ .Release.Name }}
app.kubernetes.io/name: {{ include "guardrails.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- if gt (len .Values.imagePullSecrets) 0 }}
imagePullSecrets:
Expand All @@ -50,7 +47,7 @@ spec:
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ tpl $value $ }}
value: {{ tpl $value $ | quote }}
{{- end }}
{{- end }}
{{- if .Values.envFrom }}
Expand Down
2 changes: 1 addition & 1 deletion charts/guardrails/templates/service-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ spec:
port: 80
targetPort: 8080
selector:
app: {{ .Release.Name }}-nginx
{{- include "guardrails.cacheSelectorLabels" . | nindent 4 }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/guardrails/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ spec:
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
selector:
app: {{ .Release.Name }}
{{- include "guardrails.selectorLabels" . | nindent 4 }}
7 changes: 3 additions & 4 deletions charts/guardrails/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ commonLabels: {}
# for the `guardrails` container. **Supports Helm templating syntax**, e.g. you can use `{{ .Release.Name }}` or other
# templating variables, functions, and conditions within the the value of each environment variable.
env:
# Uncomment WHYLABS_API_CACHE_ENDPOINT if .Values.cache.enable is true
# WHYLABS_API_CACHE_ENDPOINT: "{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local"
# @ignored
WHYLABS_API_CACHE_ENDPOINT: "{{ if .Values.cache.enable }}{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local{{ else }}{{ end }}"
TENANCY_MODE: "{{ .Values.tenancyMode | default \"SINGLE\" }}"
CONFIG_SYNC_INTERVAL: "1"

# -- Create environment variables from Kubernetes secrets or config maps.
envFrom:
Expand Down Expand Up @@ -229,7 +228,7 @@ startupProbe:
periodSeconds: 10

# -- (string) tenancyMode for the guardrails service. Must be `SINGLE` or `MULTI`.
tenancyMode: MULTI
tenancyMode: SINGLE

# -- Node taints which will be tolerated for `Pod`
# [scheduling](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/).
Expand Down
Loading