UNPKG

xlb-main-login

Version:

``` yarn install ```

87 lines (81 loc) 2.28 kB
// 该脚本是提供给jenkins发布版本通知rancher升级脚本 const request = require('request') const moment = require('dayjs') const utc = require('dayjs/plugin/utc') moment.extend(utc) const argv = process.argv.splice(2) const baseUrl = 'https://k8s.xiaoliebian.tech:9443/v3' // Rancher那个截图上的EndPoint const token = 'token-vxfx2:nhxhh48pkndxgzlsdsdx97gln55qxrtsnswm7r7fd9vsjfz67np9ml' // Token const strictSSL = false // 有证书那就设置为true let fullUrl = '' function updateWorkLoad(data) { console.log('redeploy start') data.annotations['cattle.io/timestamp'] = moment().utc().format() data.containers = [ { initContainer: false, restartCount: 0, stdin: true, stdinOnce: false, tty: true, allowPrivilegeEscalation: false, image: imageName, imagePullPolicy: 'Never', name: 'scrm', ports: [ { containerPort: 80, dnsName: 'scrm', hostPort: 0, kind: 'ClusterIP', name: '80tcp2', protocol: 'TCP', sourcePort: 0, type: '/v3/project/schemas/containerPort', }, ], privileged: false, readOnly: false, resources: { type: '/v3/project/schemas/resourceRequirements', requests: {}, limits: {}, }, runAsNonRoot: false, terminationMessagePath: '/dev/termination-log', terminationMessagePolicy: 'File', type: 'container', environmentFrom: [], capAdd: [], capDrop: [], livenessProbe: null, volumeMounts: [], }, ] request.put( fullUrl, { headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json', }, strictSSL: strictSSL, json: data, }, (error, response) => { if (!error && response.statusCode === 200) { console.log('deploy success!') } else { console.log(error) console.log('deploy error!') } } ) } const project = argv[0] const imageName = argv[1] fullUrl = `${baseUrl}${project}` console.log(imageName) updateWorkLoad({ annotations: { 'cattle.io/timestamp': '' }, })