try:
_redis_client = Redis('redis')
print(_redis_client.info())
except Exception as e:
print(e)
version: "3"
services:
web:
build: .
ports:
- "8080:8080"
restart: always
redis:
image: redis:5-alpine
ports:
- "6379:6379"
volumes:
- "/data"
restart: always
apiVersion: apps/v1
kind: Deployment
metadata:
name: pytest
spec:
replicas: 1
template:
metadata:
labels:
app: pytest
spec:
containers:
- name: web
image: '..'
ports:
- containerPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
spec:
volumes:
- name: redis-data
containers:
- name: redis
image: redis:5-alpine
ports:
- containerPort: 6379
protocol: TCP
volumeMounts:
- name: redis-data
mountPath: /data
selector:
matchLabels:
app: redis
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
type: NodePort
ports:
- name: "web"
port: 8080
selector:
app: pytest
---
apiVersion: v1
kind: Service
metadata:
name: redis
spec:
type: NodePort
ports:
- name: "redis"
port: 6379
selector:
app: redis
怎么连上 k8s 的 redis
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.