Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the linkage of CI/CD through the webhook micro-service of Rancher

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to achieve the linkage of CI/CD through Rancher's webhook micro service". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to achieve the linkage of CI/CD through Rancher's webhook micro service".

Webhook introduction

The service flow of Rancher webhook is roughly as follows:

Router initializes the corresponding handler based on the method and url submitted by the user.

Handler parses the key and projectid in the request parameters to initialize the corresponding webhook driver.

Driver calls the upgrade API, returns and triggers the webhook request accordingly.

Environment preparation Platform

Mac,Windows,Linux,Docker Cloud,AWS,Azure can be deployed.

The platform to be prepared this time is Ubuntu release (14.04). In order to be compatible with docker, the kernel should be controlled above 3.10 when selecting linux distribution.

Docker

Install the docker engine according to the platform you choose. For installation instructions, please refer to the official https://docs.docker.com documentation and use it with Rancher. The best version of docker engine is 1.12.6 or 1.13.1.

The docker engine version to be prepared this time is 1.12.6.

Rancher

CI/CDBuild application image

The example application is based on the official NGX image build, and the NGX welcome page information is modified.

Push application image

Push the NGX application image to the specified remote image repository

Create Stack&Service

To create webapp stack,NGX service through API, the command line is as follows

Curl-u "xxx:xxx"\-X POST\-H 'Accept: application/json'\-H' Content-Type: application/json'\-d'{"description": "validate the upgrade service using webhook", "name": "webapp", "system": false "dockerCompose": "version:'2'\ nservices:\ nNGX:\ nimage: anzersy/nginx:20170801\ nstdin_open: true\ ntty: true\ ncpuset:\" 0\ "\ nports:\ n-8787:80/tcp\ ncpu_shares: 1024\ nlabels:\ nio.rancher.container.pull_image: always\ nservicename: nginx" "rancherCompose": "version:'2'\ nservices:\ nNGX:\ nscale: 1\ nstart_on_create: true", "binding": null, "startOnCreate": true}''http://a.b.c.d:e/v2-beta/projects/1a107/stacks' authentication service

Open a browser, access the NGX service, and confirm the content of the application.

Create webhook

Go to the webhook creation page and create a service upgrade webhook for the Dev,Beta,Prod environment through UI.

(note that the corresponding image TAG and service tag are set)

Update and push apply the image

Update the NGX application, build the image, and push it to the remote repository.

Trigger upgrade webhook

Trigger upgrade webhoook to automatically upgrade the service.

Curl-u "xxx:xxx"\-X POST\-H'Accept: application/json'\-H 'Content-Type: application/json'\-d'{"push_data": {"tag": "20170801"}, "repository": {"repo_name": "anzersy/nginx"}''http://a.b.c.d:e/v1- authentication update

Open a browser, access the NGX service, and verify that the service upgrade is normal.

Thank you for your reading. the above is the content of "how to achieve the linkage of CI/CD through Rancher's webhook micro service". After the study of this article, I believe you have a deeper understanding of how to achieve the linkage of CI/CD through Rancher's webhook micro service, and the specific usage still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report