在 kubernetes 中,depends_on 的等价物是什么 [英] What is the equivalent for depends_on in kubernetes
问题描述
我有一个包含以下条目的 docker compose 文件
I have a docker compose file with the following entries
version: '2.1'
services:
mysql:
container_name: mysql
image: mysql:latest
volumes:
- ./mysqldata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 'password'
ports:
- '3306:3306'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3306"]
interval: 30s
timeout: 10s
retries: 5
test1:
container_name: test1
image: test1:latest
ports:
- '4884:4884'
- '8443'
depends_on:
mysql:
condition: service_healthy
links:
- mysql
Test-1 容器依赖于 mysql,它需要启动并运行.
The Test-1 container is dependent on mysql and it needs to be up and running.
在 docker 中,这可以使用健康检查和depends_on 属性来控制.kubernetes 中的健康检查等效项是我已经创建的 readinessprobe,但是我们如何控制 pod 中的容器启动???????
In docker this can be controlled using health check and depends_on attributes. The health check equivalent in kubernetes is readinessprobe which i have already created but how do we control the container startup in the pod's?????
非常感谢您对此的任何指示.
Any directions on this is greatly appreciated.
我的 Kubernetes 文件:
My Kubernetes file:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: deployment
spec:
replicas: 1
template:
metadata:
labels:
app: deployment
spec:
containers:
- name: mysqldb
image: "dockerregistry:mysqldatabase"
imagePullPolicy: Always
ports:
- containerPort: 3306
readinessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 15
periodSeconds: 10
- name: test1
image: "dockerregistry::test1"
imagePullPolicy: Always
ports:
- containerPort: 3000
推荐答案
这是故意省略的.原因是应用程序应该负责连接/重新连接逻辑以连接到服务(例如数据库).这超出了 Kubernetes 的范围.
This was purposefully left out. The reason being is that applications should be responsible for their connect/re-connect logic for connecting to service(s) such as a database. This is outside the scope of Kubernetes.
这篇关于在 kubernetes 中,depends_on 的等价物是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!