Skip to content

Commit

Permalink
Merge pull request #28 from whylabs/dev/aberg/guard-update-#86b0cym95
Browse files Browse the repository at this point in the history
Update resources, app version, and docs
  • Loading branch information
AnchorArray authored May 14, 2024
2 parents e4d8209 + da46e2e commit 1c9e7ce
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 26 deletions.
50 changes: 42 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,43 @@ jobs:
with:
version: v3.14.0

# - name: YAML Lint
# if: github.event_name == 'pull_request'
# uses: actionshub/yaml-lint@v1
# with:
# directory: .

# - name: Helm Lint
# if: github.event_name == 'pull_request'
# working-directory: ${{ github.workspace }}/charts
# run: |
# for dir in */ ; do
# if [ -f "$dir/Chart.yaml" ]; then
# helm lint "$dir"
# fi
# done
# shell: bash

# - name: Markdown Lint
# if: github.event_name == 'pull_request'
# uses: github/super-linter@v4
# env:
# DEFAULT_BRANCH: mainline
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# VALIDATE_MARKDOWN: true

- name: Update Chart Version for PRs
if: github.event_name == 'pull_request'
working-directory: ${{ github.workspace }}/charts
run: |
for dir in */ ; do
if [ -f "$dir/Chart.yaml" ]; then
yq eval '.version += "-dev"' -i "$dir/Chart.yaml"
fi
done
shell: bash

- name: Package All Helm Charts
if: github.event_name == 'push'
working-directory: ${{ github.workspace }}/charts
run: |
for dir in */ ; do
Expand All @@ -36,21 +71,20 @@ jobs:
shell: bash

- name: Login to GHCR
if: github.event_name == 'push'
run: |
docker login ghcr.io \
-u ${{ github.repository_owner }} \
--password-stdin < <(echo "${{ secrets.GITHUB_TOKEN }}")
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Publish Helm Charts to GHCR
if: github.event_name == 'push'
working-directory: ${{ github.workspace }}/charts
run: |
for chart in *.tgz ; do
chart_name=$(basename "$chart" .tgz)
chart_version=$(echo "$chart_name" | sed 's/.*-//')
if [ "${{ github.event_name }}" == "pull_request" ]; then
chart_version="${chart_version}-dev"
fi
ghcr_chart="ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/${chart_name}:${chart_version}"
helm push "$chart" oci://ghcr.io/${{ github.repository_owner }}
helm push "$chart" "oci://ghcr.io/${{ github.repository_owner }}"
done
shell: bash

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.vscode
.ruby-version
30 changes: 29 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
repos:
- repo: https://github.com/norwoodj/helm-docs
rev: v1.2.0
rev: v1.13.1
hooks:
- id: helm-docs
args:
- --chart-search-root=charts

# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v4.6.0
# hooks:
# - id: trailing-whitespace
# - id: end-of-file-fixer
# - id: check-yaml
# - id: check-json

# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v4.6.0
# hooks:
# - id: check-yaml
# files: \.(yml|yaml)$

# - repo: https://github.com/markdownlint/markdownlint
# rev: v0.12.0
# hooks:
# - id: markdownlint

# - repo: local
# hooks:
# - id: helm-lint
# name: Helm Lint
# entry: helm lint
# language: system
# files: ^charts/
# types: [file]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,16 @@ helm uninstall \
--namespace "${namespace}" \
"${release}"
```

## Development

### Pre-Commit

#### Troubleshooting

Try executing `pre-commit` manually if it fails on commit:

```shell
git add .
pre-commit run --all-files
```
6 changes: 6 additions & 0 deletions charts/guardrails/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ 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.2.0] - 2024-05-14

### Updated

- Default image tag from `1.0.19` to `1.0.20-dev2`

## [0.1.0] - 2024-05-08

### Added
Expand Down
4 changes: 2 additions & 2 deletions charts/guardrails/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: guardrails
description: A Helm chart for WhyLabs Guardrails
type: application
version: 0.1.0
appVersion: "1.0.19"
version: 0.2.0
appVersion: "1.0.20-dev2"
44 changes: 37 additions & 7 deletions charts/guardrails/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# guardrails

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.19](https://img.shields.io/badge/AppVersion-1.0.19-informational?style=flat-square)
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.20-dev2](https://img.shields.io/badge/AppVersion-1.0.20--dev2-informational?style=flat-square)

A Helm chart for WhyLabs Guardrails

Expand All @@ -10,14 +10,14 @@ A Helm chart for WhyLabs Guardrails
# Downloads a .tgz file to the working directory or --destination path
helm pull \
oci://ghcr.io/whylabs/guardrails \
--version 0.1.0
--version 0.2.0

helm diff upgrade \
--allow-unreleased \
--namespace <target-namespace> \
`# Specify the .tgz file as the chart` \
guardrails
guardrails-0.1.0.tgz
guardrails-0.2.0.tgz
```

After you've installed the repo you can install the chart.
Expand All @@ -27,15 +27,45 @@ helm upgrade --install \
--create-namespace \
--namespace <target-namespace> \
guardrails
guardrails-0.1.0.tgz
guardrails-0.2.0.tgz
```

## Horizontal Pod Autoscaling (HPA)

The Horizontal Pod Autoscaler automatically scales the number of pods in a
replication controller, deployment, replica set or stateful set based on
observed CPU utilization (or, with custom metrics support, on some other
application-provided metrics). The Horizontal Pod Autoscaler uses the following
formula to calculate the desired number of pods:

```text
Desired Replicas = [ (Current Utilization / Target Utilization) * Current Replicas ]
```

