From 28b567f298c419c23e8b8fa3c9b2b7959f882e89 Mon Sep 17 00:00:00 2001 From: Brent George Date: Thu, 30 May 2024 12:35:01 -0500 Subject: [PATCH] init commit --- CODE_OF_CONDUCT.md | 127 ++++++++++++++++++ CONTRIBUTING.md | 13 ++ LICENSE | 14 ++ README.md | 90 +++++++++++++ SECURITY.md | 1 + .../templates/tester.yaml | 22 +++ .../deepgram-self-hosted-starter/values.yaml | 1 + apptest/deployer/schema.yaml | 6 + apptest/tester/Dockerfile | 13 ++ apptest/tester/tester.sh | 8 ++ apptest/tester/tests/common/web-server.yaml | 9 ++ chart/deepgram-self-hosted-starter/Chart.yaml | 12 ++ .../templates/application.yaml | 30 +++++ .../templates/deployment.yaml | 28 ++++ .../templates/service.yaml | 14 ++ .../deepgram-self-hosted-starter/values.yaml | 4 + deployer/Dockerfile | 33 +++++ schema.yaml | 43 ++++++ 18 files changed, 468 insertions(+) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 apptest/deployer/deepgram-self-hosted-starter/templates/tester.yaml create mode 100644 apptest/deployer/deepgram-self-hosted-starter/values.yaml create mode 100644 apptest/deployer/schema.yaml create mode 100644 apptest/tester/Dockerfile create mode 100755 apptest/tester/tester.sh create mode 100644 apptest/tester/tests/common/web-server.yaml create mode 100644 chart/deepgram-self-hosted-starter/Chart.yaml create mode 100644 chart/deepgram-self-hosted-starter/templates/application.yaml create mode 100644 chart/deepgram-self-hosted-starter/templates/deployment.yaml create mode 100644 chart/deepgram-self-hosted-starter/templates/service.yaml create mode 100644 chart/deepgram-self-hosted-starter/values.yaml create mode 100644 deployer/Dockerfile create mode 100644 schema.yaml diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..c4661d7 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,127 @@ +# Contributor Covenant Code of Conduct +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +devrel@deepgram.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f5ea568 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,13 @@ + +# Contributing Guidelines + +Before submitting contributions to this repository, please reach out to [Deepgram Support](https://deepgram.com/contact-us/) for more details on self-hosting Deepgram. + +## How To + +1. Fork this repository on GitHub. +1. Clone/fetch your fork to your local development machine. +1. Create a new branch (e.g. `issue-12`, `feat.add_foo`, etc) and check it out. +1. Make your changes and commit them. (Did the tests pass? No linting errors?) +1. Push your new branch to your fork. (e.g. `git push myname issue-12`) +1. Open a Pull Request from your new branch to the original fork's `main` branch. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2bccc66 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ +ISC License + +Copyright 2024 Deepgram, Inc. + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee +is hereby granted, provided that the above copyright notice and this permission notice appear in all +copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c4939a0 --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +# Deepgram Self-Hosted Google Cloud Platform Starter + +## Overview + +The Deepgram Self-Hosted Google Cloud Platform Starter is a Helm chart for running a starter Deepgram application in a self-hosted environment. It provides a simple way to get started with Deepgram's speech recognition capabilities in your own infrastructure. + +Key features: +- Starter web application to be introduced to Deepgram's API +- Deployment via Helm chart +- Customizable via Helm chart values + +To learn more about deploying Deepgram in a self-hosted environment within GCP, please contact [Deepgram Support](https://deepgram.com/contact-us/). + +## One-time Setup + +1. Install [kubectl](https://kubernetes.io/docs/tasks/tools/) and [Helm](https://helm.sh/docs/intro/install/) on the machine where you will deploy the application. + +2. Install the Application CRD so your cluster can manage the Application resource: + +```bash +kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/marketplace-k8s-app-tools/master/crd/app-crd.yaml +``` + +## Installation + +Set environment variables for your app name and namespace: + +```bash +export APP_INSTANCE_NAME=deepgram-starter-1 +export NAMESPACE=default +``` + +Retrieve the Deepgram Self-Hosted Starter image references: + +```bash +export IMAGE_REPO=gcr.io/deepgram-public/deepgram-self-hosted-starter +export IMAGE_TAG=1.0.0 +``` + +Install the app with Helm: + +```bash +helm upgrade --install ${APP_INSTANCE_NAME} deepgram/deepgram-self-hosted-starter \ + --namespace ${NAMESPACE} \ + --set deepgramSelfHostedStarter.image.repo=${IMAGE_REPO} \ + --set deepgramSelfHostedStarter.image.tag=${IMAGE_TAG} +``` + +## Basic Usage + +The starter application exposes a web UI. Get the external IP of the service: + +```bash +kubectl get service ${APP_INSTANCE_NAME}-starter-svc \ + --namespace ${NAMESPACE} \ + --output jsonpath='{.status.loadBalancer.ingress[0].ip}' +``` + +Open the URL `http://` in a web browser with access to the cluster network to access the starter application. + +## Backup and Restore + +The Deepgram Self-Hosted Starter does not persist any data. Backup and restore procedures are not applicable. + +## Image Updates + +To update the application with a new image version, set the new tag: + +```bash +export NEW_IMAGE_TAG=2.0.0 +``` + +Update the Deployment with the new image: + +```bash +helm upgrade ${APP_INSTANCE_NAME} deepgram/deepgram-self-hosted-starter \ + --namespace ${NAMESPACE} \ + --set deepgramSelfHostedStarter.image.repo=${IMAGE_REPO} \ + --set deepgramSelfHostedStarter.image.tag=${NEW_IMAGE_TAG} +``` + +## Deletion + +To delete the Deepgram Self-Hosted Starter application: + +```bash +helm uninstall ${APP_INSTANCE_NAME} --namespace ${NAMESPACE} +``` + +This will remove all resources associated with the application. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..1729fa3 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1 @@ +Please refer to [Deepgram's security policy](https://developers.deepgram.com/docs/security-policy). diff --git a/apptest/deployer/deepgram-self-hosted-starter/templates/tester.yaml b/apptest/deployer/deepgram-self-hosted-starter/templates/tester.yaml new file mode 100644 index 0000000..b74d5a2 --- /dev/null +++ b/apptest/deployer/deepgram-self-hosted-starter/templates/tester.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ .Release.Name }}-tester" + labels: + app.kubernetes.io/name: "{{ .Release.Name }}" + annotations: + marketplace.cloud.google.com/verification: test +spec: + serviceAccountName: {{ .Release.Name }}-deployer-sa + containers: + - name: tester + image: "{{ .Values.testerImage }}" + imagePullPolicy: Always + env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: APP_INSTANCE_NAME + value: {{ .Release.Name }} + restartPolicy: Never diff --git a/apptest/deployer/deepgram-self-hosted-starter/values.yaml b/apptest/deployer/deepgram-self-hosted-starter/values.yaml new file mode 100644 index 0000000..b8b26eb --- /dev/null +++ b/apptest/deployer/deepgram-self-hosted-starter/values.yaml @@ -0,0 +1 @@ +testerImage: null diff --git a/apptest/deployer/schema.yaml b/apptest/deployer/schema.yaml new file mode 100644 index 0000000..85f0326 --- /dev/null +++ b/apptest/deployer/schema.yaml @@ -0,0 +1,6 @@ +properties: + testerImage: + type: string + default: gcr.io/deepgram-public/deepgram-self-hosted-starter/deployer/tester:1.0.0 + x-google-property: + type: IMAGE diff --git a/apptest/tester/Dockerfile b/apptest/tester/Dockerfile new file mode 100644 index 0000000..13678aa --- /dev/null +++ b/apptest/tester/Dockerfile @@ -0,0 +1,13 @@ +FROM gcr.io/cloud-marketplace-tools/testrunner:0.1.5 + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + curl + +COPY tests /tests +COPY tester.sh /tester.sh + +WORKDIR / +ENTRYPOINT ["/tester.sh"] diff --git a/apptest/tester/tester.sh b/apptest/tester/tester.sh new file mode 100755 index 0000000..6d3bc19 --- /dev/null +++ b/apptest/tester/tester.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -xeo pipefail +shopt -s nullglob + +for test in /tests/common/*; do + testrunner -logtostderr "--test_spec=${test}" +done diff --git a/apptest/tester/tests/common/web-server.yaml b/apptest/tester/tests/common/web-server.yaml new file mode 100644 index 0000000..3f453c5 --- /dev/null +++ b/apptest/tester/tests/common/web-server.yaml @@ -0,0 +1,9 @@ +actions: + - name: Starter application is serving content + bashTest: + script: curl -f "http://${APP_INSTANCE_NAME}-starter-svc.${NAMESPACE}.svc.cluster.local" + expect: + stdout: + contains: Deepgram + exitCode: + equals: 0 diff --git a/chart/deepgram-self-hosted-starter/Chart.yaml b/chart/deepgram-self-hosted-starter/Chart.yaml new file mode 100644 index 0000000..9fbc35b --- /dev/null +++ b/chart/deepgram-self-hosted-starter/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: deepgram-self-hosted-starter +type: application +version: 1.0.0 +appVersion: 1.0.0 +description: A Helm chart for running a starter Deepgram application in a self-hosted environment +sources: ["https://github.com/deepgram/gcp-marketplace-listing"] +kubeVersion: ">=1.27.0-0" +maintainers: + - name: Deepgram Self-Hosted + email: self.hosted@deepgram.com +icon: "https://www.dropbox.com/scl/fi/v4jtfbsrx881pbevcga3j/D-icon-black-square-250x250.png?rlkey=barv5jeuhd7t2lczz0m3nane7&dl=1" diff --git a/chart/deepgram-self-hosted-starter/templates/application.yaml b/chart/deepgram-self-hosted-starter/templates/application.yaml new file mode 100644 index 0000000..3d0c37e --- /dev/null +++ b/chart/deepgram-self-hosted-starter/templates/application.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: app.k8s.io/v1beta1 +kind: Application +metadata: + name: "{{ .Release.Name }}" + namespace: "{{ .Release.Namespace }}" + annotations: + marketplace.cloud.google.com/deploy-info: '{"partner_id": "deepgram-public", "product_id": "deepgram-self-hosted-starter", "partner_name": "Deepgram"}' + labels: + app.kubernetes.io/name: "{{ .Release.Name }}" +spec: + descriptor: + type: DeepgramSelfHostedStarter + version: "{{ .Values.deepgramSelfHostedStarter.image.tag }}" + description: >- + A Helm chart for running a starter Deepgram application in a self-hosted environment. + maintainers: + - name: Deepgram Self-Hosted + email: self.hosted@deepgram.com + links: + - description: Deepgram Developer Documentation + url: https://developers.deepgram.com + selector: + matchLabels: + app.kubernetes.io/name: "{{ .Release.Name }}" + componentKinds: + - group: apps + kind: Deployment + - group: core + kind: Service diff --git a/chart/deepgram-self-hosted-starter/templates/deployment.yaml b/chart/deepgram-self-hosted-starter/templates/deployment.yaml new file mode 100644 index 0000000..ac3d05e --- /dev/null +++ b/chart/deepgram-self-hosted-starter/templates/deployment.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-starter-app + labels: &DeploymentLabels + name: "{{ .Release.Name }}" + app: deepgram-self-hosted-starter +spec: + replicas: 1 + selector: + matchLabels: + app: deepgram-self-hosted-starter + template: + metadata: + labels: *DeploymentLabels + spec: + containers: + - name: {{ .Release.Name }}-starter-app + image: "{{ .Values.deepgramSelfHostedStarter.image.repo }}:{{ .Values.deepgramSelfHostedStarter.image.tag }}" + ports: + - name: http + containerPort: 80 + livenessProbe: + tcpSocket: + port: 80 + readinessProbe: + tcpSocket: + port: 80 diff --git a/chart/deepgram-self-hosted-starter/templates/service.yaml b/chart/deepgram-self-hosted-starter/templates/service.yaml new file mode 100644 index 0000000..34cbfe5 --- /dev/null +++ b/chart/deepgram-self-hosted-starter/templates/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-starter-svc + labels: &ServiceLabels + name: "{{ .Release.Name }}" +spec: + selector: + app: deepgram-self-hosted-starter + ports: + - name: "primary" + port: 80 + targetPort: 80 + diff --git a/chart/deepgram-self-hosted-starter/values.yaml b/chart/deepgram-self-hosted-starter/values.yaml new file mode 100644 index 0000000..cc2e18f --- /dev/null +++ b/chart/deepgram-self-hosted-starter/values.yaml @@ -0,0 +1,4 @@ +deepgramSelfHostedStarter: + image: + repo: null + tag: null diff --git a/deployer/Dockerfile b/deployer/Dockerfile new file mode 100644 index 0000000..7e0c265 --- /dev/null +++ b/deployer/Dockerfile @@ -0,0 +1,33 @@ +FROM marketplace.gcr.io/google/c2d-debian11 AS build + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends gettext + +ADD chart/deepgram-self-hosted-starter /tmp/chart +RUN cd /tmp && tar -czvf /tmp/deepgram-self-hosted-starter.tar.gz chart + +ADD apptest/deployer/deepgram-self-hosted-starter /tmp/test/chart +RUN cd /tmp/test \ + && tar -czvf /tmp/test/deepgram-self-hosted-starter.tar.gz chart/ + +ADD schema.yaml /tmp/schema.yaml + +ARG REGISTRY +ARG TAG + +RUN cat /tmp/schema.yaml > /tmp/schema.yaml.new \ + && mv /tmp/schema.yaml.new /tmp/schema.yaml + +ADD apptest/deployer/schema.yaml /tmp/apptest/schema.yaml +RUN cat /tmp/apptest/schema.yaml > /tmp/apptest/schema.yaml.new \ + && mv /tmp/apptest/schema.yaml.new /tmp/apptest/schema.yaml + +FROM gcr.io/cloud-marketplace-tools/k8s/deployer_helm:latest +COPY --from=build /tmp/deepgram-self-hosted-starter.tar.gz /data/chart/ +COPY --from=build /tmp/test/deepgram-self-hosted-starter.tar.gz /data-test/chart/ +COPY --from=build /tmp/apptest/schema.yaml /data-test/ +COPY --from=build /tmp/schema.yaml /data/ + +ENV WAIT_FOR_READY_TIMEOUT 300 +ENV TESTER_TIMEOUT 60 diff --git a/schema.yaml b/schema.yaml new file mode 100644 index 0000000..84dfd5d --- /dev/null +++ b/schema.yaml @@ -0,0 +1,43 @@ +x-google-marketplace: + schemaVersion: v2 + + applicationApiVersion: v1beta1 + + publishedVersion: 1.0.0 + publishedVersionMetadata: + releaseNote: >- + A regular update. + releaseTypes: + - Feature + recommended: false + + clusterConstraints: + resources: + - replicas: 1 + requests: + cpu: 100m + memory: 100Mi + + images: + "": + properties: + deepgramSelfHostedStarter.image.repo: + type: REPO_WITH_REGISTRY + default: gcr.io/deepgram-public/deepgram-self-hosted-starter + deepgramSelfHostedStarter.image.tag: + type: TAG + default: 1.0.0 + +properties: + name: + type: string + x-google-marketplace: + type: NAME + namespace: + type: string + x-google-marketplace: + type: NAMESPACE + +required: + - name + - namespace