Created
June 20, 2021 18:50
-
-
Save MathiasGruber/f32bbef49b11f1d8336e295e354c5ad9 to your computer and use it in GitHub Desktop.
Super simple sample for deploying BentoML images into Kubernetes
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
import os | |
def deploy_bentoml(model_name): | |
"""Deploys a BentoML from dockerhub into Kubernetes cluster""" | |
# Open a template for BentoML deployments | |
with open('bentoml_deploy.tpl', 'r') as fi: | |
# Substitute the name of the model into template & save | |
yaml_file = fi.read() | |
yaml_file = yaml_file.replace('[VAR_MODULE_NAME]', model_name) | |
yaml_file = yaml_file.replace('[VAR_IMAGE_URL]', f'nanomathias/{model_name}') | |
with open('bentoml_deploy.yaml', 'w') as fo: | |
fo.write(yaml_file) | |
# Apply deployment to Kubernetes | |
os.system('kubectl apply -f bentoml_deploy.yaml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment