# ==========================================
# 1. REDIS: Deployment и Service
# ==========================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
labels:
app: redis
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:alpine
ports:
- containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
name: redis-service
spec:
selector:
app: redis
ports:
- protocol: TCP
port: 6379
targetPort: 6379
type: ClusterIP
---
# ==========================================
# 2. PYTHON APP: Deployment и Service
# ==========================================
apiVersion: apps/v1
kind: Deployment
metadata:
name: python-app-deployment
labels:
app: python-app
spec:
replicas: 2
selector:
matchLabels:
app: python-app
template:
metadata:
labels:
app: python-app
spec:
containers:
- name: python-app
image: my-python-app:1.0
imagePullPolicy: IfNotPresen
ports:
- containerPort: 5000
env:
- name: REDIS_HOST
value: "redis-service"
- name: REDIS_PORT
value: "6379"
---
apiVersion: v1
kind: Service
metadata:
name: python-app-service
spec:
selector:
app: python-app
ports:
- protocol: TCP
port: 80
targetPort: 5000
nodePort: 30080
type: NodePort