Skip to content

Instantly share code, notes, and snippets.

@MathiasGruber
Created June 20, 2021 18:50
Show Gist options
  • Save MathiasGruber/f32bbef49b11f1d8336e295e354c5ad9 to your computer and use it in GitHub Desktop.
Save MathiasGruber/f32bbef49b11f1d8336e295e354c5ad9 to your computer and use it in GitHub Desktop.
Super simple sample for deploying BentoML images into Kubernetes
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