Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 未创建Kubectl吊舱_Kubernetes_Google Kubernetes Engine - Fatal编程技术网

Kubernetes 未创建Kubectl吊舱

Kubernetes 未创建Kubectl吊舱,kubernetes,google-kubernetes-engine,Kubernetes,Google Kubernetes Engine,试图在GKE的集群中创建POD。有一个docker容器,其中包含一些python代码,还有一个sidecar容器来访问sql数据库。以前的部署工作得很好,但是几周后我尝试用kubectl apply-f file_name.yaml重新部署 吊舱被临时创建为“挂起”状态,15秒后消失。每次都会发生。我无法访问日志。kubectl get pods在15秒后也不会返回任何结果。 不知道从这里到哪里去。。。任何帮助都将不胜感激 apiVersion: v1 kind: Pod metadata:

试图在GKE的集群中创建POD。有一个docker容器,其中包含一些python代码,还有一个sidecar容器来访问sql数据库。以前的部署工作得很好,但是几周后我尝试用kubectl apply-f file_name.yaml重新部署

吊舱被临时创建为“挂起”状态,15秒后消失。每次都会发生。我无法访问日志。kubectl get pods在15秒后也不会返回任何结果。 不知道从这里到哪里去。。。任何帮助都将不胜感激

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/limit-ranger: 'LimitRanger plugin set: cpu request for container
      pyxy-web-v1'
  creationTimestamp: "2020-05-14T00:38:09Z"
  labels:
    run: pyxy-web-v1
  name: pyxy-web-v1
  namespace: default
  resourceVersion: "1215073"
  selfLink: /api/v1/namespaces/default/pods/pyxy-web-v1
  uid: *omitted
spec:
  containers:
  - image: gcr.io/my-project-{*omitted}/pyxy-web:latest
    imagePullPolicy: Always
    name: pyxy-web-v1
    ports:
    - containerPort: 8080
      protocol: TCP
    env:
    - name: DB_USER
      valueFrom:
        secretKeyRef:
          name: cloudsql-db-credentials
          key: *omitted
    - name: DB_PASS
      valueFrom:
        secretKeyRef:
          name: cloudsql-db-credentials
          key: *omitted
    resources:
      requests:
        cpu: 100m
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-94bct
      readOnly: true

  - name: cloudsql-proxy
    image: gcr.io/cloudsql-docker/gce-proxy:1.16
    command: ["/cloud_sql_proxy",
              "-instances=my-project-{*omitted}:us-central1:routing-app-v1=tcp:3306",
              # If running on a VPC, the Cloud SQL proxy can connect via Private IP. See:
              # https://cloud.google.com/sql/docs/mysql/private-ip for more info.
              # "-ip_address_types=PRIVATE",
              "-credential_file=/secrets/cloudsql/credentials.json"]
    # [START cloudsql_security_context]
    securityContext:
      runAsUser: 2  # non-root user
      allowPrivilegeEscalation: false
    volumeMounts:
    - name: cloudsql-instance-credentials
      mountPath: /secrets/cloudsql
      readOnly: true

  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: gke-pyxy-cluster-default-pool-{*omitted}
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 180
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - name: default-token-94bct
    secret:
      defaultMode: 420
      secretName: default-token-94bct
  - name: cloudsql-instance-credentials
    secret:
      secretName: cloudsql-instance-credentials
在15秒长的等待期间,kubectl Descripte pods返回以下信息

