我是道克和库伯内特斯的新手。所使用的技术:
我将两个服务托管到两个码头容器中,container1和container2。
下面是我的deploy.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: webapi-dockerkube
spec:
replicas: 1
template:
metadata:
labels:
app: webapi-dockerkube
spec:
containers:
- name: webapi-dockerkube
image: "webapidocker:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /api/values
port: 80
readinessProbe:
httpGet:
path: /api/values
port: 80
- name: webapi-dockerkube2
image: "webapidocker2:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /api/other/values
port: 80
readinessProbe:
httpGet:
path: /api/other/values
port: 80当我运行命令时:
kubectl create -f .\deploy.yaml我得到了CrashLoopBackOff的地位。
但是,当我只配置了一个容器时,运行正常也是一样。在检查日志时,我得到以下错误:Error from server (BadRequest): a container name must be specified for pod webapi-dockerkube-8658586998-9f8mk, choose one of: [webapi-dockerkube webapi-dockerkube2]
发布于 2019-04-18 20:20:59
您正在同一个吊舱中运行两个容器,这两个容器都绑定到端口80。这在同一舱内是不可能的。想象一下像“服务器”这样的吊舱,您就不能将两个进程绑定到同一个端口。
解决方案在您的情况:使用不同的端口在舱内或使用单独的吊舱。从您的部署来看,似乎没有像文件系统这样的共享资源,因此可以很容易地将容器拆分成不同的荚。
请注意,如果您希望两个容器都运行在具有不同端口的同一个吊舱中,那么更改pod定义是不够的。容器中的应用程序也必须绑定到不同的端口。
发布于 2019-04-18 17:54:27
apiVersion: v1
kind: Pod
metadata:
name: two-containers
spec:
restartPolicy: Never
volumes:
- name: shared-data
emptyDir: {}
containers:
- name: nginx-container
image: nginx
volumeMounts:
- name: shared-data
mountPath: /usr/share/nginx/html
- name: debian-container
image: debian
volumeMounts:
- name: shared-data
mountPath: /pod-data
command: ["/bin/sh"]
args: ["-c", "echo Hello from the debian container > /pod-data/index.html"] 在这里,共享多个容器的示例,您可以使用此模板
此外,您还可以检查使用的日志。
库贝克尔原木
检查回崩溃环的原因
https://stackoverflow.com/questions/55751220
复制相似问题