Nori
Nori

Reputation: 3022

How to use Google Cloud Debugger on Cloud Run with Django

I'm trying to use Google Cloud Debugger on Cloud Run with Django. I red this document.

https://cloud.google.com/debugger/docs/setup/python

What I did.

  1. I turned on Debugger in google cloud.
  2. Install google-python-cloud-debugger.
  3. I created source-context.json same directory with models.py
  4. I add this code in manage.py
try:
      import googleclouddebugger
      googleclouddebugger.enable()

    except ImportError:
      pass

I update container of Google Cloud Run. How ever I cant find any application in Debugger

I imported my source code from GitHub. I can see my code in Debugger. However, I couldn't check break point in Debugger page.

How to debug Django on Clod Run? Please help me.

Update

I did this 2 step.

  1. Add logger Cloud Debugger Agent rights to the service account from IAM.

  2. Connect GitHub repository with Google Cloud Source

Cloud Debugger works on local environment. However it doesn't work in Cloud Run.

This picture has only local application. I can't find Cloud Run application. enter image description here

This is my yaml file. (I'm using Cloud Run as full managed mode)

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: my_app
  namespace: '135253772466'
  selfLink: /apis/serving.knative.dev/v1/namespaces/135253772466/services/my_app
  uid: 61b4ac55-4aab-4d33-801d-d21b0d116ea4
  resourceVersion: AAWmjubgiTg
  generation: 176
  creationTimestamp: '2020-04-14T12:38:39.484473Z'
  labels:
    cloud.googleapis.com/location: asia-northeast1
  annotations:
    run.googleapis.com/client-name: gcloud
    serving.knative.dev/creator: [email protected]
    serving.knative.dev/lastModifier: [email protected]
    client.knative.dev/user-image: gcr.io/my_project/my_app
    run.googleapis.com/client-version: 291.0.0
spec:
  traffic:
  - percent: 100
    latestRevision: true
  template:
    metadata:
      name: my_app-00176-wud
      annotations:
        run.googleapis.com/client-name: gcloud
        client.knative.dev/user-image: gcr.io/my_project/my_app
        run.googleapis.com/client-version: 291.0.0
        autoscaling.knative.dev/maxScale: '1000'
    spec:
      timeoutSeconds: 900
      serviceAccountName: [email protected]
      containerConcurrency: 80
      containers:
      - image: gcr.io/my_project/my_app
        ports:
        - containerPort: 8080
        env:
        - name: CLOUD_RUN_HOST
          value: my_app-u3ljntrlma-an.a.run.app
        resources:
          limits:
            cpu: 1000m
            memory: 2048Mi
status:
  conditions:
  - type: Ready
    status: 'True'
    lastTransitionTime: '2020-05-26T15:39:32.595Z'
  - type: ConfigurationsReady
    status: 'True'
    lastTransitionTime: '2020-05-26T15:39:25.640Z'
  - type: RoutesReady
    status: 'True'
    lastTransitionTime: '2020-05-26T15:39:32.595Z'
  observedGeneration: 176
  traffic:
  - revisionName: my_app-00176-wud
    percent: 100
    latestRevision: true
  latestReadyRevisionName: my_app-00176-wud
  latestCreatedRevisionName: my_app-00176-wud
  address:
    url: https://my_app-u3ljntrlma-an.a.run.app
  url: https://my_app-u3ljntrlma-an.a.run.app


Upvotes: 2

Views: 310

Answers (0)

Related Questions