首页 > 解决方案 > Connexion 拒绝和 CrashLoopBackOff 使用 Docker GraphQl 为容器运行循环

问题描述

我是 docker 新手,我遇到了这个错误我正在使用 AMZ 平台和 mongoDB 和 graphql 和 Docker 一切工作正常,因为我没有编写所有代码,而且我一直在运行和 CrashLoopBackOff :(我不知道为什么!这就是我得到的:

graphql-564c895966-25c2w   0/1     CrashLoopBackOff   9          20m
graphql-564c895966-6g64n   0/1     CrashLoopBackOff   9          20m

kubectl describe pod graphql-564c895966-25c2w:

Name:         graphql-564c895966-25c2w
Namespace:    default
Priority:     0
Node:         pool-g1r6uxpbs-3yjla/10.131.59.199
Start Time:   Thu, 25 Jun 2020 00:46:05 +0100
Labels:       app=graphql
              pod-template-hash=564c895966
Annotations:  <none>
Status:       Running
IP:           10.244.0.143
IPs:
  IP:           10.244.0.143
Controlled By:  ReplicaSet/graphql-564c895966
Containers:
  graphql:
    Container ID:   docker://05feb2a4feefbffcd31e23cd4b80fe5cdc3c6dbb5559a9372015ebdf789432b1
    Image:          fundinginvoicetech/gql:a917d80b5f276e8307e9993811f73569694fa56a
    Image ID:       docker-pullable://fundinginvoicetech/gql@sha256:805762b32727ce0cbd20250c35002419df189a79f492281b59681117c53273a7
    Port:           4000/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Thu, 25 Jun 2020 01:01:45 +0100
      Finished:     Thu, 25 Jun 2020 01:02:25 +0100
    Ready:          False
    Restart Count:  9
    Liveness:       http-get https://:https/healthz delay=15s timeout=40s period=10s #success=1 #failure=3
    Environment:
      NODE_ENV:                  production
      PORT:                      4000
      AWS_ACCESS_KEY_ID:         <set to the key 'amazonAccountId' in secret 'secrets'>  Optional: false
      AWS_SECRET_ACCESS_KEY:     <set to the key 'amazonSecret' in secret 'secrets'>     Optional: false
      SENTRY_DSN:                <set to the key 'sentryDsn' in secret 'secrets'>        Optional: false
      ELASTIC_APM_SECRET_TOKEN:  <set to the key 'logzToken' in secret 'secrets'>        Optional: false
      ELASTIC_APM_SERVER_URL:    <set to the key 'logzUrl' in secret 'secrets'>          Optional: false
      ELASTIC_APM_SERVICE_NAME:  <set to the key 'logzServiceName' in secret 'secrets'>  Optional: false
      AUTH_PUBLIC_KEY:           <set to the key 'authPublicKey' in secret 'secrets'>    Optional: false
      PRIVATE_KEY:               <set to the key 'privatekey' in secret 'cert'>          Optional: false
      CERTIFICATE:               <set to the key 'certificate' in secret 'cert'>         Optional: false
      CA_CERT:                   <set to the key 'ca' in secret 'cert'>                  Optional: false
      MONGO_CONNECT_URL:         <set to the key 'mongo' in secret 'databases'>          Optional: false
      POSTGRES_CONNECT_URL:      <set to the key 'pg' in secret 'databases'>             Optional: false
      ENGINE_API_KEY:            <set to the key 'apolloEngineAPI' in secret 'secrets'>  Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-m69fd (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-m69fd:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-m69fd
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                  From                           Message
  ----     ------     ----                 ----                           -------
  Normal   Scheduled  <unknown>            default-scheduler              Successfully assigned default/graphql-564c895966-25c2w to pool-g1r6uxpbs-3yjla
  Normal   Pulling    20m                  kubelet, pool-g1r6uxpbs-3yjla  Pulling image "fundinginvoicetech/gql:a917d80b5f276e8307e9993811f73569694fa56a"
  Normal   Pulled     20m                  kubelet, pool-g1r6uxpbs-3yjla  Successfully pulled image "fundinginvoicetech/gql:a917d80b5f276e8307e9993811f73569694fa56a"
  Normal   Created    18m (x4 over 20m)    kubelet, pool-g1r6uxpbs-3yjla  Created container graphql
  Normal   Started    18m (x4 over 20m)    kubelet, pool-g1r6uxpbs-3yjla  Started container graphql
  Warning  Unhealthy  18m (x9 over 20m)    kubelet, pool-g1r6uxpbs-3yjla  Liveness probe failed: Get https://10.244.0.143:4000/healthz: dial tcp 10.244.0.143:4000: connect: connection refused
  Normal   Killing    18m (x3 over 19m)    kubelet, pool-g1r6uxpbs-3yjla  Container graphql failed liveness probe, will be restarted
  Normal   Pulled     5m40s (x8 over 19m)  kubelet, pool-g1r6uxpbs-3yjla  Container image "fundinginvoicetech/gql:a917d80b5f276e8307e9993811f73569694fa56a" already present on machine
  Warning  BackOff    30s (x67 over 16m)   kubelet, pool-g1r6uxpbs-3yjla  Back-off restarting failed container

kubectl logs graphql-564c895966-6g64n

yarn run v1.22.4
$ node index.js
{"message":"Starting server with args []...","level":"info"}
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: only absolute urls are supported
    at /home/graphql/node_modules/node-fetch/index.js:54:10
    at new Promise (<anonymous>)
    at new Fetch (/home/graphql/node_modules/node-fetch/index.js:49:9)
    at Fetch (/home/graphql/node_modules/node-fetch/index.js:37:10)
    at module.exports (/home/graphql/node_modules/isomorphic-fetch/fetch-npm-node.js:8:19)
    at Object.<anonymous> (/home/graphql/index.js:88:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
{"message":"External IP 104.248.164.113","level":"info"}

这是我的 manifest.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: graphql
  namespace: default
  labels:
    app: graphql
spec:
  replicas: 2
  selector:
    matchLabels:
      app: graphql
  template:
    metadata:
      labels:
        app: graphql
    spec:
      containers:
        - name: graphql
          image: fundinginvoicetech/gql:$COMMIT_SHA1
          ports:
            - containerPort: 4000
              name: https
          livenessProbe:
            httpGet:
              path: /healthz
              port: https
              scheme: HTTPS
              httpHeaders:
                - name: $HEALTH_CHECK_HEADER
                  value: $HEALTH_CHECK_TOKEN
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 40
          env:
            - name: NODE_ENV
              value: "production"
            - name: PORT
              value: "4000"
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: amazonAccountId
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: amazonSecret
            - name: SENTRY_DSN
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: sentryDsn
            - name: ELASTIC_APM_SECRET_TOKEN
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: logzToken
            - name: ELASTIC_APM_SERVER_URL
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: logzUrl
            - name: ELASTIC_APM_SERVICE_NAME
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: logzServiceName
            - name: AUTH_PUBLIC_KEY
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: authPublicKey
            - name: PRIVATE_KEY
              valueFrom:
                secretKeyRef:
                  name: cert
                  key: privatekey
            - name: CERTIFICATE
              valueFrom:
                secretKeyRef:
                  name: cert
                  key: certificate
            - name: CA_CERT
              valueFrom:
                secretKeyRef:
                  name: cert
                  key: ca
            - name: MONGO_CONNECT_URL
              valueFrom:
                secretKeyRef:
                  name: databases
                  key: mongo
            - name: POSTGRES_CONNECT_URL
              valueFrom:
                secretKeyRef:
                  name: databases
                  key: pg
            - name: ENGINE_API_KEY
              valueFrom:
                secretKeyRef:
                  name: secrets
                  key: apolloEngineAPI
            - name: ENGINE_SCHEMA_TAG
              value: "production"
            - name: HEALTH_CHECK_HEADER
              value: $HEALTH_CHECK_HEADER
            - name: HEALTH_CHECK_TOKEN
              value: $HEALTH_CHECK_TOKEN
            - name: IP_AUTODETECTION_METHOD
              value: "interface=eth.*"
      imagePullSecrets:
        - name: regcred

请有人可以帮助我我找不到任何东西:((((((((((()))

标签: mongodbdockervue.jskubernetesgraphql

解决方案


好的,如果您尝试连接到 mongocluster,则需要使用此 uri:

mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]

例如:

独立(不是 mongo 数据库集群)

mongodb://mongodb0.example.com:27017

复制集

mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB

推荐阅读