This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kustomize deployments and skaffolding for Label_MIcroservice (#93)
* This PR provides a kustomize package to deploy the label microservice * Also add a skaffolding config for the Label_Microservice * Remove the old YAML deployment files for the Label Microservice. * Edit the worker Dockerfile * Use TensorFlow 1.15.0 rather than using the "latest" image * We can also use a regular TensorFlow image and not a GPU version since this is just for inference and so we shouldn't need GPUs * Create a new requirements.worker.txt to only include the libraries that are needed in the worker. This should be much smaller than the uber set of python libraries (e.g. we don't need Jupyter, fairing, etc...) * Create requirements.universal_model.txt to contain some of the required python dependencies for the universal model. * Universal model is using ktext and some other libraries. * Add a prod overlay for the issue_embedding service. * create_secrets.py is a helper script for creating the required secrets in the clusters based on files in GCS. Related to #70 ensemble models.
- Loading branch information
1 parent
262bfb8
commit 244b6eb
Showing
24 changed files
with
524 additions
and
227 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
11 changes: 11 additions & 0 deletions
11
Issue_Embeddings/deployment/overlays/prod/deployments.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,11 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: server | ||
spec: | ||
# Use a single replica for development | ||
replicas: 3 | ||
template: | ||
spec: | ||
containers: | ||
- name: app |
13 changes: 13 additions & 0 deletions
13
Issue_Embeddings/deployment/overlays/prod/kustomization.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,13 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
commonLabels: | ||
environment: prod | ||
namespace: label-bot-prod | ||
patchesStrategicMerge: | ||
- deployments.yaml | ||
resources: | ||
- ../../base | ||
images: | ||
- digest: sha256:292e6af3214b3a3dc499fe08a1873b986b77ba9e201ca57afd9d6736f513fe40 | ||
name: gcr.io/issue-label-bot-dev/issue-embedding | ||
newName: gcr.io/issue-label-bot-dev/issue-embedding:3191fea |
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 |
---|---|---|
@@ -1,72 +1,37 @@ | ||
# borrowed from hamelsmu/ml-gpu-lite | ||
# Dockerfile for prediction workers | ||
FROM tensorflow/tensorflow:1.15.0-py3 | ||
|
||
FROM tensorflow/tensorflow:latest-gpu-py3 | ||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 | ||
|
||
RUN add-apt-repository -y ppa:git-core/ppa | ||
RUN add-apt-repository -y ppa:jonathonf/python-3.6 | ||
|
||
RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \ | ||
build-essential \ | ||
byobu \ | ||
ca-certificates \ | ||
git-core git \ | ||
htop \ | ||
libglib2.0-0 \ | ||
libjpeg-dev \ | ||
libpng-dev \ | ||
libxext6 \ | ||
libsm6 \ | ||
libxrender1 \ | ||
libcupti-dev \ | ||
openssh-server \ | ||
python3.6 \ | ||
python3.6-dev \ | ||
software-properties-common \ | ||
vim \ | ||
&& \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN apt-get -y update | ||
|
||
# Setup Python 3.6 (Need for other dependencies) | ||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 | ||
RUN apt-get install -y python3-setuptools | ||
RUN easy_install pip | ||
RUN pip install --upgrade pip | ||
|
||
# Fastai dependencies | ||
RUN pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html | ||
|
||
# install python packages | ||
COPY Label_Microservice/requirements.txt . | ||
RUN pip --no-cache-dir install -r requirements.txt | ||
|
||
#For Fairseq-py | ||
ENV NVIDIA_VISIBLE_DEVICES all | ||
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility | ||
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64 | ||
|
||
# Open Ports for TensorBoard, Jupyter, and SSH | ||
EXPOSE 6006 | ||
EXPOSE 7654 | ||
EXPOSE 22 | ||
|
||
#Setup File System | ||
RUN mkdir ds | ||
ENV HOME=/ds | ||
ENV SHELL=/bin/bash | ||
VOLUME /ds | ||
WORKDIR /ds | ||
COPY Label_Microservice/deployment/requirements.worker.txt . | ||
COPY Label_Microservice/deployment/requirements.universal_model.txt . | ||
RUN pip --no-cache-dir install -r requirements.worker.txt | ||
RUN pip --no-cache-dir install -r requirements.universal_model.txt | ||
|
||
# Copy needed files for worker | ||
COPY py/label_microservice/worker.py /ds/worker.py | ||
COPY py /py | ||
ENV PYTHONPATH=/py | ||
|
||
# Skaffold hack | ||
# Skaffold infers the files to watch for changes by parsing the dockerfile | ||
# and looking for COPY statements. Skaffold v1.1.0 doesn't appear to detect | ||
# changes to directories so we add explicit COPY statements for the files that | ||
# we want to retrigger skaffold on when they are modified | ||
# TODO(jlewi): Need to try removing this. I think the problem might have been I was out of | ||
# notify resources on my local machine. When I switched skaffold to use --notify=polling | ||
# it started to detect changes. | ||
COPY py/label_microservice/mlp.py /py/label_microservice/mlp.py | ||
COPY py/label_microservice/models.py /py/label_microservice/models.py | ||
COPY py/label_microservice/repo_config.py /py/label_microservice/repo_config.py | ||
COPY py/label_microservice/repo_specific_model.py /py/label_microservice/repo_specific_model.py | ||
COPY py/label_microservice/universal_kind_label_model.py /py/label_microservice/universal_kind_label_model.py | ||
COPY py/label_microservice/worker.py /py/label_microservice/worker.py | ||
|
||
# Add helper files | ||
# TODO(jlewi): What is this for? | ||
RUN pip freeze > container_requirements.txt | ||
|
||
# Run the shell | ||
# TODO(jlewi): Why is the default command tail? | ||
CMD [ "/bin/bash", "-c", "tail -f /dev/null" ] |
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,51 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: worker | ||
spec: | ||
replicas: 5 | ||
template: | ||
metadata: | ||
labels: | ||
app: worker | ||
spec: | ||
volumes: | ||
- name: github-app | ||
secret: | ||
secretName: github-app | ||
containers: | ||
- name: app | ||
image: gcr.io/issue-label-bot-dev/bot-worker | ||
command: | ||
- python3 | ||
- -m | ||
- label_microservice.worker | ||
- subscribe_from_env | ||
resources: | ||
requests: | ||
memory: "4Gi" | ||
cpu: "4" | ||
volumeMounts: | ||
- name: github-app | ||
mountPath: /var/secrets/github | ||
env: | ||
- name: PORT | ||
value: "80" | ||
# This should be the name of the in-cluster K8s service running issue embeddings | ||
- name: ISSUE_EMBEDDING_SERVICE | ||
value: "http://issue-embedding-server" | ||
- name: PROJECT | ||
value: issue-label-bot-dev | ||
# The values for the Kubeflow kf-label-bot-dev application | ||
# See kubeflow/code-intelligence#84 | ||
- name: GITHUB_APP_ID | ||
value: "50112" | ||
- name: GITHUB_APP_PEM_KEY | ||
value: /var/secrets/github/kf-label-bot-dev.private-key.pem | ||
# TODO(jlewi):Not needed because we use workload identity | ||
#- name: GOOGLE_APPLICATION_CREDENTIALS | ||
# value: /var/secrets/google/user-gcp-sa.json | ||
restartPolicy: Always | ||
# We need to set a service account corresponding to workload | ||
# identity | ||
serviceAccountName: default-editor |
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,12 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namePrefix: label-bot- | ||
commonLabels: | ||
service: label-bot | ||
app: label-bot | ||
images: | ||
- name: gcr.io/issue-label-bot-dev/bot-worker | ||
newName: gcr.io/issue-label-bot-dev/bot-worker | ||
resources: | ||
- service.yaml | ||
- deployments.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,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: worker | ||
spec: | ||
selector: | ||
app: worker | ||
ports: | ||
- name: http | ||
port: 80 | ||
protocol: TCP | ||
targetPort: 80 | ||
type: ClusterIP |
Oops, something went wrong.