Prepare Your Environment
- Ensure you have a Kubernetes cluster set up. Minikube or a cloud provider like IBM Cloud Kubernetes Service works.
- Install Kubernetes CLI:
kubectl
.
- Set up Docker to build container images.
Create a Docker Image
- Download and configure your IBM Watson service.
- Write a Dockerfile to containerize your app, e.g., using a base Python/Node.js image.
FROM python:3.8-slim
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
Deploy to Kubernetes
- Build and push your Docker image to a registry.
- Define a Kubernetes deployment YAML file for your app. Include configurations like replicas, image, and ports.
apiVersion: apps/v1
kind: Deployment
metadata:
name: watson-deploy
spec:
replicas: 2
selector:
matchLabels:
app: watson
template:
metadata:
labels:
app: watson
spec:
containers:
- name: watson
image: user/watson-image
ports:
- containerPort: 5000
- Apply the configuration:
kubectl apply -f deployment.yaml
.
- Expose the deployment through a service to access IBM Watson externally.
kubectl expose deployment watson-deploy --type=LoadBalancer --name=watson-service