結合你們CICD的應用場景,本篇Blog旨在介紹如何經過Rancher的webhook微服務來實現Service/Host的彈性伸縮。linux
Rancher webhook的服務流程大體以下:nginx
根據用戶選擇的平臺安裝docker引擎,安裝指導可參考https://docs.docker.com官方文檔,搭配Rancher使用,docker引擎版本最優選擇1.12.6或者1.13.1。 本次準備的docker引擎版本是1.12.6。web
建立example servicedocker
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'
建立webhookjson
Trigger webhookapp
建立example hostcurl
建立webhookwebapp
Trigger webhooktcp