This directory contains Kubernetes manifests to deploy the ChemGraph Streamlit application on a Kubernetes cluster.
- A running Kubernetes cluster
kubectlconfigured to communicate with your cluster- Docker image available at
ghcr.io/argonne-lcf/chemgraph:latest(or build your own) - API keys for the LLM providers you want to use
deployment.yaml- Deployment manifest for the Streamlit appservice.yaml- Service manifest to expose the appsecrets.yaml.template- Template for storing API keys securelyingress.yaml- (Optional) Ingress configuration for external access
First, copy the secrets template and fill in your API keys:
cp secrets.yaml.template secrets.yamlEdit secrets.yaml and replace the placeholder values with your actual API keys:
stringData:
openai-api-key: "sk-..."
anthropic-api-key: "sk-ant-..."
gemini-api-key: "..."
groq-api-key: "..."
argo-user: "..."
alcf-access-token: "..."Important: Never commit secrets.yaml to version control! Add it to .gitignore.
Apply the secret:
kubectl create namespace chemgraph # Optional: create a dedicated namespace
kubectl apply -f secrets.yamlApply the deployment and service manifests:
kubectl apply -f deployment.yaml
kubectl apply -f service.yamlCheck the status of your deployment:
kubectl get pods -l app=chemgraph
kubectl get svc chemgraph-streamlitGet the external IP (if using LoadBalancer type):
kubectl get svc chemgraph-streamlitOnce the service has an external IP, access the Streamlit app at:
http://<EXTERNAL-IP>:8501
If using a cloud provider, it may take a few minutes for the LoadBalancer to provision an external IP.
If your cluster doesn't support LoadBalancer, edit service.yaml and change the service type:
spec:
type: NodePortThen access the app using any node IP and the assigned NodePort:
kubectl get svc chemgraph-streamlit
# Access at http://<NODE-IP>:<NODE-PORT>For local testing, use port forwarding:
kubectl port-forward svc/chemgraph-streamlit 8501:8501Then access at http://localhost:8501
For production deployments with a domain name, use the included ingress configuration:
kubectl apply -f ingress.yamlMake sure you have an Ingress controller installed (like nginx-ingress or traefik) and update the host in ingress.yaml.
Edit deployment.yaml to adjust resource requests and limits:
resources:
requests:
memory: "2Gi"
cpu: "1000m"
limits:
memory: "4Gi"
cpu: "2000m"To run multiple replicas for high availability:
spec:
replicas: 3If you've built your own ChemGraph image:
containers:
- name: streamlit
image: your-registry/chemgraph:your-tagkubectl get pods -l app=chemgraph
kubectl describe pod <pod-name>kubectl logs -f deployment/chemgraph-streamlitThe deployment includes liveness and readiness probes that check the Streamlit health endpoint:
kubectl describe pod <pod-name> | grep -A 10 "Liveness\|Readiness"Pod not starting:
- Check if the image can be pulled:
kubectl describe pod <pod-name> - Verify secrets are created:
kubectl get secrets
Application crashes:
- Check logs:
kubectl logs <pod-name> - Verify API keys are correct
- Check resource limits are sufficient
Cannot access the service:
- Verify service is running:
kubectl get svc - Check if LoadBalancer has an external IP assigned
- Verify firewall rules allow traffic on port 8501
To remove all ChemGraph resources:
kubectl delete -f deployment.yaml
kubectl delete -f service.yaml
kubectl delete secret chemgraph-secrets- Never commit secrets to version control
- Use RBAC to limit access to the namespace
- Enable TLS for production deployments (use Ingress with cert-manager)
- Rotate API keys regularly
- Use network policies to restrict pod-to-pod communication if needed
- Consider using a secrets management solution like HashiCorp Vault or Sealed Secrets