Deploying endpoints app into appengine with appcfg.py - google-app-engine

The documentation describes how to deploy endpoints application with gcloud tool but is it possible to deploy the app with appcfg.py?
What I'd like is to use this command:
appcfg.py update [YOUR_APP_DIR] -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID]
And don't have to edit the app.yaml file to set a new value for ENDPOINTS_SERVICE_VERSION variable every time I need to deploy a new version.
If I understand correctly YOUR_VERSION_ID application version is not the same as ENDPOINTS_SERVICE_VERSION but where this difference is important?

Related

Golang Cloud SDK - gcloud app deploy cannot find import package

according to the official documentation for Google App Engine Standard environment (Go API) the "preferred tooling to deploy a project" is now the Cloud SDK and so we moved to gcloud from goapp.
We are unable to deploy Go projects to GAE because all the sub-packages of every given project can't be found at "deploy time".
The typical folder structure that we have been using for every GAE project was as follows:
-project-name
--app.yaml
--main.go
--assets
---package1
---package2
When global libraries were put in the system GOPATH everything worked smoothly.
Running gcloud app deploy we now get this:
You are about to deploy the following services:
- yourproject/default/123456789 (from [/Path/to/app.yaml])
Deploying to URL: [https://yourproject.appspot.com]
Do you want to continue (Y/n)? Y
Beginning deployment of service [default]...
ERROR: (gcloud.app.deploy) Staging command [/path/to/yourproject/app.yaml /var/folders/b6/5ydn0wdn64jd32sxzzz48b7c0000gn/T/tmpbd4oiG] failed with return code [1].
------------------------------------ STDOUT ------------------------------------
------------------------------------ STDERR ------------------------------------
2017/03/24 10:25:58 failed analyzing /path/to/yourproject: cannot find package "yourpackage" in any of:
($GOROOT not set)
/path/to/gopath/src/yourpackage (from $GOPATH)
GOPATH: /path/to/gopath
--------------------------------------------------------------------------------
while dev_appserver.py works perfectly keeping the same folder structure.
Did we miss something?
How can we deploy to Google App Engine Standard environment using gcloud?
If the project structure needs to be changed: how? Is there official documentation about it?
Thanks in advance,
Edit -- Further infos:
Luigi-Mac-Pro:path/to/yourproject distudio$ gcloud version
Google Cloud SDK 148.0.0
app-engine-go
app-engine-go-darwin-x86_64 1.9.50
app-engine-python 1.9.50
bq 2.0.24
bq-nix 2.0.24
core 2017.03.17
core-nix 2016.11.07
gcloud
gcloud-deps 2017.03.17
gcloud-deps-darwin-x86_64 2017.02.21
gsutil 4.23
gsutil-nix 4.22
Google recommends keeping your dependencies outside of the app directory, and using GOPATH to refer them. In your case, that would mean doing the following:
-project-name
--app.yaml
--main.go
where main.go contains
import (
"package1"
"package2"
)
And somewhere else:
-my_packages
--src
---package1
---package2
And then set GOPATH environment variable to path/to/my_packages prior to running dev_appserver and gcloud app deploy.
For the future
We are working out the long term solution for properly vendoring packages inside your app directory – likely using Go's future native package manager. I'm sorry to say that we don't have a good way of supporting sub-packages for gcloud app deploy. This was an unfortunate side effect of compatibility with the App Engine Flexible environment.

How to update queues with gcloud?

I previously was using appcfg.py to deploy my (python) applications on Google AppEngine, but I recently switched to the gcloud command.
For updating the queues, I was doing :
/opt/google/google_appengine/appcfg.py -A project-id update_queues .
But now with ‘gcloud‘ I don't know how I can do that?
For information, here's how I deploy a new version now :
gcloud app deploy --project project-id app.yaml
Thank you :)
The cloud sdk deploy command supports multiple config files index.yaml, queue.yaml, dispatch.yaml, dos.yaml, cron.yaml
gcloud app deploy [DEPLOYABLES …]
[DEPLOYABLES …]
The yaml files for the services or configurations you want to deploy. If not given, defaults to app.yaml in the current directory. If that is not found, attempts to automatically generate necessary configuration files (such as app.yaml) in the current directory.
https://cloud.google.com/sdk/gcloud/reference/app/deploy
So:
gcloud app deploy app.yaml queue.yaml

