Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Forward all issues for Kubeflow org; setup dev environment #60

Merged
merged 1 commit into from
Jan 18, 2020
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
1 change: 1 addition & 0 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ RUN pip install \
tensorflow==1.12.0 \
seldon-core==0.2.6


COPY requirements.txt .
RUN pip install -r requirements.txt
COPY flask_app flask_app/
Expand Down
27 changes: 24 additions & 3 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ with mlbot.net.

This is currently running on a GKE cluster.

See [machine-learning-apps/Issue-Label-Bot#57](https://github.com/machine-learning-apps/Issue-Label-Bot/issues/57) for a log of how
the service was deployed.

To build a new image

```
skaffold build
```

Then to update the image

```
cd overlays/dev|prod
kustomize edit set image gcr.io/github-probots/label-bot-frontend=gcr.io/github-probots/label-bot-frontend:${TAG}@${SHA}
```

## github-probots

Expand Down Expand Up @@ -40,12 +55,18 @@ Deploying it

There is a staging cluster for testing running in

* **GCP project**: issue-label-bot-dev
* **cluster**: github-mlapp-test
* **namespace**: mlapp
* **GCP project**: github-probots
* **cluster**: kf-ci-ml
* **namespace**: label-bot-dev

Deploying it

1. Create the secrets



TODO(jlewi): instructions below are outdated

1. Create the deployment

```
Expand Down
78 changes: 78 additions & 0 deletions deployment/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ml-github-app
labels:
app: ml-github-app
spec:
replicas: 9
selector:
matchLabels:
app: ml-github-app
template:
metadata:
labels:
app: ml-github-app
spec:
containers:
- name: frontend
image: gcr.io/github-probots/label-bot-frontend
command: ["python", "app.py"]
workingDir: "/flask_app"
readinessProbe:
httpGet:
path: /
port: 3000
initialDelaySeconds: 10
periodSeconds: 3
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: ml-app-inference-secret
key: DATABASE_URL
- name: WEBHOOK_SECRET
valueFrom:
secretKeyRef:
name: ml-app-inference-secret
key: WEBHOOK_SECRET
# The values for the Kubeflow kf-label-bot-dev application
# See kubeflow/code-intelligence#84. This is suitable
# for development but shouldn't be used in production
- name: APP_ID
value: "50112"
# Pato the GitHub app PEM key
- name: GITHUB_APP_PEM_KEY
value: /var/secrets/github/kf-label-bot-dev.private-key.pem
# The GCP project and pubsub topic to publish to.
# Default to the test/dev topic
- name: GCP_PROJECT_ID
value: issue-label-bot-dev
- name: GCP_PUBSUB_TOPIC_NAME
value: TEST_event_queue
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/user-gcp-sa.json
- name: FLASK_ENV
value: production
- name: PORT
value: '3000'
- name: APP_URL
value: https://mlbot.net/
- name: authors
value: 'c'
ports:
- containerPort: 443
- containerPort: 80
- containerPort: 3000
volumeMounts:
- name: user-gcp-sa
mountPath: /var/secrets/google
- name: github-app
mountPath: /var/secrets/github
volumes:
- name: user-gcp-sa
secret:
secretName: user-gcp-sa
- name: github-app
secret:
secretName: github-app
20 changes: 20 additions & 0 deletions deployment/base/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: frontend
annotations:
# The ip and certificate name should be overwritten for each
# overlay and set to the correct values
kubernetes.io/ingress.global-static-ip-name: fake-ip
networking.gke.io/managed-certificates: fake-certificate
spec:
backend:
serviceName: ml-github-app
servicePort: 3000
rules:
- http:
paths:
- path: /
backend:
serviceName: ml-github-app
servicePort: 3000
13 changes: 13 additions & 0 deletions deployment/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: label-bot-
commonLabels:
app: label-bot
service: label-bot
images:
- name: gcr.io/github-probots/label-bot-frontend
newName: gcr.io/github-probots/label-bot-frontend
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
13 changes: 13 additions & 0 deletions deployment/base/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: ml-github-app
labels:
app: ml-github-app
spec:
ports:
- port: 3000
protocol: TCP
selector:
app: ml-github-app
type: NodePort
7 changes: 7 additions & 0 deletions deployment/overlays/dev/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: networking.gke.io/v1beta1
kind: ManagedCertificate
metadata:
name: certificate
spec:
domains:
- label-bot-dev.mlbot.net
40 changes: 40 additions & 0 deletions deployment/overlays/dev/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ml-github-app
spec:
replicas: 1
template:
spec:
containers:
- name: frontend
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: ml-app-inference-secret
key: DATABASE_URL
- name: WEBHOOK_SECRET
valueFrom:
secretKeyRef:
name: ml-app-inference-secret
key: WEBHOOK_SECRET
# The values for the Kubeflow kf-label-bot-dev application
# See kubeflow/code-intelligence#84. This is suitable
# for development but shouldn't be used in production
- name: APP_ID
value: "50112"
# Path the GitHub app PEM key
- name: GITHUB_APP_PEM_KEY
value: /var/secrets/github/kf-label-bot-dev.private-key.pem
# The GCP project and pubsub topic to publish to should
# correspond to the production backend
- name: GCP_PROJECT_ID
value: issue-label-bot-dev
- name: GCP_PUBSUB_TOPIC_NAME
value: TEST_event_queue
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/user-gcp-sa.json
- name: FLASK_ENV
value: production

7 changes: 7 additions & 0 deletions deployment/overlays/dev/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: frontend
annotations:
kubernetes.io/ingress.global-static-ip-name: label-bot-dev
networking.gke.io/managed-certificates: certificate
12 changes: 12 additions & 0 deletions deployment/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
commonLabels:
environment: dev
namespace: label-bot-dev
resources:
- certificate.yaml
patchesStrategicMerge:
- deployment.yaml
- ingress.yaml
38 changes: 38 additions & 0 deletions deployment/overlays/prod/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ml-github-app
spec:
replicas: 9
spec:
containers:
- name: frontend
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: ml-app-inference-secret
key: DATABASE_URL
- name: WEBHOOK_SECRET
valueFrom:
secretKeyRef:
name: ml-app-inference-secret
key: WEBHOOK_SECRET
# The values for the Kubeflow issue-label-bot application
# that is available in the GitHub marketplace
- name: APP_ID
value: "27079"
# Pato the GitHub app PEM key
- name: GITHUB_APP_PEM_KEY
value: /var/secrets/github/kf-label-bot-dev.private-key.pem
# The GCP project and pubsub topic to publish to should
# correspond to the production backend
- name: GCP_PROJECT_ID
value: issue-label-bot-dev
- name: GCP_PUBSUB_TOPIC_NAME
value: event_queue
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/user-gcp-sa.json
- name: FLASK_ENV
value: production

19 changes: 19 additions & 0 deletions developer_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Developer guide

1. You can deploy the front end using skaffold

```
skaffold dev --cleanup=False
```

* Your Kubernetes context should be set to using the `github-probots-dev` namespace
* This will continually rebuild and upate your code
* Skaffold's file sync feature is used to update the code in the image without rebuilding and
redeploying
* This makes redeploying very easy.

1. To send a GitHub webhook event you can either open up an issue or you can use `scripts/send_request.py`

* The latter is useful because it avoids needing to open up a new GitHub issue

* Right now the bot is only designed to respond to issues opened events.
Loading