温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

发布时间:2021-11-15 17:35:25 来源:亿速云 阅读:216 作者:柒染 栏目:云计算

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

概述

这里介绍如何通过Rancher的webhook微服务来实现Service/Host的弹性伸缩。

流程介绍

  • Service Scale

    • 创建example服务对象。

    • 创建service scale webhook对象。

    • 第三方触发webhook,完成service弹性伸缩。

  • Host Sacle

    • 通过阿里云machine driver创建实例对象,打上scale-up标签。

    • 创建host scale webhook对象。

    • 第三方触发webhook,完成host弹性伸缩。

webhook介绍

Rancher webhook的服务流程大致如下:

  1. Webhook Driver(WD)初始化。

  2. Router Handler(RH)初始化。

  3. 接收请求URL和Method,匹配调用RH.Execute或其他方法,RH.Execute解析请求数据得到WD_Id,进而执行WD.Execute,最后返回并response。

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

环境准备

Platform

  • Mac,Windows,Linux,Docker Cloud,AWS,Azure均可部署。

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

  • 本次准备的平台是Ubuntu发行版(14.04),为了兼容docker,选择linux发行版的时候内核需控制在3.10以上。

Docker

根据用户选择的平台安装docker引擎,安装指导可参考https://docs.docker.com官方文档,搭配Rancher使用,docker引擎版本最优选择1.12.6或者1.13.1。 本次准备的docker引擎版本是1.12.6。

Rancher

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

实践步骤

Service Scale

创建example service

curl -u "xx:xx" \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"description": "example service for scaling",
"name": "webapp",
"system": false,
"dockerCompose": "version: '2'\nservices:\n  NGX:\n    image: nginx:alpine\n    stdin_open: true\n    tty: true\n    cpuset: \"0\"\n    ports:\n    - 8787:80/tcp\n    cpu_shares: 1024\n    labels:\n      io.rancher.container.pull_image: always\n      servicename: nginx",
"rancherCompose": "version: '2'\nservices:\n  NGX:\n    scale: 1\n    start_on_create: true",
"binding": null,
"startOnCreate": true
}' 'http://a.b.c.d:8080/v2-beta/projects/1a5/stacks'

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

创建webhook

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

Trigger webhook

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩 如何通过Rancher webhook微服务实现Service/Host的弹性伸缩 如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

Host Scale

创建example host

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩 如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

创建webhook

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

Trigger webhook

如何通过Rancher webhook微服务实现Service/Host的弹性伸缩 如何通过Rancher webhook微服务实现Service/Host的弹性伸缩 如何通过Rancher webhook微服务实现Service/Host的弹性伸缩

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI