---
title: "Deploying 🤗 ViT on Kubernetes with TF Serving"
description: "A Vision Transformer from Hugging Face Transformers, exported as a TensorFlow SavedModel, is packaged into a custom TensorFlow Serving Docker image and deployed to a GKE cluster."
url: "https://swe.quest/articles/deploying-vit-on-kubernetes-with-tf-serving-72269d9df3724559"
canonical: "https://huggingface.co/blog/deploy-tfserving-kubernetes"
source: "Hugging Face"
published: "2022-08-11"
difficulty: "medium"
kind: "How-to"
reading_minutes: 12
tags: ["inference","kubernetes","containers","cloud"]
---

# Deploying 🤗 ViT on Kubernetes with TF Serving

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-08-11, 12 min read, How-to. Original: [https://huggingface.co/blog/deploy-tfserving-kubernetes](https://huggingface.co/blog/deploy-tfserving-kubernetes)

## Summary

A Vision Transformer from Hugging Face Transformers, exported as a TensorFlow SavedModel, is packaged into a custom TensorFlow Serving Docker image and deployed to a GKE cluster. The walkthrough covers building the image via docker commit with the versioned model directory layout, pushing it to GCR, and writing Deployment, Service (LoadBalancer exposing gRPC 8500 and REST 8501) and HorizontalPodAutoscaler manifests applied with kubectl or Kustomize. It also explains how CPU requests drive HPA scaling decisions and how to tune TF Serving's inter-op and intra-op parallelism flags.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)
- [Cloud platforms](https://swe.quest/tags/cloud.md) (Infrastructure)

## Prerequisites

- Docker basics ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- Kubernetes basics ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- TensorFlow SavedModel

## Keywords

TensorFlow Serving, Vision Transformer, Hugging Face Transformers, GKE, Horizontal Pod Autoscaler, Kustomize, Docker, gRPC

## Related posts

- [Deploying TensorFlow Vision Models in Hugging Face with TF Serving](https://swe.quest/articles/deploying-tensorflow-vision-models-in-hugging-face-with-tf-serving-a278ea9a908befbd.md): Hugging Face · 2022-07-25 · Medium · 8 min read · Inference & serving, Computer vision, Python, RPC & gRPC
  A Vision Transformer image classifier from Hugging Face Transformers can be served locally with TensorFlow Serving by exporting it as a SavedModel with preprocessing and postprocessing embedded in the graph.
- [Deploying 🤗 ViT on Vertex AI](https://swe.quest/articles/deploying-vit-on-vertex-ai-1cefa91d85f70e80.md): Hugging Face · 2022-08-19 · Medium · 10 min read · Inference & serving, Cloud platforms, ML platforms, Computer vision, Python
  A TensorFlow ViT B/16 SavedModel from 🤗 Transformers, with base64 image preprocessing and label postprocessing baked into its signature, can be served on Google Cloud Vertex AI in four SDK steps: upload to the Model Registry, create an Endpoint, deploy with machine/accelerator specs and traffic split, then send prediction requests.
- [My Journey to a serverless transformers pipeline on Google Cloud](https://swe.quest/articles/my-journey-to-a-serverless-transformers-pipeline-on-google-cloud-202ccbc112026927.md): Hugging Face · 2021-03-18 · Medium · 8 min read · Serverless, Inference & serving, Cloud platforms, Python, Containers
  A Hugging Face transformers sentiment-analysis pipeline (DistilBERT fine-tuned on SST-2) was deployed as a low-traffic microservice on Google Cloud Run after AI Platform Prediction (beta instability, checkpoint not a pure TensorFlow model) and App Engine (TensorFlow install failure, PyTorch handling only 2 requests per instance) fell short.
- [Deploy Triton Inference Server on Railway](https://swe.quest/articles/deploy-triton-inference-server-on-railway-ef04464cb6f25df0.md): Railway · 2024-12-13 · Medium · 10 min read · Inference & serving, ML platforms, Deployment, Python
  NVIDIA Triton Inference Server can serve CPU-friendly ML models on Railway, with MinIO as an S3-compatible model repository.
- [Hugging Face's TensorFlow Philosophy](https://swe.quest/articles/hugging-face-s-tensorflow-philosophy-1d3751167c605c69.md): Hugging Face · 2022-08-12 · Medium · 14 min read · Machine learning, Python, Model training, Compilers
  Hugging Face's transformers library treats TensorFlow models as first-class Keras citizens: every model is a Keras Model and every layer a Keras Layer, so fit(), compile() and predict() work directly, and models compose into custom hybrids via subclassing.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