For example, if an HPA is configured with a target CPU utilization of 50%, there
are currently 3 pods, and the current average CPU utilization is 90%, the number
of replicas will be scaled to 6:

```text
Desired Replicas = ⌈ (90% / 50%) * 3 ⌉
= ⌈ 1.8 * 3 ⌉
= ⌈ 5.4 ⌉
= 6
```

HPA uses the same formula for both increasing and decreasing the number of pods.
Horizontal pod scaling is disabled by default. To enable it, set the
`hpa.enabled` key to `true`. The pods QoS class will impact HPA behavior as a
deployment that is allowed to burst CPU usage will cause more aggressive HPA
scaling than a deployment with a `Guaranteed` QoS that does not go above 100%
utilization.

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity settings for `Pod` [scheduling](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/). If an explicit label selector is not provided for pod affinity or pod anti-affinity one will be created from the pod selector labels. |
| autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80}` | [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) configuration for the `guardrails` container. |
| autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":70}` | [Horizontal Pod Autoscaler](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) configuration for the `guardrails` container. |
| 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. |
| extraVolumeMounts | list | `[]` | Extra [volume mounts](https://kubernetes.io/docs/concepts/storage/volumes/) for the `guardrails` container. |
Expand All @@ -53,8 +83,8 @@ helm upgrade --install \
| podLabels | object | `{}` | Labels to add to the `Pod`. |
| podSecurityContext | object | `{"runAsNonRoot":true}` | [Pod security context](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#podsecuritycontext-v1-core), this supports full customisation. |
| readinessProbe | object | `{"failureThreshold":10,"httpGet":{"path":"/health","port":8000},"initialDelaySeconds":30,"periodSeconds":30}` | [Readiness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) configuration for the `guardrails` container. |
| replicaCount | int | `2` | Number of replicas for the service. |
| resources | object | `{"limits":{"cpu":"4","memory":"6Gi"},"requests":{"cpu":"4","memory":"6Gi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for the `guardrails` container. |
| replicaCount | int | `4` | Number of replicas for the service. |
| resources | object | `{"limits":{"cpu":"4","ephemeral-storage":"250Mi","memory":"4Gi"},"requests":{"cpu":"4","ephemeral-storage":"250Mi","memory":"4Gi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for the `guardrails` container. |
| securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"privileged":false,"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":1000}` | [Security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) for the `guardrails` container. |
| service.annotations | object | `{}` | Service annotations. |
| service.port | int | `80` | Service HTTP port. |
Expand Down
30 changes: 30 additions & 0 deletions charts/guardrails/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ helm upgrade --install \
{{ template "chart.name" . }}-{{ template "chart.version" . }}.tgz
```

## Horizontal Pod Autoscaling (HPA)

The Horizontal Pod Autoscaler automatically scales the number of pods in a
replication controller, deployment, replica set or stateful set based on
observed CPU utilization (or, with custom metrics support, on some other
application-provided metrics). The Horizontal Pod Autoscaler uses the following
formula to calculate the desired number of pods:

```text
Desired Replicas = [ (Current Utilization / Target Utilization) * Current Replicas ]
```

For example, if an HPA is configured with a target CPU utilization of 50%, there
are currently 3 pods, and the current average CPU utilization is 90%, the number
of replicas will be scaled to 6:

```text
Desired Replicas = ⌈ (90% / 50%) * 3 ⌉
= ⌈ 1.8 * 3 ⌉
= ⌈ 5.4 ⌉
= 6
```

HPA uses the same formula for both increasing and decreasing the number of pods.
Horizontal pod scaling is disabled by default. To enable it, set the
`hpa.enabled` key to `true`. The pods QoS class will impact HPA behavior as a
deployment that is allowed to burst CPU usage will cause more aggressive HPA
scaling than a deployment with a `Guaranteed` QoS that does not go above 100%
utilization.

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
Expand Down
1 change: 1 addition & 0 deletions charts/guardrails/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
{{- include "guardrails.labels" . | nindent 4 }}
spec:
revisionHistoryLimit: 1
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
Expand Down
12 changes: 7 additions & 5 deletions charts/guardrails/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -- Number of replicas for the service.
replicaCount: 2
replicaCount: 4

image:
# -- Image repository for the `guardrails` container.
Expand Down Expand Up @@ -89,10 +89,12 @@ ingress:
resources:
requests:
cpu: "4"
memory: 6Gi
memory: 4Gi
ephemeral-storage: 250Mi
limits:
cpu: "4"
memory: 6Gi
memory: 4Gi
ephemeral-storage: 250Mi

# -- [Liveness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) configuration for the `guardrails` container.
livenessProbe:
Expand All @@ -117,8 +119,8 @@ autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
targetCPUUtilizationPercentage: 70
# targetMemoryUtilizationPercentage: 70

# -- Extra [volumes](https://kubernetes.io/docs/concepts/storage/volumes/) for the `Pod`.
extraVolumes: []
Expand Down
6 changes: 3 additions & 3 deletions charts/langkit/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# **:exclamation: This Helm Chart is deprecated! Please use the [GuardRails Chart](https://github.com/whylabs/charts/tree/mainline/charts/guardrails) instead**

# langkit

> **:exclamation: This Helm Chart is deprecated!**
![Version: 0.16.0](https://img.shields.io/badge/Version-0.16.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.13](https://img.shields.io/badge/AppVersion-1.0.13-informational?style=flat-square)

A Helm chart for LangKit container deployment
Expand Down Expand Up @@ -141,4 +141,4 @@ helm uninstall \

----------------------------------------------

Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/).
Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/).

0 comments on commit 1c9e7ce

Please sign in to comment.