Automatic deployment part of the CI/CD process

1. Preview

Mirror list:

Cluster list:

List of applications:

2. Data sheets

2.1 clusters cluster

// {root}/app/model/cluster.js
'use strict';

module.exports = app => {
  const { STRING, TEXT } = app.Sequelize;
  const Cluster = app.model.define('cluster', {
    name: STRING,
    region: STRING,
    masterUrl: STRING(1024),
    ca: TEXT,
    key: TEXT,
    cert: TEXT,
  });
  return Cluster;
};
Copy the code

2.2 images/image_tags Image/Image version

// {root}/app/model/image.js
'use strict';

module.exports = app => {
  const { STRING } = app.Sequelize;
  const Image = app.model.define('image', {
    namespace: STRING(512),
    region: STRING,
    name: STRING,
    repo_full_name: STRING(1024),
  });
  Image.associate = function() {
    app.model.Image.hasMany(app.model.ImageTag, { as: 'tags', foreignKey: 'image_id' });
  };
  return Image;
};

// {root}/app/model/image_tags.js
'use strict';

module.exports = app => {
  const { STRING, DATE } = app.Sequelize;
  const Tag = app.model.define('image_tag', {
    digest: STRING,
    tag: STRING,
    pushed_at: DATE,
  }, {
    createdAt: false,
    updatedAt: false,
  });
  Tag.associate = function() {
    app.model.ImageTag.belongsTo(app.model.Image, { as: 'tags', foreignKey: 'image_id' });
  };
  return Tag;
};
Copy the code

2.3 hooks webhook

'use strict';

module.exports = app => {
  const { STRING } = app.Sequelize;
  const Hook = app.model.define('hook', {
    name: STRING,
    callbackUrl: STRING(1024),
    accessToken: STRING(1024),
  });
  return Hook;
};
Copy the code

3. Controls/Services

3.1 CURD

  • eggjs/egg-sequelize

3.2 Hooks

Need to validate accessToken, callbackUrl is used to pass information backwards (such as sending pin notifications)

Const {/ / https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.karFPe&treeId=257&articleId=105735&docType=1  data } = yield axios.post(callbackUrl, { msgtype: 'markdown', markdown: { title: '#Image Pushed', text: ` # # # # image: ${newImage. Get (' name ')} \ n \ n > version: ${newImageTag. Get (' tag ')} `,,}});Copy the code

Screenshots:

3.3 Clusters Information

/ / https://help.aliyun.com/document_detail/26065.html?spm=5176.doc26063.6.883.YpbfjI const axios = the require (' axios'); const https = require('https'); try { const { ca, key, cert, masterUrl } = cluster; const agent = new https.Agent({ ca, key, cert, }); const { data } = yield axios.get(`${masterUrl}/projects/`, { httpsAgent: agent, }); this.ctx.body = data; } catch (error) { this.ctx.throw(500, '#cluster: request info failed'); }Copy the code

4. UI (React + Mobx + Antd)

4.1 packages

  • react
  • react-helmet
  • react-router-v4
  • mobx
  • mobx-persist
  • mobx-decorators
  • root-import

4.2 demo/source

Data is the company’s private data, will not put the source code, and the following project is basically the same.

  • ImplementsIO/implements.io