WeBankPartners / wecube-plugins-saltstack

WeCube plugin for application deployment
Apache License 2.0
13 stars 2 forks source link
saltstack wecube-plugin

SaltStack Plugin

License

English / 中文

Introduction

Salt is a new approach to infrastructure management built on a dynamic communication bus. Salt can be used for data-driven orchestration, remote execution for any infrastructure, configuration management for any app stack, etc.

The SaltStack plugin encapsulates and packages the salt-api according to the specific needs of different scenarios, which reduces the difficulty of using SaltStack. It also provides an API interface that is closer to the business usage scenarios.

As an essential member of the WeCube plugin group, the SaltStack plugin provides WeCube with the ability to manage infrastructure resources. In the meanwhile, the SaltStack plugin can also offer pluggable services for third-party applications.

SaltStack plugin 1.0.0 is now released, its architecture & APIs are as follows:

Key Features

The SaltStack plugin relies on services such as salt-master, salt-api, and httpd. Based on these services, it encapsulates a layer of APIs for system management and application deployment.

User can perform the following operations through the APIs provided by the plugin:

How to build development environment

Please refer to the SaltStack Plugin Development Guide on how to build development environment.

Build and Run Docker Image

Before executing the following command, please make sure docker command is installed on the CentOS host. Click here to know How to Install Docker.

  1. Git clone source code
git clone https://github.com/WeBankPartners/wecube-plugins-saltstack.git

saltstack_dir

  1. Build plugin binary
make build 

saltstack_build

  1. Build plugin docker image, the docker image tag is github's commit number.
make image

saltstack_image

  1. Run plugin container. Please replace variable {$HOST_IP} with your host ip, replace variable {$IMAGE_TAG} with your image tag, and execute the following command.
Port Comment
9099 salt-minion install port
4505 salt-master pub port
4506 salt-master ret port
4507 salt plugin instances connect port
docker run -d  --restart=unless-stopped -v /etc/localtime:/etc/localtime -e minion_master_ip={$HOST_IP} -e minion_port=22 -p 9099:80 -p 9090:8080 -p 4505:4505 -p 4506:4506 -p 8082:8082 --privileged=true  -v /home/app/data/minions_pki:/etc/salt/pki/master/minions -v /home/app/wecube-plugins-saltstack/logs:/home/app/wecube-plugins-saltstack/logs -v /home/app/data:/home/app/data wecube-plugins-saltstack:{$TAG_NUM}
  1. after running the SaltStack Plugin, use the following curl command to check if SaltStack plugin works fine.
curl -X POST  http://127.0.0.1:8082/v1/deploy/agent/install -H "cache-control: no-cache"  -H "content-type: application/json" -d "{\"inputs\":[{\"guid\":\"1234\",\"seed\":\"abc12345\",\"host\":\"127.0.0.1\",\"password\": \"251f54c3f5be75e171ae1eb516dbacd9\"}]}"

salt-minion has been installed on host:127.0.0.1 when you saw the message below:

{
    "resultCode": "0",
    "resultMessage": "success",
    "results": {
        "outputs": [
            {
                "guid": "1234"
            }
        ]
    }
}

Build Plugin Package for Wecube

If you want to build a plugin package to work with Wecube, please execute the following command. You can replace variable {$package_version} with the version number you want.

make package PLUGIN_VERSION=v{$package_version}

saltstack_zip

Read more in Build SaltStack Plugin Docker Image Guide.

API Reference

Please refer to the SaltStack API Guide

License

SaltStack Plugin is licensed under the Apache License Version 2.0, please refer to the license for details.

Community