Stay organized with collections
Save and categorize content based on your preferences.
This guide shows you how to run an App Engine flexible environment app on GKE.
To run your app on GKE, you need to create a Dockerfile for
it, build a container with Cloud Build, and then run that container in
GKE. No code changes are required.
Before you begin
Before following the instructions on this page, take the following steps:
Verify that your app deploys and runs successfully in the App Engine flexible environment.
In these instructions, you'll use the same project that you used for your
App Engine app. You can always create and use a new project, if you want.
Alternatively, you can use
Cloud Shell, which comes with the
gcloud CLI, git, and other pre-installed
features, such as language
support, tools, and editors.
Replace [YOUR-PROJECT-ID] with the project ID of your GKE project, and replace [YOUR-CONTAINER-NAME] with the name of the container you want to use for your app container.
Wait for the container to build: it may take awhile. When it finishes successfully, it shows a message like this one:
Created [https://cloudbuild.googleapis.com/v1/projects/YOUR-PROJECT-ID/builds/xxxxxxx-xxxx-xxx-xxx-xxxxxxxxxxxx].
Logs are permanently available at [https://console.developers.google.com/logs/viewer?resource=build&project=YOUR-PROJECT-ID&filters=text:xxxx-xxx-xxx-xxxxxxxxxxxx]].
ID CREATE_TIME DURATION SOURCE IMAGES STATUS
xxxxxxx-xxxx-xxx-xxx-xxxxxxxxxxxx 2017-03-04T00:42:10+00:00 1M32S gs://YOUR-PROJECT-ID_cloudbuild/source/xxxxxxx.08.tgz gcr.io/YOUR-PROJECT-ID/YOUR-CONTAINER-NAME SUCCESS<
Note the container name: you need to specify this when you run it in GKE.
Replace [YOUR-DEPLOYMENT-NAME] with the name you want to use for your
deployment, replace [YOUR-PROJECT-ID] with your GKE project
ID, and replace [YOUR-CONTAINER-NAME] with the name of the container you
created for your app.
Replace [YOUR-DEPLOYMENT-NAME] with the name you used in the previous steps. You
may need to wait several minutes before the external IP is viewable.
View the external IP address for your app:
kubectl get service [YOUR-DEPLOYMENT-NAME]
Replace [YOUR-DEPLOYMENT-NAME] with the name you used in the previous
steps. If the EXTERNAL IP field is empty, wait for awhile, then re-invoke the
command.
View the app running in GKE:
http://EXTERNAL-IP:8080
Replace EXTERNAL-IP with the external IP address you obtained in the
previous step.
You've successfully deployed and run your App Engine app on GKE!
What's next
You may want to learn more about Kubernetes and the kubectl command.
Google Kubernetes Engine uses Kubernetes for container management, deployment and
scaling. More information on Kubernetes is available on the external
Kubernetes site.
This guide uses kubectl, the command line interface for managing
Kubernetes clusters. More information on kubectl is available in the
kubectl reference.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis guide outlines how to migrate an App Engine flexible environment application to Google Kubernetes Engine (GKE) without any code modifications.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves creating a Dockerfile for the app, building a container using Cloud Build, and then deploying and running that container within GKE.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, users need to enable the necessary GKE and Cloud Build APIs, as well as have the Google Cloud CLI, \u003ccode\u003ekubectl\u003c/code\u003e, and \u003ccode\u003egit\u003c/code\u003e installed and set up correctly.\u003c/p\u003e\n"],["\u003cp\u003eRunning the app in GKE requires creating a cluster, setting the compute zone, authorizing the \u003ccode\u003ekubectl\u003c/code\u003e tool, creating a deployment, exposing the deployment for public access, and viewing the external IP address.\u003c/p\u003e\n"],["\u003cp\u003eThe guide emphasizes that once complete, your App Engine app will be running successfully on GKE, with additional resources available to learn more about Kubernetes and the \u003ccode\u003ekubectl\u003c/code\u003e command.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nGo Java Node.js PHP Python Ruby .NET Custom\n\nThis guide shows you how to run an App Engine flexible environment app on GKE.\nTo run your app on GKE, you need to create a Dockerfile for\nit, build a container with Cloud Build, and then run that container in\nGKE. No code changes are required.\n\nBefore you begin\n\nBefore following the instructions on this page, take the following steps:\n\n1. Verify that your app deploys and runs successfully in the App Engine flexible environment.\n\n2. In these instructions, you'll use the same project that you used for your\n App Engine app. You can always create and use a new project, if you want.\n\n3.\n\n\n Enable the GKE, Cloud Build APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com,cloudbuild.googleapis.com&redirect=https://console.cloud.google.com)\n\n \u003cbr /\u003e\n\n4. Download and install the Google Cloud CLI and then initialize the gcloud tool:\n [Download the Google Cloud SDK](/sdk/docs).\n\n Alternatively, you can use\n [Cloud Shell](/shell/docs/launching-cloud-shell), which comes with the\n gcloud CLI, `git`, and other pre-installed\n [features](/shell/docs/how-cloud-shell-works#tools), such as language\n support, tools, and editors.\n5. Install the `kubectl` command-line tool:\n\n gcloud components install kubectl\n\n6. [Download and install git](https://git-scm.com/).\n\nCreating a Dockerfile for your App Engine app\n\nBuild a Dockerfile for your app as described in\n[Create a Dockerfile](/appengine/docs/flexible/custom-runtimes/build#docker).\n\nBuilding a container from the Dockerfile\n\nTo build a container:\n\n1. Ensure you are in the App Engine app directory that contains the Dockerfile.\n\n2. Change the default project used by the `gcloud` tool so it points to the project you are using to run your app in GKE:\n\n gcloud config set project [YOUR-PROJECT-ID]\n\n Replace `[YOUR-PROJECT-ID]` with your GKE project ID.\n3. Build the container using the following command:\n\n gcloud builds submit --tag gcr.io/[YOUR-PROJECT-ID]/[YOUR-CONTAINER-NAME] .\n\n Replace `[YOUR-PROJECT-ID]` with the project ID of your GKE project, and replace `[YOUR-CONTAINER-NAME]` with the name of the container you want to use for your app container.\n4. Wait for the container to build: it may take awhile. When it finishes successfully, it shows a message like this one:\n\n Created [https://cloudbuild.googleapis.com/v1/projects/YOUR-PROJECT-ID/builds/xxxxxxx-xxxx-xxx-xxx-xxxxxxxxxxxx].\n Logs are permanently available at [https://console.developers.google.com/logs/viewer?resource=build&project=YOUR-PROJECT-ID&filters=text:xxxx-xxx-xxx-xxxxxxxxxxxx]].\n\n ID CREATE_TIME DURATION SOURCE IMAGES STATUS\n xxxxxxx-xxxx-xxx-xxx-xxxxxxxxxxxx 2017-03-04T00:42:10+00:00 1M32S gs://YOUR-PROJECT-ID_cloudbuild/source/xxxxxxx.08.tgz gcr.io/YOUR-PROJECT-ID/YOUR-CONTAINER-NAME SUCCESS\u003c\n\n Note the container name: you need to specify this when you run it in GKE.\n\nRunning your app in GKE\n\nTo run the container that holds your app:\n\n1. Create the cluster (this may take a few minutes):\n\n gcloud container clusters create [YOUR-CLUSTER-NAME]\n\n Replace `[YOUR-CLUSTER-NAME]` with the name you want to give the cluster.\n2. From the command line, set your compute zone:\n\n gcloud config set compute/zone us-central1-b\n\n3. Make sure the GKE `kubectl` tool is authorized:\n\n gcloud container clusters get-credentials [YOUR-CLUSTER-NAME]\n\n Follow the prompts to authorize the tool.\n4. Run the container that holds your app:\n\n kubectl create deployment [YOUR-DEPLOYMENT-NAME] --image=gcr.io/[YOUR-PROJECT-ID]/[YOUR-CONTAINER-NAME]\n\n Replace `[YOUR-DEPLOYMENT-NAME]` with the name you want to use for your\n deployment, replace `[YOUR-PROJECT-ID]` with your GKE project\n ID, and replace `[YOUR-CONTAINER-NAME]` with the name of the container you\n created for your app.\n5. Expose the container for public access:\n\n kubectl expose deployment [YOUR-DEPLOYMENT-NAME] --type=\"LoadBalancer\" --port=8080\n\n Replace `[YOUR-DEPLOYMENT-NAME]` with the name you used in the previous steps. You\n may need to wait several minutes before the external IP is viewable.\n | **Note:** The **type=\"LoadBalancer\"** option in `kubectl` requests that Google Cloud Platform provision a load balancer for your container, which is billed per the regular Load Balancer pricing.\n6. View the external IP address for your app:\n\n kubectl get service [YOUR-DEPLOYMENT-NAME]\n\n Replace `[YOUR-DEPLOYMENT-NAME]` with the name you used in the previous\n steps. If the `EXTERNAL IP` field is empty, wait for awhile, then re-invoke the\n command.\n7. View the app running in GKE:\n\n http://EXTERNAL-IP:8080\n\n Replace `EXTERNAL-IP` with the external IP address you obtained in the\n previous step.\n\nYou've successfully deployed and run your App Engine app on GKE!\n\nWhat's next\n\nYou may want to learn more about Kubernetes and the `kubectl` command.\nGoogle Kubernetes Engine uses Kubernetes for container management, deployment and\nscaling. More information on Kubernetes is available on the external\n[Kubernetes site](http://kubernetes.io/).\n\nThis guide uses `kubectl`, the command line interface for managing\nKubernetes clusters. More information on `kubectl` is available in the\n[kubectl reference](https://kubernetes.io/docs/reference/kubectl/)."]]