๐ Stock K8s Operator
A Kubernetes operator that dynamically monitors stock prices and integrates financial data into your Kubernetes ecosystem.


๐ Overview
The Stock K8s Operator enables Kubernetes to interact with financial markets by providing real-time stock price monitoring capabilities within your cluster. This operator extends Kubernetes with custom resources that represent stock quotes and their associated data, allowing your applications to react to market information.
โจ Features
- ๐ Stock Quote Monitoring: Query current stock prices from financial data providers
- ๐ Automatic Updates: Periodically fetch the latest stock information
- ๐ Status Integration: Stock quote data stored directly in Kubernetes resource status
- ๐ API Provider Flexibility: Compatible with various stock data APIs
- ๐งฉ Kubernetes Native: Follows standard Kubernetes operator patterns
๐๏ธ Architecture

The Stock K8s Operator follows standard Kubernetes operator patterns:
- Custom Resource Definition: Defines
StockQuote
resources in your cluster
- Controller: Watches for
StockQuote
resources and queries external APIs for data
- Reconciliation Loop: Periodically fetches updated stock information
- Status Updates: Records current price and metadata in the resource status
๐ Installation
Prerequisites
- Kubernetes cluster v1.19+
- kubectl v1.19+
- Helm v3+ (optional)
Using kubectl
# Install CRDs
kubectl apply -f https://raw.githubusercontent.com/rodrigc/stock-k8s-operator/main/config/crd/bases/batch.stock-operator.crodrigues.org_stockquotes.yaml
# Install operator
kubectl apply -f https://raw.githubusercontent.com/rodrigc/stock-k8s-operator/main/config/deploy/operator.yaml
Using Helm
helm repo add stock-operator https://rodrigc.github.io/stock-k8s-operator/charts
helm install stock-operator stock-operator/stock-k8s-operator
๐ Usage
Creating a StockQuote Resource
apiVersion: batch.stock-operator.crodrigues.org/v1
kind: StockQuote
metadata:
name: aapl-stock
spec:
symbol: AAPL
Checking StockQuote Status
kubectl get stockquotes
NAME SYMBOL PRICE LAST UPDATED
aapl-stock AAPL 175.23 2025-03-15T14:30:00Z
msft-stock MSFT 418.07 2025-03-15T14:30:00Z
Detailed View
kubectl describe stockquote aapl-stock
โ๏ธ Configuration
The operator can be configured through environment variables:
Variable |
Description |
Default |
WATCH_NAMESPACE |
Namespace to watch for StockQuote resources |
All namespaces |
API_PROVIDER |
Stock data provider to use |
alphavantage |
API_KEY |
API key for the stock data provider |
"" |
RECONCILE_PERIOD |
How often to update stock quotes |
5m |
๐ป Development
Building from Source
# Clone the repository
git clone https://github.com/rodrigc/stock-k8s-operator.git
cd stock-k8s-operator
# Build
make build
# Run locally
make run
Running Tests
make test
๐ฎ Use Cases
- Financial Dashboards: Display real-time market data in Kubernetes-based dashboards
- Informational Services: Provide stock information to applications running in your cluster
- Market Data Collection: Gather stock prices for analysis or reporting
- Financial Applications: Base financial applications on current market data
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
๐ License
MIT License