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

minikube helm chart #28

Merged
merged 11 commits into from
Oct 24, 2023
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
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ queries against Wikipedia and sister projects databases.

## Setting up a local dev environment ##

# docker-compose
Quarry uses [Docker](https://docs.docker.com/engine/install/) to set up a local
environment. You can set it up by:

Expand All @@ -18,19 +19,43 @@ will imediatelly be taken into account.
A worker node is also created to execute your queries in the background (uses the
same image). Finally, redis and two database instances are also started.

One database is your quarry database the other is a wikireplica-like database
named `mywiki`. This (or `mywiki_p`) is the correct thing to enter in the
database field on all local test queries.

In your local environment, you can query Quarry internal db itself. Use then
"quarry" as database name.

To stop, run `docker-compose stop` or hit CTRL-C on the terminal your docker-compose
is running in. After that, to start with code changes, you'll want to `docker-compose down`
to clean up. Also, this creates a docker volume where sqlite versions of query
results are found. That will not be cleaned up unless you run `docker-compose down -v`



# minikube
It is possible to run a quarry system inside [minikube](https://minikube.sigs.k8s.io/docs/)!
At this time, you need to set it up with a cluster version before 1.22, most likely.

First build the containers:
```
eval $(minikube docker-env)
docker build . -t quarry:01
cd docker-replica/
docker build . -t mywiki:01
```

You will need to install minikube (tested on minikube 1.23) and [helm](https://helm.sh) and kubectl on your system. When you are confident those are working, start minikube with:
- `minikube start --kubernetes-version=v1.23.15`
- `minikube addons enable ingress`
- `kubectl create namespace quarry`
- `helm -n quarry install quarry helm-quarry -f helm-quarry/dev-env.yaml`

The rest of the setup instructions will display on screen as long as the install is successful.

# local databases
Both local setups will create two databases.

One database is your quarry database the other is a wikireplica-like database
named `mywiki`. This (or `mywiki_p`) is the correct thing to enter in the
database field on all local test queries.

The other database is the Quarry internal db. In your local environment, you can query Quarry internal db itself. Use then
"quarry" as database name.

### Updating existing containers ###

If you had already run a dev environment (that is, ran `docker-compose up`) you might want to update
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
- "redis"

redis:
image: redis:alpine
image: redis:alpine3.18

# wikireplica simulator
mywiki:
Expand Down
3 changes: 3 additions & 0 deletions docker-replica/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mariadb:10.4-focal

COPY replica.sql /docker-entrypoint-initdb.d/replica.sql
23 changes: 23 additions & 0 deletions helm-quarry/.helmignore
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/
4 changes: 4 additions & 0 deletions helm-quarry/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
description: A Helm chart for quarry
name: helm-quarry
version: "1.0"
10 changes: 10 additions & 0 deletions helm-quarry/dev-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
localdev:
enabled: true
web:
replicas: 1
memory: "300Mi"
cpu: "100m"
worker:
replicas: 1
memory: "400Mi"
cpu: "100m"
31 changes: 31 additions & 0 deletions helm-quarry/dev_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# The OAUTH tokens are callbacks to a quarry.local domain
# it is ok that they are public.
OAUTH_CONSUMER_TOKEN: "deeb8dbabbf157cb0ed120b89971d800"
OAUTH_SECRET_TOKEN: "38fdce038bbf848453a856aa329f8a06c456c791"
SECRET_KEY: 'aaarggghhpleaserescuemeiamstuckinarandomnumbergeneratorfactory'
DEBUG: True
DB_HOST: 'db'
DB_NAME: 'quarry'
DB_USER: 'quarry'
DB_PASSWORD: 'quarry'
broker_url: 'redis://redis'
result_backend: 'redis://redis'
worker_concurrency: 24 # Since all tasks are IO bound
task_acks_late: True # Tasks are idempotent!
task_track_started: True
worker_prefetch_multiplier: 1 # Tasks can run for a long time
# Just query the quarry database itself.
REPLICA_DOMAIN: ''
REPLICA_HOST: 'mywiki'
REPLICA_DB: 'mywiki_p'
REPLICA_USER: 'repl'
REPLICA_PASSWORD: 'repl'
REPLICA_PORT: 3306
OUTPUT_PATH_TEMPLATE: '/results/%s/%s/%s.sqlite'
REDIS_HOST: 'redis'
REDIS_PORT: 6379
REDIS_DB: 0
QUERY_TIME_LIMIT: 60 # 1 minute
QUERY_RESULTS_PER_PAGE: 50
KILLER_LOG_PATH: 'killer.log'
MAINTENANCE_MSG: 'This is your local development environment.'
11 changes: 11 additions & 0 deletions helm-quarry/prod-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
localdev:
enabled: false

web:
replicas: 8
memory: "300Mi"
cpu: "100m"
worker:
replicas: 2
memory: "700Mi"
cpu: "100m"
33 changes: 33 additions & 0 deletions helm-quarry/prod_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Replace these with prod values and encrypt

# The OAUTH tokens are callbacks to a quarry.local domain
# it is ok that they are public.
OAUTH_CONSUMER_TOKEN: "deeb8dbabbf157cb0ed120b89971d800"
OAUTH_SECRET_TOKEN: "38fdce038bbf848453a856aa329f8a06c456c791"
SECRET_KEY: 'aaarggghhpleaserescuemeiamstuckinarandomnumbergeneratorfactory'
DEBUG: True
DB_HOST: 'db'
DB_NAME: 'quarry'
DB_USER: 'quarry'
DB_PASSWORD: 'quarry'
broker_url: 'redis://redis'
result_backend: 'redis://redis'
worker_concurrency: 24 # Since all tasks are IO bound
task_acks_late: True # Tasks are idempotent!
task_track_started: True
worker_prefetch_multiplier: 1 # Tasks can run for a long time
# Just query the quarry database itself.
REPLICA_DOMAIN: ''
REPLICA_HOST: 'mywiki'
REPLICA_DB: 'mywiki_p'
REPLICA_USER: 'repl'
REPLICA_PASSWORD: 'repl'
REPLICA_PORT: 3306
OUTPUT_PATH_TEMPLATE: '/results/%s/%s/%s.sqlite'
REDIS_HOST: 'redis'
REDIS_PORT: 6379
REDIS_DB: 0
QUERY_TIME_LIMIT: 60 # 1 minute
QUERY_RESULTS_PER_PAGE: 50
KILLER_LOG_PATH: 'killer.log'
MAINTENANCE_MSG: 'This is your local development environment.'
1 change: 1 addition & 0 deletions helm-quarry/schema.sql
14 changes: 14 additions & 0 deletions helm-quarry/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Thank you for installing {{ .Chart.Name }}!

An essential part of setting up your dev environment is adding an entry to your /etc/hosts file.
Get the IP of minikube with:
minikube ip
Add this line to your /etc/hosts file:
<ip address> quarry.local

You can override any values you need in a file called dev-values.yaml.

If you create one, run:
helm -n {{ .Release.Namespace }} upgrade {{ .Release.Name }} helm-quarry/ -f dev-values.yaml
Happy hacking.

10 changes: 10 additions & 0 deletions helm-quarry/templates/config_yaml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: config
data:
{{ if .Values.localdev.enabled }}
config.yaml: {{ .Files.Get "dev_config.yaml" | quote }}
{{ else }}
config.yaml: {{ .Files.Get "prod_config.yaml" | quote }}
{{ end }}
36 changes: 36 additions & 0 deletions helm-quarry/templates/db_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: db
labels:
app: db
spec:
replicas: 1
selector:
matchLabels:
app: db
template:
metadata:
labels:
app: db
spec:
containers:
- name: db
image: mariadb:10.1.48-bionic
imagePullPolicy: Always
env:
- name: MYSQL_USER
value: "quarry"
- name: MYSQL_PASSWORD
value: "quarry"
- name: MYSQL_DATABASE
value: "quarry"
- name: MYSQL_RANDOM_ROOT_PASSWORD
value: "1"
volumeMounts:
- name: schema
mountPath: /docker-entrypoint-initdb.d/
volumes:
- name: schema
configMap:
name: db-schema
7 changes: 7 additions & 0 deletions helm-quarry/templates/db_schema_cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: db-schema
data:
schema.sql: |-
{{ .Files.Get "schema.sql" | indent 4}}
11 changes: 11 additions & 0 deletions helm-quarry/templates/db_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
vivian-rook marked this conversation as resolved.
Show resolved Hide resolved
kind: Service
metadata:
name: db
spec:
selector:
app: db
ports:
- name: db
port: 3306
targetPort: 3306
29 changes: 29 additions & 0 deletions helm-quarry/templates/mywiki_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mywiki
labels:
app: mywiki
spec:
replicas: 1
selector:
matchLabels:
app: mywiki
template:
metadata:
labels:
app: mywiki
spec:
containers:
- name: mywiki
image: mywiki:01 # replace with quay.io
imagePullPolicy: Never
env:
- name: MYSQL_USER
value: "repl"
- name: MYSQL_PASSWORD
value: "repl"
- name: MYSQL_DATABASE
value: "repl"
- name: MYSQL_RANDOM_ROOT_PASSWORD
value: "1"
11 changes: 11 additions & 0 deletions helm-quarry/templates/mywiki_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: mywiki
spec:
selector:
app: mywiki
ports:
- name: mywiki
port: 3306
targetPort: 3306
20 changes: 20 additions & 0 deletions helm-quarry/templates/redis_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
vivian-rook marked this conversation as resolved.
Show resolved Hide resolved
kind: Deployment
metadata:
name: redis
labels:
app: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:alpine3.18
imagePullPolicy: Always
11 changes: 11 additions & 0 deletions helm-quarry/templates/redis_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
selector:
app: redis
ports:
- name: redis
port: 6379
targetPort: 6379
12 changes: 12 additions & 0 deletions helm-quarry/templates/results_pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: results
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/results"
9 changes: 9 additions & 0 deletions helm-quarry/templates/results_pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: results
spec:
accessModes: [ReadWriteMany]
resources:
requests:
storage: 1Gi
Loading
Loading