<p>We use the method in the first code block in java, but I don't see a corresponding method in the <a href="https://www.rubydoc.info/gems/google-cloud-storage/0.24.0/Google%2FCloud%2FStorage.new" rel="nofollow noreferrer">rails documentation</a>, Only the second code block:</p>

<p><code>Storage storage = StorageOptions.getDefaultInstance().getService();</code></p>

<pre><code>storage = Google::Cloud::Storage.new(
  project: "my-todo-project",
  keyfile: "/path/to/keyfile.json"
)
</code></pre>

<p>If we use an application specific service account in the kubernetes cluster. How do we configure the Rails application to work in the local developer environment and also run with a k8s cluster?</p>

<p>Also, I would prefer not to use a project_id and a keyfile to initialize, since I will have to manage multiple such JSON files during the initialization process in dev, qa, staging, production environments.</p>

<p>Before moving your app to multiple environments, you should set up your deployment pipeline which will handle how your app is configured for different environments, including configuration of service accounts. </p>

<p>Below you can find two official google cloud documentations on how to do it, plus one example in gitlab, so you can follow what better suits you.</p>

<p><a href="https://cloud.google.com/solutions/continuous-delivery-jenkins-kubernetes-engine" rel="nofollow noreferrer">Continuous deployment to Google Kubernetes Engine using Jenkins</a></p>

<p><a href="https://cloud.google.com/solutions/continuous-delivery-spinnaker-kubernetes-engine" rel="nofollow noreferrer">Continuous Delivery Pipelines with Spinnaker and Google Kubernetes Engine</a></p>

<p><a href="https://github.com/GoogleCloudPlatform/continuous-deployment-on-kubernetes" rel="nofollow noreferrer">Git Lab - continuous-deployment-on-kubernetes</a></p>

<p>Also, regarding the parameters of instantiation of the cloud storage object, as you can see on the same documentation you provided at your question, the project parameter is the identifier of your storage in the cloud, so if you do not set that your app will not be able to find it. For the Keyfile, it is what allow your service account to authenticate, so you can't make it work without it as well.</p>

<p>I hope This information helped you.</p>
