title: How to set GOOGLE_APPLICATION_CREDENTIALS on GKE running through Kubernetes
body: <p>with the help of kubernetes I am running daily jobs on GKE, On a daily basis based on cron configured in kubernetes a new container spins up and try to insert some data into BigQuery.</p>
  
  <p>The setup that we have is we have 2 different projects in GCP in one project we maintain the data in BigQuery in other project we have all the GKE running so when GKE has to interact with different project resource my guess is I have to set an environment variable with name  GOOGLE_APPLICATION_CREDENTIALS which points to a service account json file, but since every day kubernetes is spinning up a new container I am not sure how and where I should set this variable.</p>
  
  <p>Thanks in Advance!</p>
  
  <h1>NOTE: this file is parsed as a golang template by the drone-gke plugin.</h1>
  
  <pre><code>---
  apiVersion: v1
  kind: Secret
  metadata:
    name: my-data-service-account-credentials
  type: Opaque
  data:
    sa_json: "bas64JsonServiceAccount"
  ---
  apiVersion: v1
  kind: Pod
  metadata:
    name: adtech-ads-apidata-el-adunit-pod
  spec:
    containers:
    - name: adtech-ads-apidata-el-adunit-container
      volumeMounts:
      - name: service-account-credentials-volume
       mountPath: "/etc/gcp"
       readOnly: true
    volumes:
    - name: service-account-credentials-volume
      secret:
        secretName: my-data-service-account-credentials
        items:
        - key: sa_json
          path: sa_credentials.json
  </code></pre>
  
  <hr>
  
  <h1>This is our cron jobs for loading the AdUnit Data</h1>
  
  <pre><code>apiVersion: batch/v2alpha1
  kind: CronJob
  metadata:
    name: adtech-ads-apidata-el-adunit
  spec:
    schedule: "*/5 * * * *"
    suspend: false
    concurrencyPolicy: Replace
    successfulJobsHistoryLimit: 10
    failedJobsHistoryLimit: 10
    jobTemplate:
      spec:
        template:
          spec:
            containers:
            - name: adtech-ads-apidata-el-adunit-container
              image: {{.image}}
              args:
              - -cp
              - opt/nyt/DFPDataIngestion-1.0-jar-with-dependencies.jar
              - com.nyt.cron.AdUnitJob
              env:
                - name: ENV_APP_NAME
                  value: "{{.env_app_name}}"
                - name: ENV_APP_CONTEXT_NAME
                  value: "{{.env_app_context_name}}"
                - name: ENV_GOOGLE_PROJECTID
                  value: "{{.env_google_projectId}}"
                - name: ENV_GOOGLE_DATASETID
                  value: "{{.env_google_datasetId}}"
                - name: ENV_REPORTING_DATASETID
                  value: "{{.env_reporting_datasetId}}"
                - name: ENV_ADBRIDGE_DATASETID
                  value: "{{.env_adbridge_datasetId}}"
                - name: ENV_SALESFORCE_DATASETID
                  value: "{{.env_salesforce_datasetId}}"
                - name: ENV_CLOUD_PLATFORM_URL
                  value: "{{.env_cloud_platform_url}}"
                - name: ENV_SMTP_HOST
                  value: "{{.env_smtp_host}}"
                - name: ENV_TO_EMAIL
                  value: "{{.env_to_email}}"
                - name: ENV_FROM_EMAIL
                  value: "{{.env_from_email}}"
                - name: ENV_AWS_USERNAME
                  value: "{{.env_aws_username}}"
                - name: ENV_CLIENT_ID
                  value: "{{.env_client_id}}"
                - name: ENV_REFRESH_TOKEN
                  value: "{{.env_refresh_token}}"
                - name: ENV_NETWORK_CODE
                  value: "{{.env_network_code}}"
                - name: ENV_APPLICATION_NAME
                  value: "{{.env_application_name}}"
                - name: ENV_SALESFORCE_USERNAME
                  value: "{{.env_salesforce_username}}"
                - name: ENV_SALESFORCE_URL
                  value: "{{.env_salesforce_url}}"
                - name: GOOGLE_APPLICATION_CREDENTIALS
                  value: "/etc/gcp/sa_credentials.json"
                - name: ENV_CLOUD_SQL_URL
                  valueFrom:
                    secretKeyRef:
                      name: secrets
                      key: cloud_sql_url
                - name: ENV_AWS_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: secrets
                      key: aws_password
                - name: ENV_CLIENT_SECRET
                  valueFrom:
                    secretKeyRef:
                      name: secrets
                      key: dfp_client_secret
                - name: ENV_SALESFORCE_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: secrets
                      key: salesforce_password
  
  
            restartPolicy: OnFailure
  </code></pre>
  
  <hr>