This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kubernetes Staging Environment (#242)
- Loading branch information
Showing
25 changed files
with
554 additions
and
40 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
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,59 @@ | ||
# Deployment | ||
|
||
Material related to deploying Busy Beaver. | ||
|
||
## Current Deployment Workflow | ||
|
||
Busy Beaver has been packaged up as a Helm chart. | ||
|
||
### Prerequestites | ||
|
||
- Install Helm | ||
- Use Helm to set up `nginx`, `cert-manager`, `redis`, fluent-bit | ||
- Add `busybeaver-staging` Secret to cluster | ||
|
||
### Installing Busy Beaver | ||
|
||
```console | ||
helm install busybeaver-staging ./busybeaver/ | ||
helm upgrade busybeaver-staging ./busybeaver/ | ||
``` | ||
|
||
### Secrets Format | ||
|
||
All data values need to be `base64` encoded. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: busybeaver-staging | ||
type: Opaque | ||
data: | ||
db-uri: | ||
cache-uri: | ||
sentry-dsn: | ||
secret-key: | ||
slack-client-id: | ||
slack-client-secret: | ||
slack-botuser-oauth-token: | ||
slack-signing-secret: | ||
meetup-api-key: | ||
github-client-id: | ||
github-client-secret: | ||
github-oauth-token: | ||
github-signing-secret: | ||
twitter-access-token-secret: | ||
twitter-access-token: | ||
twitter-consumer-key: | ||
twitter-consumer-secret: | ||
``` | ||
### Notes | ||
- if staging database gets deleted and we have to start again | ||
- will need to set up app for distribution and install it via OAuth | ||
- TODO (need to clean this up) | ||
- [ ] what accounts did we need to create? | ||
- [ ] what are those accounts? | ||
- [ ] where do we store credentials? |
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 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
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 @@ | ||
apiVersion: v2 | ||
name: busybeaver | ||
description: Community engagement Slackbot | ||
home: https://github.com/busy-beaver-dev/busy-beaver | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
version: 0.0.2 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. | ||
appVersion: 1.3.3 | ||
|
||
keywords: | ||
- community-engagement | ||
- slackbot | ||
|
||
maintainers: | ||
- name: Aly Sivji | ||
email: [email protected] | ||
url: https://alysivji.github.io |
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,8 @@ | ||
Thank you for installing {{ .Chart.Name }}. | ||
|
||
Your release is named {{ .Release.Name }}. | ||
|
||
To learn more about the release, try: | ||
|
||
$ helm status {{ .Release.Name }} | ||
$ helm get all {{ .Release.Name }} |
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,151 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "busybeaver.name" -}} | ||
{{- default .Chart.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "busybeaver.fullname" -}} | ||
{{- $name := default .Chart.Name -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "busybeaver.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "busybeaver.labels" -}} | ||
{{ include "busybeaver.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
helm.sh/chart: {{ include "busybeaver.chart" . }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "busybeaver.selectorLabels" -}} | ||
app: webapp | ||
environment: {{ .Values.environment }} | ||
app.kubernetes.io/name: {{ include "busybeaver.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end -}} | ||
|
||
{{/* | ||
Environment Variables | ||
*/}} | ||
{{- define "busybeaver.env_vars" }} | ||
- name: PYTHONPATH | ||
value: . | ||
- name: FLASK_APP | ||
value: /app/busy_beaver/__init__.py | ||
- name: SENTRY_DSN | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: sentry-dsn | ||
# infrastructure | ||
- name: DATABASE_URI | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: db-uri | ||
- name: REDIS_URI | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: cache-uri | ||
# integrations | ||
# oauth lib | ||
- name: OAUTHLIB_INSECURE_TRANSPORT | ||
value: "1" | ||
- name: OAUTHLIB_RELAX_TOKEN_SCOPE | ||
value: "1" | ||
# slack | ||
- name: SLACK_CLIENT_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: slack-client-id | ||
- name: SLACK_CLIENT_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: slack-client-secret | ||
- name: SLACK_BOTUSER_OAUTH_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: slack-botuser-oauth-token | ||
- name: SLACK_SIGNING_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: slack-signing-secret | ||
# meetup | ||
- name: MEETUP_API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: meetup-api-key | ||
# github | ||
- name: GITHUB_APP_CLIENT_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: github-client-id | ||
- name: GITHUB_APP_CLIENT_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: github-client-secret | ||
- name: GITHUB_OAUTH_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: github-oauth-token | ||
- name: GITHUB_SIGNING_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: github-signing-secret | ||
- name: TWITTER_ACCESS_TOKEN_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: twitter-access-token-secret | ||
- name: TWITTER_ACCESS_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: twitter-access-token | ||
- name: TWITTER_CONSUMER_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: twitter-consumer-key | ||
- name: TWITTER_CONSUMER_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.secretName }} | ||
key: twitter-consumer-secret | ||
{{- end }} |
26 changes: 26 additions & 0 deletions
26
deployment/busybeaver/templates/cronjob--poll-twitter.yaml
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,26 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: "{{ include "busybeaver.fullname" . }}--cron--poll-twitter" | ||
labels: | ||
type: poll-twitter | ||
{{- include "busybeaver.labels" . | nindent 4 }} | ||
spec: | ||
schedule: "*/13 * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: busybeaver--poll-twitter | ||
image: {{ .Values.image.repository }}:{{ .Values.image.version }} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
command: ["flask"] | ||
args: | ||
- "poll_twitter" | ||
- "--workspace" | ||
- {{ .Values.workspaceId | quote }} | ||
- "--channel_name" | ||
- "at-chicagopython" | ||
env: {{- include "busybeaver.env_vars" . | indent 12 }} |
Oops, something went wrong.