Redis 作为 Container/POD 的 Sidecar?
Redis as a Sidecar to a Container/POD?
我需要在 container/POD 中 运行 两项服务 ...
1. An App
2. Redis - the App uses it
有没有可能,比如让 Redis 成为 Sidecar?
你只需要做一个两容器的 pod,像这样:
containers:
- name: 1st
image: redis
...
- name: 2nd
image: app
如果你想将 Redis 的生命周期与你的应用程序的单个实例联系起来,你可以这样做。您只需要创建一个包含多个容器的 pod。如果它们 运行 在同一个 pod 中,您可以从您的应用访问 localhost
上的 redis。
apiVersion: v1
kind: Pod
metadata:
name: two-containers
spec:
containers:
- name: app
image: myapp
- name: redis
image: redis
您的问题听起来更像是 XY problem. Why not make redis as a separate pod and access it via a service?这样您就可以独立扩展您的应用程序。
我需要在 container/POD 中 运行 两项服务 ...
1. An App
2. Redis - the App uses it
有没有可能,比如让 Redis 成为 Sidecar?
你只需要做一个两容器的 pod,像这样:
containers:
- name: 1st
image: redis
...
- name: 2nd
image: app
如果你想将 Redis 的生命周期与你的应用程序的单个实例联系起来,你可以这样做。您只需要创建一个包含多个容器的 pod。如果它们 运行 在同一个 pod 中,您可以从您的应用访问 localhost
上的 redis。
apiVersion: v1
kind: Pod
metadata:
name: two-containers
spec:
containers:
- name: app
image: myapp
- name: redis
image: redis
您的问题听起来更像是 XY problem. Why not make redis as a separate pod and access it via a service?这样您就可以独立扩展您的应用程序。