0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

クイックスタート | Kubernetes Engine のドキュメント | Google Cloud を実施したときの作業ログ

Posted at

クイックスタート | Kubernetes Engine のドキュメント | Google Cloud を実施したときの作業ログになります。
https://cloud.google.com/kubernetes-engine/docs/quickstart?hl=ja

# デフォルトのプロジェクトの設定
$ gcloud config set project winter-return-241300
Updated property [core/project].


# デフォルトのコンピューティング ゾーンの設定
$ gcloud config set compute/zone us-west1-a
Updated property [compute/zone].

# Kubernetes Engine クラスタの作成
# エラーが出てる。。。
$ gcloud container clusters create lesson-cluster
WARNING: In June 2019, node auto-upgrade will be enabled by default for newly created clusters and node pools. To disable it, use the `--no-enable-autoupgrade` flag.
WARNING: Starting in 1.12, new clusters will have basic authentication disabled by default. Basic authentication can be enabled (or disabled) manually using the `--[no-]enable-basic-auth` flag.
WARNING: Starting in 1.12, new clusters will not have a client certificate issued. You can manually enable (or disable) the issuance of the client certificate using the `--[no-]issue-client-certificate` flag.
WARNING: Currently VPC-native is not the default mode during cluster creation. In the future, this will become the default mode and can be disabled using `--no-enable-ip-alias` flag. Use `--[no-]enable-ip-alias` flag to suppress this warning.
WARNING: Starting in 1.12, default node pools in new clusters will have their legacy Compute Engine instance metadata endpoints disabled by default. To create a cluster with legacy instance metadata endpoints disabled in the default node pool, run `clusters create` with the flag `--metadata disable-legacy-endpoints=true`.
WARNING: Your Pod address range (`--cluster-ipv4-cidr`) can accommodate at most 1008 node(s). 
This will enable the autorepair feature for nodes. Please see https://cloud.google.com/kubernetes-engine/docs/node-auto-repair for more information on node autorepairs.
ERROR: (gcloud.container.clusters.create) ResponseError: code=403, message=Kubernetes Engine API is not enabled for this project. Please ensure it is enabled in Google Cloud Console and try again: visit https://console.cloud.google.com/apis/api/container.googleapis.com/overview?project=winter-return-241300 to do so.


https://console.cloud.google.com/apis/api/container.googleapis.com/overview?project=winter-return-241300
にアクセスしてAPIを有効にする

再度実行
成功!

$ gcloud container clusters create lesson-cluster
WARNING: In June 2019, node auto-upgrade will be enabled by default for newly created clusters and node pools. To disable it, use the `--no-enable-autoupgrade` flag.
WARNING: Starting in 1.12, new clusters will have basic authentication disabled by default. Basic authentication can be enabled (or disabled) manually using the `--[no-]enable-basic-auth` flag.
WARNING: Starting in 1.12, new clusters will not have a client certificate issued. You can manually enable (or disable) the issuance of the client certificate using the `--[no-]issue-client-certificate` flag.
WARNING: Currently VPC-native is not the default mode during cluster creation. In the future, this will become the default mode and can be disabled using `--no-enable-ip-alias` flag. Use `--[no-]enable-ip-alias` flag to suppress this warning.
WARNING: Starting in 1.12, default node pools in new clusters will have their legacy Compute Engine instance metadata endpoints disabled by default. To create a cluster with legacy instance metadata endpoints disabled in the default node pool, run `clusters create` with the flag `--metadata disable-legacy-endpoints=true`.
WARNING: Your Pod address range (`--cluster-ipv4-cidr`) can accommodate at most 1008 node(s). 
This will enable the autorepair feature for nodes. Please see https://cloud.google.com/kubernetes-engine/docs/node-auto-repair for more information on node autorepairs.
Creating cluster lesson-cluster in us-west1-a... Cluster is being health-checked (master is healthy)...done.                                                        
Created [https://container.googleapis.com/v1/projects/winter-return-241300/zones/us-west1-a/clusters/lesson-cluster].
To inspect the contents of your cluster, go to: https://console.cloud.google.com/kubernetes/workload_/gcloud/us-west1-a/lesson-cluster?project=winter-return-241300
kubeconfig entry generated for lesson-cluster.
NAME            LOCATION    MASTER_VERSION  MASTER_IP       MACHINE_TYPE   NODE_VERSION   NUM_NODES  STATUS
lesson-cluster  us-west1-a  1.12.7-gke.10   35.185.235.146  n1-standard-1  1.12.7-gke.10  3          RUNNING

クラスタの認証情報を取得する

$ gcloud container clusters get-credentials lesson-cluster
Fetching cluster endpoint and auth data.
kubeconfig entry generated for lesson-cluster.

Deployment を作成する

$ kubectl run hello-server --image gcr.io/google-samples/hello-app:1.0 --port 8080
deployment.apps "hello-server" created

Deployment を公開する

$ kubectl expose deployment hello-server --type "LoadBalancer"
service "hello-server" exposed

アプリケーションの検査と表示

$ kubectl get service hello-server
NAME           TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
hello-server   LoadBalancer   10.27.248.87   34.83.62.16   8080:32453/TCP   2m

↑の出力で、EXTERNAL IP 列に示されている Service の外部 IP アドレスをコピーします。
http://34.83.62.16:8080/

クリーンアップ

$ kubectl delete service hello-server
service "hello-server" deleted
$ gcloud container clusters delete lesson-cluster
The following clusters will be deleted.
 - [lesson-cluster] in [us-west1-a]

Do you want to continue (Y/n)?  y

Deleting cluster lesson-cluster...done.                                                                                                                     
Deleted [https://container.googleapis.com/v1/projects/winter-return-241300/zones/us-west1-a/clusters/lesson-cluster].
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?