Skip to content

Commit

Permalink
setting up a local kubernetes deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
felipesanches committed May 3, 2017
1 parent c739b2c commit 65530a4
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 39 deletions.
16 changes: 16 additions & 0 deletions dashboard/containers/dispatcher/dispatch-jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
import os
from fontprojects import git_repos

local_devel = (os.environ.get("FONTBAKERY_LOCAL_DEVEL" == 1)
local_families_selection = [
"Roboto",
"Roboto Condensed",
"Ubuntu",
"Merriweather",
"Lobster",
"Exo",
"Overpass Mono",
"Sarala"]

def main():
# We'll retry until we get a connection and deliver the messages
while True:
Expand All @@ -22,6 +33,11 @@ def main():
# because they are purely informative statements
continue

if local_devel and entry[1] not in local_families_selection:
# when deploying the cluster locally during development,
# we restrict the list of families to a smaller selection
continue

message = {
"MSG_INDEX": i,
"STATUS": entry[0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import time
import urllib

runs = int(os.environ.get("NONPARALLEL_JOB_RUNS", 1))
MAX_NUM_ITERATIONS = 1 # For now we'll limit the jobs to run
# up to "MAX_NUM_ITERATIONS" commits
# in the font project repos
Expand Down Expand Up @@ -221,7 +220,7 @@ def run_fontbakery_on_production_files():

connection = None
def callback(ch, method, properties, body): #pylint: disable=unused-argument
global runs, REPO_URL, FAMILYNAME
global REPO_URL, FAMILYNAME
msg = json.loads(body)
print("Received %r" % msg, file=sys.stderr)

Expand All @@ -243,12 +242,8 @@ def callback(ch, method, properties, body): #pylint: disable=unused-argument
ch.basic_ack(delivery_tag = method.delivery_tag)
connection.close()

runs -= 1
if runs == 0:
print("Finished work. Shutting down this container instance...")
sys.exit(0)
else:
print("Will fetch another workload...")
print("Finished work. Shutting down this container instance...")
sys.exit(0)


def main():
Expand Down
62 changes: 62 additions & 0 deletions dashboard/deploy_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# envvars_setup.sh
PROJECT=fontbakery
GCLOUD="sudo /home/felipe/devel/prebuilt/google-cloud-sdk/bin/gcloud"
DOCKER="sudo docker"

# update_database:
$DOCKER build -t rethinkdb-2.3.5 containers/rethinkdb
$DOCKER tag rethinkdb-2.3.5 gcr.io/$PROJECT/rethinkdb-2.3.5
$GCLOUD docker -- push gcr.io/$PROJECT/rethinkdb-2.3.5
kubectl delete rc rethinkdb-rc
kubectl create -f services/rethinkdb-driver-service.yaml
kubectl create -f services/rethinkdb-rc.yaml
kubectl create -f services/rethinkdb-admin-service.yaml

# update flask service
# Note: This will affect the publicly accessinble IP address.
kubectl delete svc flaskapp-service
kubectl create -f services/flask-service.yaml

# update_frontend:
$DOCKER build -t fb-dashboard-1 containers/web
$DOCKER tag fb-dashboard-1 gcr.io/$PROJECT/fb-dashboard-1
$GCLOUD docker -- push gcr.io/$PROJECT/fb-dashboard-1
kubectl delete rc dashboard-rc
kubectl create -f services/dashboard-rc.yaml


# -> "kill all":
kubectl delete svc rabbitmq-service
kubectl delete rc rabbitmq-controller
kubectl delete job job-fb-worker-1
kubectl delete job job-fb-dispatcher-1

# update_queue_service:
kubectl delete svc rabbitmq-service
kubectl delete rc rabbitmq-controller
kubectl create -f services/rabbitmq-service.yaml
kubectl create -f services/rabbitmq-controller.yaml

# update_workers:
$DOCKER build -t job-fb-worker-1 ..
$DOCKER tag job-fb-worker-1 gcr.io/$PROJECT/job-fb-worker-1
$GCLOUD docker -- push gcr.io/$PROJECT/job-fb-worker-1
kubectl delete job job-fb-worker-1
kubectl create -f jobs/worker_local.yaml

# update_dispatcher:
$DOCKER build -t job-fb-dispatcher-1 containers/dispatcher
$DOCKER tag job-fb-dispatcher-1 gcr.io/$PROJECT/job-fb-dispatcher-1
$GCLOUD docker -- push gcr.io/$PROJECT/job-fb-dispatcher-1
kubectl delete job job-fb-dispatcher-1
kubectl create -f jobs/dispatcher_local.yaml

# overall status:
kubectl get jobs
kubectl get pods
kubectl get svc
kubectl get rc




31 changes: 0 additions & 31 deletions dashboard/docker-compose.yml

This file was deleted.

20 changes: 20 additions & 0 deletions dashboard/jobs/dispatcher_local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: batch/v1
kind: Job
metadata:
name: job-fb-dispatcher-1
spec:
completions: 1
parallelism: 1
template:
metadata:
name: job-fb-dispatcher-1
spec:
containers:
- name: c
image: gcr.io/fontbakery/job-fb-dispatcher-1
env:
- name: QUEUE
value: job1
- name: FONTBAKERY_LOCAL_DEVEL
value: 1
restartPolicy: OnFailure
18 changes: 18 additions & 0 deletions dashboard/jobs/worker_local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: batch/v1
kind: Job
metadata:
name: job-fb-worker-1
spec:
completions: 8
parallelism: 8
template:
metadata:
name: job-fb-worker-1
spec:
containers:
- name: c
image: gcr.io/fontbakery/job-fb-worker-1
env:
- name: QUEUE
value: job1
restartPolicy: OnFailure

0 comments on commit 65530a4

Please sign in to comment.