[英]pod stuck in pending state after kubectl apply?
my pod stays in pending state after kubectl apply. 应用kubectl后,我的pod保持挂起状态。 I am currently trying to deploy 3 services which are postgres database,api server and the ui of application.The postgres pod is running fine but the remaining 2 services are stuck in pending state.
我目前正在尝试部署3个服务,这些服务是postgres数据库,api服务器和应用程序的ui。postgres pod正常运行但其余2个服务处于挂起状态。
I tried creating yaml files like this 我尝试像这样创建yaml文件
api server persistant volume api服务器持续卷
kind: PersistentVolume
apiVersion: v1
metadata:
name: api-initdb-pv-volume
labels:
type: local
app: api
spec:
storageClassName: manual
capacity:
storage: 1Mi
accessModes:
- ReadOnlyMany
hostPath:
path: "/home/vignesh/pagedesigneryamls/api"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: api-initdb-pv-claim-one
labels:
app: api
spec:
storageClassName: manual
accessModes:
- ReadOnlyMany
resources:
requests:
storage: 1Mi
api server api服务器
apiVersion: v1
kind: Service
metadata:
name: apiserver
labels:
app: apiserver
spec:
ports:
- name: apiport
port: 8000
targetPort: 8000
selector:
app: apiserver
tier: backend
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apiserver
labels:
app: apiserver
spec:
selector:
matchLabels:
app: apiserver
tier: backend
strategy:
type: Recreate
template:
metadata:
labels:
app: apiserver
tier: backend
spec:
containers:
- image: suji165475/devops-sample:wootz-backend
name: apiserver
ports:
- containerPort: 8000
name: myport
volumeMounts:
- name: api-persistent-storage-one
mountPath: /usr/src/app
- name: api-persistent-storage-two
mountPath: /usr/src/app/node_modules
volumes:
- name: api-persistent-storage-one
persistentVolumeClaim:
claimName: api-initdb-pv-claim-one
- name: api-persistent-storage-two
persistentVolumeClaim:
claimName: api-initdb-pv-claim-two
docker-compose file (just for refernce) docker-compose文件(仅供参考)
version: "3"
services:
pg_db:
image: postgres
networks:
- wootzinternal
ports:
- 5432
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=postgres
- POSTGRES_DB=wootz
volumes:
- wootz-db:/var/lib/postgresql/data
apiserver:
image: wootz-backend
volumes:
- ./api:/usr/src/app
- /usr/src/app/node_modules
build:
context: ./api
dockerfile: Dockerfile
networks:
- wootzinternal
depends_on:
- pg_db
ports:
- '8000:8000'
ui:
image: wootz-frontend
volumes:
- ./client:/usr/src/app
- /usr/src/app/node_modules
build:
context: ./client
dockerfile: Dockerfile
networks:
- wootzinternal
ports:
- '80:3000'
volumes:
wootz-db:
networks:
wootzinternal:
driver: bridge
when I tried kubectl apply on the api server yaml file, the pod for the api server was stuck in pending state for ever.how do i solve this. 当我尝试kubectl应用于api服务器yaml文件时,api服务器的pod已经陷入暂停状态,我是否解决了这个问题。
For your future questions, if you need to get more information on what is happening you should be using kubectl describe pod_name
as this would give you and us more information and would increase a chance for a proper answer. 对于您将来的问题,如果您需要获得有关正在发生的事情的更多信息,您应该使用
kubectl describe pod_name
因为这将为您和我们提供更多信息,并将增加获得正确答案的机会。 I used your yaml and after describing the pod: 我用你的yaml并描述了pod之后:
persistentvolumeclaim "api-initdb-pv-claim-two" not found
After adding second one: 添加第二个后:
pod has unbound PersistentVolumeClaims (repeated 3 times)
After you add the second PV it should start working. 添加第二个PV后,它应该开始工作。
You have two persistent volume claims and only one persistent volume. 您有两个持久性卷声明,只有一个持久卷。 You can't bind two PVC to a PV.
您不能将两个PVC绑定到PV。 So in this case you need to add another PV and another PVC to the manifests.
因此,在这种情况下,您需要将另一个PV和另一个PVC添加到清单中。
You can read more about it here . 你可以在这里阅读更多相关信息。
A PersistentVolume (PV) is an atomic abstraction.
PersistentVolume(PV)是一种原子抽象。 You can not subdivide it across multiple claims.
您无法在多个声明中细分它。
More information about Persistent Volumes and how they work can be found in the official documentation . 有关Persistent Volumes及其工作原理的更多信息,请参阅官方文档 。
Also if you are trying to deploy PostgresSQL here is a good guide on how to do that. 此外,如果您尝试部署PostgresSQL, 这是一个很好的指导如何做到这一点。 And another one which will be easier as it is using managed Kubernetes service - how to run HA PostgreSQL on GKE .
另一个使用托管Kubernetes服务会更容易 - 如何在GKE上运行HA PostgreSQL 。
api-initdb-pv-claim-two pvc doesnt exist. api-initdb-pv-claim-two pvc不存在。
you need to create pv's and bound it using one pvc each 你需要创建pv并使用每个pvc绑定它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.