Name:         pyxy-web-v1
Namespace:    default
Priority:     0
Node:         gke-pyxy-cluster-default-pool-{*omitted}/
Labels:       run=pyxy-web-v1
Annotations:  kubernetes.io/limit-ranger: LimitRanger plugin set: cpu request for container cloudsql-proxy
Status:       Pending
IP:           
IPs:          <none>
Containers:
  pyxy-web-v1:
    Image:      gcr.io/my-project-{*omitted}/pyxy-web:latest
    Port:       8080/TCP
    Host Port:  0/TCP
    Requests:
      cpu:  100m
    Environment:
      DB_USER:  <set to the key '*omitted' in secret 'cloudsql-db-credentials'>  Optional: false
      DB_PASS:  <set to the key '*omitted' in secret 'cloudsql-db-credentials'>  Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-94bct (ro)
  cloudsql-proxy:
    Image:      gcr.io/cloudsql-docker/gce-proxy:1.16
    Port:       <none>
    Host Port:  <none>
    Command:
      /cloud_sql_proxy
      -instances=my-project-{*omitted}:us-central1:routing-app-v1=tcp:3306
      -credential_file=/secrets/cloudsql/credentials.json
    Requests:
      cpu:        100m
    Environment:  <none>
    Mounts:
      /secrets/cloudsql from cloudsql-instance-credentials (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-94bct (ro)
Volumes:
  default-token-94bct:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-94bct
    Optional:    false
  cloudsql-instance-credentials:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  cloudsql-instance-credentials
    Optional:    false
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>
名称:pyxy-web-v1
名称空间:默认值
优先级:0
节点:gke pyxy集群默认池-{*省略}/
标签:run=pyxy-web-v1
注释:kubernetes.io/limit-ranger:LimitRanger插件集:容器cloudsql代理的cpu请求
状态:待定
知识产权:
IPs:
容器:
pyxy-web-v1:
Image:gcr.io/my project-{*省略}/pyxy-web:latest
端口:8080/TCP
主机端口:0/TCP
请求:
中央处理器:100米
环境:
DB_用户:可选:false
DB_PASS:可选:false
挂载:
/来自default-token-94bct(ro)的var/run/secrets/kubernetes.io/serviceCount
cloudsql代理:
图片:gcr.io/cloudsqldocker/gce proxy:1.16
端口:
主机端口:
命令:
/云sql代理
-instances=my project-{*省略}:us-central1:routing-app-v1=tcp:3306
-凭证文件=/secrets/cloudsql/credentials.json
请求:
中央处理器:100米
环境:
挂载:
/来自cloudsql实例凭据(ro)的机密/cloudsql
/来自default-token-94bct(ro)的var/run/secrets/kubernetes.io/serviceCount
卷数:
default-token-94bct:
类型:Secret(由Secret填充的卷)
SecretName:default-token-94bct
可选:false
cloudsql实例凭据:
类型:Secret(由Secret填充的卷)
SecretName:cloudsql实例凭据
可选:false
QoS等级:Burstable
节点选择器:
容差:node.kubernetes.io/未就绪:不执行300秒
node.kubernetes.io/不可访问:不执行300秒
活动:
然而,在这段时间之后,它又回来了 “在默认命名空间中找不到资源。”

Answer Pod规范中有一个节点名,该节点已不在集群中(由于升级)。也就是说,
pod.spec.nodeName
是错误的

kubectl解释pod.spec

   nodeName <string>
     NodeName is a request to schedule this pod onto a specific node. If it is
     non-empty, the scheduler simply schedules this pod onto that node, assuming
     that it fits resource requirements.

请在相关名称空间中提供
kubectl description pods
kubectl日志的输出。“描述”命令将显示与pod相关的事件。您可以在相同名称空间中对replicaset执行相同的操作您确定没有选择
run:pyxy-web-v1
标签的replicaset或守护程序吗?这种行为很奇怪,我只能通过一个控制器来解释,因为复制副本数量超过了定义的限制,所以导致Pod删除。@Serge非常感谢。在15秒的时间间隔内,我检查了日志,发现节点名称与我的节点池不匹配,它必须已升级。现在我更正了节点名称,它再次运行良好。对于其他所有人,get logs返回的错误是:“来自服务器的错误(未找到):pods”gke-pyxy-cluster-default-pool-94aa0302-pm35“未找到”太好了,谢谢您提供的信息。我添加了一个答案,供任何人阅读。
Error from server (NotFound): pods "gke-pyxy-cluster-default-pool-94aa0302-pm35" not found