2015-09-09 wcdj
摘要:本文记录使用GCE(Google Container Engine)体验容器云服务的过程和方法。
(1)要申请一个Google账户。
(2)激活Google账单,即绑定支付信用卡,为使用Google的服务买单。激活过程中为了验证信用卡是否可用,需要支付1美元的费用。
激活支付地址:https://console.developers.google.com/billing?_ga=1.62759852.1080048005.1441690490
支付激活后,可以看到能够使用的一些服务,同时看到可以免费使用60天。
(3)激活Google API
激活后,可以使用如下两种服务:
创建一个gerry-test-proj工程:
然后点击建立,会自动跳转到当前创建好的工程中:
(4)安装gcloud
The Container Engine API uses the gcloud
command line tool for clusteroperations and for managing credentials.
Install thegcloud
tool.
安装完成后,可以看下gcloud的使用方法:
root@gerryyang:~# gcloud -h
Usage: gcloud [optional flags]
group may be auth | components | compute | config | container |
deployment-manager | dns | sql | topic
command may be docker | feedback | help | info | init | version
The *gcloud* CLI manages authentication, local configuration, developer
workflow, and interactions with the Google Cloud Platform APIs.
optional flags:
--account ACCOUNT Google Cloud Platform user account to use for
invocation.
--format FORMAT Format for printed output.
--help Display detailed help.
--log-http LOG_HTTP Logs all HTTP server requests and responses to stderr.
(true/false)
--project PROJECT_ID Google Cloud Platform project ID to use for this
invocation.
--quiet, -q Disable all interactive prompts.
--trace-token TRACE_TOKEN
Token used to route traces of service requests for
investigation of issues.
--user-output-enabled USER_OUTPUT_ENABLED
Control whether user intended output is printed to the
console. (true/false)
--verbosity VERBOSITY Override the default verbosity for this command. This
must be a standard logging verbosity level: [debug,
info, warning, error, critical, none] (Default:
[warning]).
-h Print a summary help and exit.
-v, --version Print version information.
command groups:
auth Manage oauth2 credentials for the Google Cloud SDK.
components List, install, update, or remove Google Cloud SDK
components or packages.
compute Read and manipulate Google Compute Engine resources.
config View and edit Google Cloud SDK properties.
container Deploy and manage clusters of machines for running
containers.
deployment-manager Manage deployments of cloud resources.
dns Manage your Cloud DNS managed-zones and record-sets.
sql Manage Cloud SQL databases.
topic gcloud supplementary help.
commands:
docker Provides the docker CLI access to the Google Container
Registry.
feedback Provide feedback to the Google Cloud SDK team.
help Prints detailed help messages for the specified
commands.
info Display information about the current gcloud
environment.
init Create and initialize a gcloud workspace in the current
directory.
version Print version information for Cloud SDK components.
然后,就可以做下面这些事情了:
With the Cloud SDK command-line interface, you can easily manage your service resources and your development workflow.
Have a question? Ask on StackOverflow using the "gcloud" tag or check out our groups page.
Found a bug? File it in our issue tracker site. Any feedback is appreciated!
Looking to stay up-to-date with the latest Cloud SDK releases or other news? Join thegoogle-cloud-sdk-announce mailing list.
比如,使用gcloud安装额外的一些组件:(可以参考gcloud的使用说明:https://cloud.google.com/sdk/gcloud/)
When you install the Google Cloud SDK, some components might be installed by default. To see a list of currently-installed components and a list of any available component updates, type the following command:
$ gcloud components list
To install additional components, type the update
command, followed by the name of the component. For example, to installgsutil
, type the following command:
$ gcloud components update gsutil
Running the above update
command installs the gsutil
tool into thegoogle-cloud-sdk/bin
directory, and installs the tool's dependencies elsewhere in the Cloud SDK. If you correctly addedgoogle-cloud-sdk/bin
to your PATH
, you will be able to rungsutil
from the command line.
To update all of your installed components, type gcloud components update
.
先看下安装完gcloud默认安装了哪些组件:
root@gerryyang:~# gcloud components list
┌────────────────────────────────────────────────────────────────────────────────────────────┐
│ Components │
├───────────────┬─────────────────────────────────────────────┬───────────────────┬──────────┤
│ Status │ Name │ ID │ Size │
├───────────────┼─────────────────────────────────────────────┼───────────────────┼──────────┤
│ Not Installed │ App Engine Command Line Interface (Preview) │ app │ < 1 MiB │
│ Not Installed │ Developer Preview gcloud Commands │ preview │ < 1 MiB │
│ Not Installed │ gcloud Alpha Commands │ alpha │ < 1 MiB │
│ Not Installed │ gcloud Beta Commands │ beta │ < 1 MiB │
│ Not Installed │ gcloud app Java Extensions │ app-engine-java │ 96.0 MiB │
│ Not Installed │ gcloud app Python Extensions │ app-engine-python │ 7.1 MiB │
│ Not Installed │ kubectl │ kubectl │ │
│ Installed │ BigQuery Command Line Tool │ bq │ < 1 MiB │
│ Installed │ Cloud SDK Core Libraries │ core │ 2.1 MiB │
│ Installed │ Cloud Storage Command Line Tool │ gsutil │ 2.7 MiB │
│ Installed │ Default set of gcloud commands │ gcloud │ < 1 MiB │
└───────────────┴─────────────────────────────────────────────┴───────────────────┴──────────┘
To install new components or update existing ones, run:
$ gcloud components update COMPONENT_ID
root@gerryyang:~# gcloud components update kubectl
┌─────────────────────────────────────────────┐
│ These components will be installed. │
├─────────────────────────┬─────────┬─────────┤
│ Name │ Version │ Size │
├─────────────────────────┼─────────┼─────────┤
│ kubectl │ │ │
│ kubectl (Linux, x86_64) │ 1.0.3 │ 4.5 MiB │
└─────────────────────────┴─────────┴─────────┘
For the latest full release notes, please visit:
https://dl.google.com/dl/cloudsdk/channels/rapid/RELEASE_NOTES
Do you want to continue (Y/n)? y
|- Creating update staging area -|
|============================================================|
|- Installing: kubectl -|
|============================================================|
|- Installing: kubectl (Linux, x86_64) -|
|============================================================|
Creating backup and activating new installation...
Update done!
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/root/Docker/tools/kubectl
Tell the command line interface which Google Developers Console project to use:
$ gcloud config set project PROJECT
To find the value of PROJECT
, visithttps://console.developers.google.com/projectand refer to theProject ID column.
Set your default Compute Engine zone:
$ gcloud config set compute/zone ZONE
If you've created a cluster, you can set it as the default so that you can omit the--cluster CLUSTER_NAME
flag from your commands:
$ gcloud config set container/cluster CLUSTER_NAME
To view your gcloud
defaults at any time, run:
$ gcloud config list
例如:
(5)接下来要做的事情。
Follow one of our walkthroughs to build an application from start to finish:
If you'd like to get started on your own, your first step is to create a container cluster.
Refer
[1] https://cloud.google.com/container-engine/docs/before-you-begin
[2] https://cloud.google.com/container-engine/docs/tutorials/guestbook