MorFans Dev
折腾 - 开发 - 分享

Google Docker 初探

Google Docker 初探

系统环境为 macOS Sierra 10.12.6

工具安装

1.kubectl command line

https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-with-homebrew-on-macos

2.gcloud command line

https://cloud.google.com/sdk/docs/quickstart-mac-os-x?hl=zh-CN

gcloud 配置

1.设置 gcloud 用户

$ gcloud config set account [ACCOUNT]

2.授权

授权操作,执行命令后,浏览器自动打开,登录用户后授权既可。

$ gcloud auth login

or

使用 --no-launch-browser 参数执行上面命令,将 url 粘贴到浏览器中访问,登录用户并授权后,将 verification code 复制,在命令行粘贴继续。

$ gcloud auth login --no-launch-browser

3.设置projectId

$ gcloud config set project [PROJECT_ID]

4.查看信息

$ gcloud info

连接到集群

通过运行以下命令来配置 kubectl 命令行访问权限

$ gcloud container clusters get-credentials [CLUSTER_NAME] \
    --zone [ZONE] --project [PROJECT]

可以使用 --log-http 查看http日志:

$ gcloud --log-http container clusters get-credentials [CLUSTER_NAME] \
    --zone [ZONE] --project [PROJECT]

然后启动代理以连接到 Kubernetes 控制平面:

$ kubectl proxy

接着,通过浏览器访问以下位置,以打开“信息中心”界面:

http://localhost:8001/ui

发布一个简单的Hello 应用

google 官方文档 https://cloud.google.com/container-engine/docs/quickstart

$ kubectl run hello-node --image=gcr.io/google-samples/node-hello:1.0 --port=8080

$ kubectl expose deployment hello-node --type="LoadBalancer"

$ kubectl get service hello-node

查看应用程序(将EXTERNAL-IP替换为上一步中获取的外部IP地址)。

http://EXTERNAL-IP:8080
赞赏
魔帆博客,版权所有 | 如未注明,均为原创
本站均采用 BY-NC-ND 协议 (署名-非商业性使用-禁止演绎) 进行授权。
转载请注明来自本站文章:Google Docker 初探(https://www.morfans.cn/archives/2543)

清江 林影

文章作者

我喜欢狗,任性的狗

发表回复

textsms
account_circle
email

  • You are so cool! I do not think I’ve truly read through anything like this before.
    So nice to find someone with some genuine thoughts on this subject matter.
    Really.. thank you for starting this up. This website is one thing that is needed on the internet,
    someone with a bit of originality!

    1 天前 回复

Google Docker 初探
系统环境为 macOS Sierra 10.12.6 工具安装 1.kubectl command line https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-with-homebrew-on-macos 2.gcloud comman…
扫描二维码继续阅读
2017-08-13