Difference between 'goapp deploy' and 'appcf.py' to deploy my app on Google App Engine?

I don't understand the difference between
goapp deploy -application <YOUR_PROJECT_ID> myapp/
and
appcfg.py -A <YOUR_PROJECT_ID_> -V v1 update myapp/
when trying to deploy my app in google app engine. Can somebody enlighten me please?
Documented in Uploading, Downloading, and Managing a Go App:
goapp deploy wraps the appcfg.py python tool provided in the SDK. You can also invoke this tool directly if you need greater control over the deployment.
goapp deploy is equivalent to appcfg.py update myapp/.
These commands get application ID and other configuration from app.yaml automatically. You can use -application param of goapp, or -A of appcfg.py to override the application ID.
So goapp deploy calls appcfg.py under the hood, it is a convenient method to hide appcfg.py.
goapp deploy -application <YOUR_PROJECT_ID> myapp/
Deploys the application located in the myapp folder. Configuration will be read from the app.yaml file that must be at myapp/app.yaml. The command also overrides the application ID (if present in app.yaml), and <YOUR_PROJECT_ID> will be used instead.
appcfg.py -A <YOUR_PROJECT_ID> -V v1 update myapp/
This also deploys the application, but the -V overrides the version that may be present in myapp/app.yaml, and will use the version v1. -A is used to override the ID from app.yaml, will be <YOUR_PROJECT_ID> in this case.
goapp is a general tool for the whole Go-on-App-Engine workflow from build to deployment; you can use the same tool to install dependences (get), build your app, run locally (serve) and then deploy it (as well as run tests, format code, etc).
Some of these wrap other tools: goapp fmt probably just wraps gofmt, whilst goapp deploy just wraps appcfg.py update (see docs)

ERROR: (gcloud.preview.app) Invalid choice: 'run'

I'm trying to get the golang hello-world bigtable example running locally locally and running into this issue. When I run gcloud preview app run app.yaml from the bigtable-hello directory, I get the following error:
➜ bigtable-hello gcloud preview app run app.yaml
Usage: gcloud
preview app [optional flags] group may be
modules command may be deploy | gen-config
(BETA) This set of commands allows you to deploy your app, manage your existing deployments, and also run your app locally. These
commands replace their equivalents in the appcfg tool.
global flags: Run gcloud -h for a description of flags available
to all commands.
command groups: modules (BETA) View and manage your
App Engine modules.
commands: deploy (BETA) Deploy the local code
and/or configuration of
your app to App Engine. gen-config (BETA) Generate missing configuration files for a
source directory.
ERROR: (gcloud.preview.app) Invalid choice: 'run'.
Valid choices are [deploy, gen-config, gen-repo-info-file, instances,
modules, services, versions].
I've put the demo files into my local go directory like below:
app run is no longer part of the gcloud SDK as can be seen under all the possible command trees:
gcloud alpha has no app command group
gcloud app has no run command
gcloud beta has no run command
gcloud preview app has no app command group
This was removed with version 92.0.0 released on January 13, 2016. That changelog recommends using dev_appserver.py instead. An example can be found in Running the local development server.
> dev_appserver.py src/github.com/jamescharlesworth/bigtable-hello
Other flags and options can be found in dev_appserver.py's documentation in Local Development Server Options.

Appengine - Deployment appcfg.py vs git

I've recently started with Appengine and I'd been using the regular old deployment method using appcfg.py.
Now I want to start deployment using release pipelines. I created a pipeline in my Project settings, then authenticated myself in gcloud.
Now if I do gcloud init myproj-id, I should theoretically get the content of my project pulled from the server right? But that doesn't happen.
https://developers.google.com/cloud/sdk/gcloud/reference/init
If you have enabled push-to-deploy in the Cloud Console, one of the
things that gcloud init will do for you is cloning the Google-hosted
git repository associated with PROJECT
So, my questions:
Why is the content not pulled?
What happens if I push my project via git now? How would Appengine manage my previously deployed project via appcfg.py versus my git push'd project?
Why is the content not pulled?
Did you configure your repository by using the Configure your repository link at the top of the pipeline configuration page?
What happens if I push my project via git now? How would Appengine manage my previously deployed project via appcfg.py versus my git push'd project?
Unless you use different versions, App Engine won't make a difference; your git pushed project will overwrite your previous one.

Resources