in Education by
I have Django application deployed on Kubernetes Engine following this tutorial - https://cloud.google.com/python/django/kubernetes-engine. When I'm trying to make database request I'm getting this error: OperationalError at /admin/login/ (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0") Request Method: POST Request URL: [MY_URL] Django Version: 2.1.5 Exception Type: OperationalError Exception Value: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0") Exception Location: /env/lib/python3.6/site-packages/MySQLdb/connections.py in __init__, line 164 Python Executable: /env/bin/python3 Python Version: 3.6.8 Python Path: ['/home/vmagent/app', '/env/bin', '/env/lib/python36.zip', '/env/lib/python3.6', '/env/lib/python3.6/lib-dynload', '/opt/python3.6/lib/python3.6', '/env/lib/python3.6/site-packages'] Server time: Fri, 22 Mar 2019 14:41:35 +0000 There're a lot of similar questions, however, I've tried everything and haven't found exactly my case. I can connect using very same Cloud SQL proxy on my local PC and it works perfectly. I can add 0.0.0.0/0 to Cloud SQL allowed networks and connect directly from Django and it works perfectly. Here's my django settings for database: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'polls', 'USER': os.getenv('DATABASE_USER'), 'PASSWORD': os.getenv('DATABASE_PASSWORD'), 'HOST': '127.0.0.1', 'PORT': '3306', } } And my k8s deployment yaml: apiVersion: extensions/v1beta1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "3" creationTimestamp: 2019-03-22T01:02:36Z generation: 4 labels: app: polls name: polls namespace: default resourceVersion: "305840" selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/polls uid: 2ead6fa6-4c3e-11e9-9e47-42010a800102 spec: progressDeadlineSeconds: 2147483647 replicas: 3 revisionHistoryLimit: 10 selector: matchLabels: app: polls strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: metadata: creationTimestamp: null labels: app: polls revision: "1" spec: containers: - env: - name: DATABASE_USER valueFrom: secretKeyRef: key: username name: cloudsql - name: DATABASE_PASSWORD valueFrom: secretKeyRef: key: password name: cloudsql image: gcr.io/fcul-vova/polls imagePullPolicy: Always name: polls-app ports: - containerPort: 8080 protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File - command: - /cloud_sql_proxy - --dir=/cloudsql - -instances=fcul-vova:europe-west1:polls-instance=tcp:0.0.0.0:3306 - -credential_file=/secrets/cloudsql/credentials.json image: gcr.io/cloudsql-docker/gce-proxy:1.12 imagePullPolicy: IfNotPresent name: cloudsql-proxy resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /secrets/cloudsql name: cloudsql-oauth-credentials readOnly: true - mountPath: /etc/ssl/certs name: ssl-certs - mountPath: /cloudsql name: cloudsql dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 volumes: - name: cloudsql-oauth-credentials secret: defaultMode: 420 secretName: cloudsql-oauth-credentials - hostPath: path: /etc/ssl/certs type: "" name: ssl-certs - emptyDir: {} name: cloudsql status: availableReplicas: 3 conditions: - lastTransitionTime: 2019-03-22T01:04:53Z lastUpdateTime: 2019-03-22T01:04:53Z message: Deployment has minimum availability. reason: MinimumReplicasAvailable status: "True" type: Available observedGeneration: 4 readyReplicas: 3 replicas: 3 updatedReplicas: 3 JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by

Related questions

0 votes
    I got this question regarding web server (such as nginx, Cherokee or Oracle iPlanet) and Java containers ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    i am working on a MVC project in java. For my operation I use database many times. many times my ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have an application on GKE that I wish to be available via HTTPS only, so I have gotten a signed ... to the kubernetes cluster? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I have a script which loops over tables and fields doing a find and replace. The script takes around ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    Which value of Socket.readyState atribute of WebSocket indicates that the connection is established and communication is possible? A - 0 B - 1 C - 2 D - 3...
asked Dec 2, 2020 in Technology by JackTerrance
0 votes
    I have a custom server control that loads data from a web service into a GridView. Works fine on ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I have a custom server control that loads data from a web service into a GridView. Works fine on ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I have a custom server control that loads data from a web service into a GridView. Works fine on ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    What is the actual difference between Google Compute Engine, App Engine and Container Engine in Google Cloud Compute ... three engines? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I have neo4j-server installed on remote linux server. This server using nginx and has virtual host. Here is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 5, 2022 in Education by JackTerrance
0 votes
    I am building a plugin for a web application in java which is running on Tomcat and behind a apache ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I am building a plugin for a web application in java which is running on Tomcat and behind a apache ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    I've got a Node.js powered site that I'm running on Amazon Elastic Beanstalk. My Node.js app listens on port ... to my site via HTTPS. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
0 votes
    What happens when Intercept is off? A.) The request will hit the server B.) The request will hit the proxy C.) Hit the proxy...
asked Apr 29, 2021 in Technology by JackTerrance
...