使用GCE(Google Container Engine)体验容器云服务 (1)

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天。


使用GCE(Google Container Engine)体验容器云服务 (1)_第1张图片


(3)激活Google API

激活后,可以使用如下两种服务:

  • Google Container Engine API
  • Google Compute Engine and associated APIs

创建一个gerry-test-proj工程:

使用GCE(Google Container Engine)体验容器云服务 (1)_第2张图片

然后点击建立,会自动跳转到当前创建好的工程中:

使用GCE(Google Container Engine)体验容器云服务 (1)_第3张图片


(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.

然后使用gcloud登陆GCP账户(即,完成认证):

使用GCE(Google Container Engine)体验容器云服务 (1)_第4张图片


然后,就可以做下面这些事情了:

Get started with a Google Cloud Platform service

With the Cloud SDK command-line interface, you can easily manage your service resources and your development workflow.

  • Manage development workflow common to all services.
    To get started, see the gcloud command-line tool.
  • Build a web app and host it on Google App Engine.
    To get started, follow the walkthrough in the Developer Console to Try Google App Engine Now.
  • Launch large compute clusters on Google Compute Engine.
    To get started, follow the Compute Engine Quickstart Guide.
  • Store vast amounts of data on Google Cloud Storage.
    To get started, follow the Hello Google Cloud Storage Tutorial.
  • Analyze Big Data in the cloud with Google BigQuery.
    To get started, follow the bq Command-Line Tool Quickstart.
  • Store and manage data using a MySQL database with Google Cloud SQL.
    To get started, see Managing Instances Using the Cloud SDK.
  • Make your applications and services available to your users with Google Cloud DNS.
    To get started, see Getting started with Google Cloud DNS.

Submit questions and give us feedback

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

然后,使用gcloud安装kubectl:

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

设置gcloud的默认值:

  1. 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.

  2. Set your default Compute Engine zone:

    $ gcloud config set compute/zone ZONE
    
  3. 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

例如:

使用GCE(Google Container Engine)体验容器云服务 (1)_第5张图片


(5)接下来要做的事情。

Follow one of our walkthroughs to build an application from start to finish:

  • Deploy Your Node.js Code
  • Running WordPress with a Single Pod
  • Create a Guestbook with Redis and PHP
  • Using Persistent Storage with WordPress and MySQL

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



你可能感兴趣的:(Docker)