Original author: Po-yun
This article is for readers
If you are a beginner Kubernetes, it can help you quickly build a clustered environment can actually use in the cloud, and released his first application. You do not need to prepare any hardware resources in advance or download any software package.
If you already have a self-built Kubernetes cluster, want to try hosting a cluster on Ali cloud, we can help you quickly get started operation, without having to read the help files Ali cloud, which saves you time. You can have after the end of the first experience, and then choose to read help document container services and container image of the service.
If you already have a tradition of deploying Web applications on the cloud (such as deploying on the cloud where ECS), wants to transform a container of paper can also help to you, you do not even have in-depth study Kubernetes, need to know The basic concept can be.
Ready for Code
All of this operation Ali cloud-based console, so you only need a login account to Ali cloud console.
Our first application of the code is ready. Please sign https://code.aliyun.com/ , after registration is completed, access https://code.aliyun.com/shengbo.tsb/yunputest , click on derivative projects (fork) icon.
In the confirmation box then pops up, click on the picture to confirm, complete derivation.
Alternatives: If you are having difficulty derives, directly from https://github.com/docker-training/webapp clone this project, and then to push through their own git on code.aliyun.com.
Prepare a Mirror warehouse
登录https://cr.console.aliyun.com/cn-beijing/instances/repositories
在左侧导航栏选择“命名空间”
点击“创建命令空间”,输入名字“tengshengbo”。
确认命名空间创建完成之后,点击左侧导航栏“镜像仓库”,点击“创建镜像仓库”,输入仓库名称“yunputest”
在下一步,选择刚刚建立的代码仓库。选择“海外机器构建”以加快构建速度。提示:如果下拉框没有代码仓库,点击右侧的刷新按钮。
创建新镜像
回到https://code.aliyun.com/ 点击yunputest这个项目,注意,是自己名下的项目,而不是shengbo.tsb这个账号名下的项目。 点击“新标签”.
输入标签名release-v1.5。注意,您必须使用release-v[版本号]形式,比如release-v2.5或者其他。
返回镜像仓库列表,https://cr.console.aliyun.com/cn-beijing/instances/repositories
选择自己的镜像仓库,左侧导航选择“构建”,可以看到一个构建自动生成了。
创建Kubernetes集群
访问容器服务控制台 https://cs.console.aliyun.com/#/k8s/cluster/list
选择“创建Kubernetes集群”, 集群模板选择第一个“标准托管集群”
集群名称选择“yunpu-k8s”,选择专有网络和虚拟交换机,勾选公网访问(为了开发测试方便),选择实例类型(如果不考虑性能,单纯为了省钱,可以使用t5或者t6实例),其他默认就好。
注意:Pod CIDR,Service CIDR不能与VPC内已有网段冲突,如果提示有错误,请更换网络的CIDR。
在确认对话框里勾选协议,完成创建。之后,确认自己的集群运行中。
部署第一个应用
容器服务的左侧导航栏选择“应用-无状态”,点击“使用镜像创建”,在“应用基本信息”这一部分, 输入应用名称yunpuapp, 选择刚创建的集群yunpu-k8s, 其他默认。
下一步,容器配置,镜像名称一项,点击“选择镜像”,选择刚才自动从代码创建的镜像
镜像Tag一项,点击“选择镜像Tag”,选择你刚刚自己定义的版本号,比如1.4。其他保持默认。
点击下一步。
在高级配置里面,点击“服务(Service)”旁边的“创建”,
端口映射一项,输入名称port,注意服务端口80,容器端口5000.
点击“路由(Ingress)”旁边的“创建”,输入域名yunpuapp选择刚刚创建的服务以及port。
创建成功之后,可以看到应用的访问方式,在“路由(Ingress)”里面,“规则”一项,有一个链接。
点击这个链接,可以访问应用,显示内容包含响应时间、应用运行时的host name以及IP地址。多次刷新链接,可以看到不同的ip地址,这个说明后面对应的容器组Pod是多个。
升级应用
建议您自行尝试更改应用的代码,比如简单更改webapp/app.py这个文件,完成git tag后,git push.
$ git tag release-v1.5
$ git push origin release-v1.5
或者,您也可以直接在 https://code.aliyun.com/ 控制台上,为master分支新建标签release-v1.5
等待镜像更新完成后,在“无状态应用”页,点击应用旁边的“编辑”。
编辑页面,选择新的版本1.5,点击更新
下一步
Ali cloud container service Kubernetes not only hosted version, as well as proprietary version and Serverless version. Proprietary version is rich in container suitable for operation and maintenance experience, we hope a long-running applications, and independent operation and maintenance of the entire infrastructure of large enterprise customers. Serverless version do not want to care for the operation and maintenance of infrastructure, or just a short run an application in the hope that users of SMEs out of the box. This article is hosted version interposed between proprietary and Edition Serverless Edition.
If you want to know more, we recommend the following reference materials:
container services Kubernetes Edition help documentation: https://help.aliyun.com/product/85222.html
container mirroring Services Help documentation: https://help.aliyun.com/ product / 60716.html
If you need to perform operation and maintenance services for containers, refer to the following information:
operation and maintenance schedule:
https://help.aliyun.com/product/119529.html
resource organization:
https://help.aliyun.com/product/28850. html