Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.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
Python Django就绪探测失败_Python_Django_Kubernetes - Fatal编程技术网

Python Django就绪探测失败

Python Django就绪探测失败,python,django,kubernetes,Python,Django,Kubernetes,我正在Django部署中实现RollingUpdate和就绪/活跃性探测 我创建了一个/healthz端点,它只返回OK和200作为响应代码 终结点正在按预期手动工作。然而,当库伯内特斯试图到达终点时,它就超时了。近端 Readiness probe failed: Get http://10.40.2.14:8080/v1/healthz/: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

我正在Django部署中实现RollingUpdate和就绪/活跃性探测

我创建了一个
/healthz
端点,它只返回OK和200作为响应代码

终结点正在按预期手动工作。然而,当库伯内特斯试图到达终点时,它就超时了。近端

Readiness probe failed: Get http://10.40.2.14:8080/v1/healthz/: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
但是从Django访问日志中,我可以清楚地看到它确实在周期性地查询这个端点,并且它正在重新调整字节数据和200字节作为响应

[api-prod-64bdff8d4-lcbtf api-prod] [pid: 14|app: 0|req: 34/86] 10.40.2.1 () {30 vars in 368 bytes} [Wed Jul  3 12:10:18 2019] GET /v1/healthz/ => generated 15 bytes in 3 msecs (HTTP/1.1 200) 5 headers in 149 bytes (1 switches on core 0)
[api-prod-64bdff8d4-lcbtf api-prod] [pid: 13|app: 0|req: 11/87] 10.40.2.1 () {30 vars in 368 bytes} [Wed Jul  3 12:10:52 2019] GET /v1/healthz/ => generated 15 bytes in 2 msecs (HTTP/1.1 200) 5 headers in 149 bytes (1 switches on core 0)
这是我的yaml文件

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: api-prod
  labels:
    app: api-prod
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 1
  template:
    metadata:
      labels:
        app: api-prod
    spec:    
      # Minikube Local Pull Secrets
      imagePullSecrets: 
        - name: gcr-json-key

      containers:
      - name: api-prod
        image: gcr.io/example/api-prod
        imagePullPolicy: IfNotPresent     
        readinessProbe:
          httpGet:
             path: /v1/healthz/
             port: 8080
          initialDelaySeconds: 10
          periodSeconds: 60
          successThreshold: 1
        livenessProbe:
          httpGet:
             path: /v1/healthz/
             port: 8080
          initialDelaySeconds: 10
          periodSeconds: 60
          successThreshold: 1     
        env:
            # [START cloudsql_secrets]
            - name: DATABASE_USER
              valueFrom:
                secretKeyRef:
                  name: cloudsql-prod
                  key: username
            - name: DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cloudsql-prod
                  key: password
            # [END cloudsql_secrets]
        ports:
        - containerPort: 8080

      # [START proxy_container]
      - image: gcr.io/cloudsql-docker/gce-proxy:1.05
        name: cloudsql-proxy
        command: ["/cloud_sql_proxy", "--dir=/cloudsql",
                  "-instances=redacted:somewhere:somedb=tcp:5432",
                  "-credential_file=/secrets/cloudsql/credentials.json"]
        volumeMounts:
          - name: cloudsql-oauth-credentials
            mountPath: /secrets/cloudsql
            readOnly: true
          - name: ssl-certs
            mountPath: /etc/ssl/certs
          - name: cloudsql
            mountPath: /cloudsql
      # [END proxy_container] 



      # [START volumes]
      volumes:
        - name: cloudsql-oauth-credentials
          secret:
            secretName: cloudsql-oauth-credentials
        - name: ssl-certs
          hostPath:
            path: /etc/ssl/certs
        - name: cloudsql
          emptyDir:
      # [END volumes]        
# [END kubernetes_deployment]

---

apiVersion: v1
kind: Service
metadata:
  name: api-prod
  labels:
    app: api-prod
spec:
  type: ClusterIP
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: api-prod
# [END service]


请求到哪里去了?

您是否尝试添加
timeoutSeconds:3
,因为默认设置为1?@Crou未尝试,请求需要1-2毫秒。我不认为增加超时时间会有帮助。探测器不知何故无法到达端点。你能发布整个部署以便我测试它吗?@Crou添加了整个部署文件。我有一个疑点,django
ALLOWED_HOSTS
vs.在请求探测端点时没有设置主机头。那么问题是什么?