• 【CI/CD】Rancher CD过程--20230906


    gitlab设定CICD的变量

    在这里插入图片描述

    1. HARBOR_PASSWORD:密码
    2. HARBOR_USER:工号
    3. K8S_TOKEN:Bearer + rancher key
      在这里插入图片描述
    4. K8S_WORKLOAD_URL:选择【View in API】的URL,并非workload的URL。
      如果是新版rancher,则使用/g回去旧版界面。
      在这里插入图片描述
      在这里插入图片描述

    准备json.txt方法1(W公司SOP,但是可能失效)

    1. 选择workload,进入【View in API】
      在这里插入图片描述

    2. right panel >> click edit
      在这里插入图片描述

    3. Move to buttom , and click “Show Request”
      在这里插入图片描述

    4. Copy the highlight area from “-d” parameter content
      在这里插入图片描述

    5. Create json.txt file and paste the content
      在这里插入图片描述

    6. 记得修改image tag和 “cattle.io/timestamp”: “CHANGEME”。

    {
        "actions": {
            "pause": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django?action=pause",
            "redeploy": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django?action=redeploy",
            "resume": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django?action=resume",
            "rollback": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django?action=rollback"
        },
        "annotations": {
            "cattle.io/timestamp": "CHANGEME"
        },
        "baseType": "workload",
        "containers": [
            {
                "allowPrivilegeEscalation": false,
                "image": "harbor-k8s.wzs.wistron.com.cn/season/training_platform_django:0.0.8-build36",
                "imagePullPolicy": "IfNotPresent",
                "initContainer": false,
                "name": "training-platform-django",
                "ports": [
                    {
                        "containerPort": 8000,
                        "dnsName": "training-platform-django-nodeport",
                        "hostPort": 0,
                        "kind": "NodePort",
                        "name": "8000tcl",
                        "protocol": "TCP",
                        "sourcePort": 0,
                        "type": "/v3/project/schemas/containerPort"
                    }
                ],
                "privileged": false,
                "readOnly": false,
                "resources": {
                    "limits": {
                        "cpu": "1",
                        "memory": "1000Mi"
                    },
                    "requests": {
                        "cpu": "1",
                        "memory": "1000Mi"
                    },
                    "type": "/v3/project/schemas/resourceRequirements"
                },
                "restartCount": 0,
                "runAsNonRoot": false,
                "stdin": true,
                "stdinOnce": false,
                "terminationMessagePath": "/dev/termination-log",
                "terminationMessagePolicy": "File",
                "tty": true,
                "type": "/v3/project/schemas/container"
            }
        ],
        "created": "2023-06-27T13:13:37Z",
        "createdTS": 1687871617000,
        "creatorId": null,
        "deploymentConfig": {
            "maxSurge": 1,
            "maxUnavailable": 0,
            "minReadySeconds": 0,
            "progressDeadlineSeconds": 600,
            "revisionHistoryLimit": 10,
            "strategy": "RollingUpdate"
        },
        "deploymentStatus": {
            "availableReplicas": 1,
            "conditions": [
                {
                    "lastTransitionTime": "2023-06-27T13:13:37Z",
                    "lastTransitionTimeTS": 1687871617000,
                    "lastUpdateTime": "2023-08-24T05:46:46Z",
                    "lastUpdateTimeTS": 1692856006000,
                    "message": "ReplicaSet \"training-platform-django-5dc8b9dc9c\" has successfully progressed.",
                    "reason": "NewReplicaSetAvailable",
                    "status": "True",
                    "type": "Progressing"
                },
                {
                    "lastTransitionTime": "2023-09-05T09:48:01Z",
                    "lastTransitionTimeTS": 1693907281000,
                    "lastUpdateTime": "2023-09-05T09:48:01Z",
                    "lastUpdateTimeTS": 1693907281000,
                    "message": "Deployment has minimum availability.",
                    "reason": "MinimumReplicasAvailable",
                    "status": "True",
                    "type": "Available"
                }
            ],
            "observedGeneration": 67,
            "readyReplicas": 1,
            "replicas": 1,
            "type": "/v3/project/schemas/deploymentStatus",
            "unavailableReplicas": 0,
            "updatedReplicas": 1
        },
        "dnsConfig": {
            "type": "/v3/project/schemas/podDNSConfig"
        },
        "dnsPolicy": "ClusterFirst",
        "hostIPC": false,
        "hostNetwork": false,
        "hostPID": false,
        "id": "deployment:season:training-platform-django",
        "labels": {
            "workload.user.cattle.io/workloadselector": "deployment-season-training-platform-django"
        },
        "links": {
            "remove": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django",
            "revisions": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django/revisions",
            "self": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django",
            "update": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django",
            "yaml": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-django/yaml"
        },
        "name": "training-platform-django",
        "namespaceId": "season",
        "paused": false,
        "projectId": "local:p-vhqv2",
        "publicEndpoints": [
            {
                "addresses": [
                    "10.41.241.111",
                    "10.41.241.112",
                    "10.41.241.113",
                    "10.41.241.114",
                    "10.41.241.115",
                    "10.41.241.116"
                ],
                "allNodes": false,
                "hostname": "training-platform-django.k8sprd-wzs.k8s.wistron.com.cn",
                "ingressId": "season:training-platform-django-ingress",
                "nodeId": null,
                "podId": null,
                "port": 80,
                "protocol": "HTTP",
                "serviceId": "season:ingress-053ebdc075a82cf5efbe1ac16b822ab4"
            },
            {
                "addresses": [
                    "10.41.241.111"
                ],
                "allNodes": true,
                "ingressId": null,
                "nodeId": null,
                "podId": null,
                "port": 30481,
                "protocol": "TCP",
                "serviceId": "season:training-platform-django-nodeport"
            }
        ],
        "restartPolicy": "Always",
        "scale": 1,
        "scheduling": {
            "scheduler": "default-scheduler"
        },
        "selector": {
            "matchLabels": {
                "workload.user.cattle.io/workloadselector": "deployment-season-training-platform-django"
            },
            "type": "/v3/project/schemas/labelSelector"
        },
        "state": "active",
        "terminationGracePeriodSeconds": 30,
        "transitioning": "no",
        "transitioningMessage": "",
        "type": "deployment",
        "uuid": "ab30eb79-f594-4de1-a615-b042b011b02f",
        "workloadAnnotations": {
            "deployment.kubernetes.io/revision": "12",
            "field.cattle.io/creatorId": "u-mp27e6gufb"
        },
        "workloadLabels": {
            "cattle.io/creator": "norman",
            "workload.user.cattle.io/workloadselector": "deployment-season-training-platform-django"
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175

    准备json.txt方法2(Vincent Wen方法)

    1.获取token
    在这里插入图片描述

    输入curl -H "Authorization: Bearer token-jgch5:wvcrwwpglhk5jxz2fxt2h2jwmd2f7znjbjmzg5gwg4pnrc2qp5h5r9" -H "Content-Type:application/json" -X GET https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist

    相当于是 curl -H "Authorization:${K8S_TOKEN}" -H "Content-Type:application/json" -X GET ${K8S_WORKLOAD_URL}
    在这里插入图片描述
    2. 复制并写入json.txt中。

    {
    	"actions": {
    		"pause": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=pause",
    		"redeploy": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=redeploy",
    		"resume": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=resume",
    		"rollback": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=rollback"
    	},
    	"annotations": {
    		"cattle.io/timestamp": "1693990188"
    	},
    	"baseType": "workload",
    	"containers": [{
    		"allowPrivilegeEscalation": false,
    		"image": "harbor-k8s.wzs.wistron.com.cn/season/training_platform_vue_dist:0.0.0-build30",
    		"imagePullPolicy": "IfNotPresent",
    		"initContainer": false,
    		"name": "training-platform-vue-dist",
    		"ports": [{
    			"containerPort": 8080,
    			"dnsName": "training-platform-vue-dist-nodeport",
    			"hostPort": 0,
    			"kind": "NodePort",
    			"name": "8080tcl",
    			"protocol": "TCP",
    			"sourcePort": 0,
    			"type": "/v3/project/schemas/containerPort"
    		}],
    		"privileged": false,
    		"readOnly": false,
    		"resources": {
    			"limits": {
    				"cpu": "300m",
    				"memory": "300Mi"
    			},
    			"type": "/v3/project/schemas/resourceRequirements"
    		},
    		"restartCount": 0,
    		"runAsNonRoot": false,
    		"stdin": true,
    		"stdinOnce": false,
    		"terminationMessagePath": "/dev/termination-log",
    		"terminationMessagePolicy": "File",
    		"tty": true,
    		"type": "/v3/project/schemas/container"
    	}],
    	"created": "2023-06-27T14:18:09Z",
    	"createdTS": 1687875489000,
    	"creatorId": null,
    	"deploymentConfig": {
    		"maxSurge": 1,
    		"maxUnavailable": 0,
    		"minReadySeconds": 0,
    		"progressDeadlineSeconds": 600,
    		"revisionHistoryLimit": 10,
    		"strategy": "RollingUpdate"
    	},
    	"deploymentStatus": {
    		"availableReplicas": 1,
    		"conditions": [{
    			"lastTransitionTime": "2023-09-07T02:04:59Z",
    			"lastTransitionTimeTS": 1694052299000,
    			"lastUpdateTime": "2023-09-07T02:04:59Z",
    			"lastUpdateTimeTS": 1694052299000,
    			"message": "ReplicaSet \"training-platform-vue-dist-7db7c6498f\" has successfully progressed.",
    			"reason": "NewReplicaSetAvailable",
    			"status": "True",
    			"type": "Progressing"
    		}, {
    			"lastTransitionTime": "2023-09-07T02:05:23Z",
    			"lastTransitionTimeTS": 1694052323000,
    			"lastUpdateTime": "2023-09-07T02:05:23Z",
    			"lastUpdateTimeTS": 1694052323000,
    			"message": "Deployment has minimum availability.",
    			"reason": "MinimumReplicasAvailable",
    			"status": "True",
    			"type": "Available"
    		}],
    		"observedGeneration": 74,
    		"readyReplicas": 1,
    		"replicas": 1,
    		"type": "/v3/project/schemas/deploymentStatus",
    		"unavailableReplicas": 0,
    		"updatedReplicas": 1
    	},
    	"dnsPolicy": "ClusterFirst",
    	"hostIPC": false,
    	"hostNetwork": false,
    	"hostPID": false,
    	"id": "deployment:season:training-platform-vue-dist",
    	"labels": {
    		"workload.user.cattle.io/workloadselector": "deployment-season-training-platform-vue-dist"
    	},
    	"links": {
    		"remove": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist",
    		"revisions": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist/revisions",
    		"self": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist",
    		"update": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist",
    		"yaml": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist/yaml"
    	},
    	"name": "training-platform-vue-dist",
    	"namespaceId": "season",
    	"paused": false,
    	"projectId": "local:p-vhqv2",
    	"publicEndpoints": [{
    		"addresses": ["10.41.241.111", "10.41.241.112", "10.41.241.113", "10.41.241.114", "10.41.241.115", "10.41.241.116"],
    		"allNodes": false,
    		"hostname": "training-platform.k8sprd-wzs.k8s.wistron.com.cn",
    		"ingressId": "season:training-platform-vue-dist-ingress",
    		"nodeId": null,
    		"podId": null,
    		"port": 80,
    		"protocol": "HTTP",
    		"serviceId": "season:ingress-9932efa3ab00c77c4cfb44b758c758b2"
    	}, {
    		"addresses": ["10.41.241.111"],
    		"allNodes": true,
    		"ingressId": null,
    		"nodeId": null,
    		"podId": null,
    		"port": 30396,
    		"protocol": "TCP",
    		"serviceId": "season:training-platform-vue-dist-nodeport"
    	}],
    	"restartPolicy": "Always",
    	"scale": 1,
    	"scheduling": {
    		"scheduler": "default-scheduler"
    	},
    	"selector": {
    		"matchLabels": {
    			"workload.user.cattle.io/workloadselector": "deployment-season-training-platform-vue-dist"
    		},
    		"type": "/v3/project/schemas/labelSelector"
    	},
    	"state": "active",
    	"terminationGracePeriodSeconds": 30,
    	"transitioning": "no",
    	"transitioningMessage": "",
    	"type": "deployment",
    	"uuid": "d63402fa-b097-4f01-9a6e-1db4e2b87912",
    	"workloadAnnotations": {
    		"deployment.kubernetes.io/revision": "21",
    		"field.cattle.io/creatorId": "u-mp27e6gufb"
    	},
    	"workloadLabels": {
    		"cattle.io/creator": "norman",
    		"workload.user.cattle.io/workloadselector": "deployment-season-training-platform-vue-dist"
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    1. 记得修改json.txt中image tag和 “cattle.io/timestamp”: “CHANGEME”。
    {
    	"actions": {
    		"pause": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=pause",
    		"redeploy": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=redeploy",
    		"resume": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=resume",
    		"rollback": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist?action=rollback"
    	},
    	"annotations": {
    		"cattle.io/timestamp": "CHANGEME"
    	},
    	"baseType": "workload",
    	"containers": [{
    		"allowPrivilegeEscalation": false,
    		"image": "harbor-k8s.wzs.wistron.com.cn/season/training_platform_vue_dist:0.0.0-buildCI_PIPELINE_IID", #(image需要修订版本号)
    		"imagePullPolicy": "IfNotPresent",
    		"initContainer": false,
    		"name": "training-platform-vue-dist",
    		"ports": [{
    			"containerPort": 8080,
    			"dnsName": "training-platform-vue-dist-nodeport",
    			"hostPort": 0,
    			"kind": "NodePort",
    			"name": "8080tcl",
    			"protocol": "TCP",
    			"sourcePort": 0,
    			"type": "/v3/project/schemas/containerPort"
    		}],
    		"privileged": false,
    		"readOnly": false,
    		"resources": {
    			"limits": {
    				"cpu": "300m",
    				"memory": "300Mi"
    			},
    			"type": "/v3/project/schemas/resourceRequirements"
    		},
    		"restartCount": 0,
    		"runAsNonRoot": false,
    		"stdin": true,
    		"stdinOnce": false,
    		"terminationMessagePath": "/dev/termination-log",
    		"terminationMessagePolicy": "File",
    		"tty": true,
    		"type": "/v3/project/schemas/container"
    	}],
    	"created": "2023-06-27T14:18:09Z",
    	"createdTS": 1687875489000,
    	"creatorId": null,
    	"deploymentConfig": {
    		"maxSurge": 1,
    		"maxUnavailable": 0,
    		"minReadySeconds": 0,
    		"progressDeadlineSeconds": 600,
    		"revisionHistoryLimit": 10,
    		"strategy": "RollingUpdate"
    	},
    	"deploymentStatus": {
    		"availableReplicas": 1,
    		"conditions": [{
    			"lastTransitionTime": "2023-09-07T02:04:59Z",
    			"lastTransitionTimeTS": 1694052299000,
    			"lastUpdateTime": "2023-09-07T02:04:59Z",
    			"lastUpdateTimeTS": 1694052299000,
    			"message": "ReplicaSet \"training-platform-vue-dist-7db7c6498f\" has successfully progressed.",
    			"reason": "NewReplicaSetAvailable",
    			"status": "True",
    			"type": "Progressing"
    		}, {
    			"lastTransitionTime": "2023-09-07T02:05:23Z",
    			"lastTransitionTimeTS": 1694052323000,
    			"lastUpdateTime": "2023-09-07T02:05:23Z",
    			"lastUpdateTimeTS": 1694052323000,
    			"message": "Deployment has minimum availability.",
    			"reason": "MinimumReplicasAvailable",
    			"status": "True",
    			"type": "Available"
    		}],
    		"observedGeneration": 74,
    		"readyReplicas": 1,
    		"replicas": 1,
    		"type": "/v3/project/schemas/deploymentStatus",
    		"unavailableReplicas": 0,
    		"updatedReplicas": 1
    	},
    	"dnsPolicy": "ClusterFirst",
    	"hostIPC": false,
    	"hostNetwork": false,
    	"hostPID": false,
    	"id": "deployment:season:training-platform-vue-dist",
    	"labels": {
    		"workload.user.cattle.io/workloadselector": "deployment-season-training-platform-vue-dist"
    	},
    	"links": {
    		"remove": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist",
    		"revisions": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist/revisions",
    		"self": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist",
    		"update": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist",
    		"yaml": "https://rancher-wzsarm.wistron.com/v3/project/local:p-vhqv2/workloads/deployment:season:training-platform-vue-dist/yaml"
    	},
    	"name": "training-platform-vue-dist",
    	"namespaceId": "season",
    	"paused": false,
    	"projectId": "local:p-vhqv2",
    	"publicEndpoints": [{
    		"addresses": ["10.41.241.111", "10.41.241.112", "10.41.241.113", "10.41.241.114", "10.41.241.115", "10.41.241.116"],
    		"allNodes": false,
    		"hostname": "training-platform.k8sprd-wzs.k8s.wistron.com.cn",
    		"ingressId": "season:training-platform-vue-dist-ingress",
    		"nodeId": null,
    		"podId": null,
    		"port": 80,
    		"protocol": "HTTP",
    		"serviceId": "season:ingress-9932efa3ab00c77c4cfb44b758c758b2"
    	}, {
    		"addresses": ["10.41.241.111"],
    		"allNodes": true,
    		"ingressId": null,
    		"nodeId": null,
    		"podId": null,
    		"port": 30396,
    		"protocol": "TCP",
    		"serviceId": "season:training-platform-vue-dist-nodeport"
    	}],
    	"restartPolicy": "Always",
    	"scale": 1,
    	"scheduling": {
    		"scheduler": "default-scheduler"
    	},
    	"selector": {
    		"matchLabels": {
    			"workload.user.cattle.io/workloadselector": "deployment-season-training-platform-vue-dist"
    		},
    		"type": "/v3/project/schemas/labelSelector"
    	},
    	"state": "active",
    	"terminationGracePeriodSeconds": 30,
    	"transitioning": "no",
    	"transitioningMessage": "",
    	"type": "deployment",
    	"uuid": "d63402fa-b097-4f01-9a6e-1db4e2b87912",
    	"workloadAnnotations": {
    		"deployment.kubernetes.io/revision": "21",
    		"field.cattle.io/creatorId": "u-mp27e6gufb"
    	},
    	"workloadLabels": {
    		"cattle.io/creator": "norman",
    		"workload.user.cattle.io/workloadselector": "deployment-season-training-platform-vue-dist"
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149

    修改.gitlab-ci.yml

    format

    update:
      stage: deploy
      image: harbor.wistron.com/base_image/alpine:3.10
      before_script:
        - apk add curl
        - export CI_JOB_TIMESTAMP=$(date +"%s")
      tags:
        - prd-runner02  # select your runner
      script:
        - MOVE TO YOUR JSON.TXT PATH
        - sed -i s/CHANGEME/$CI_JOB_TIMESTAMP/g json.txt
        - sed -i s/CI_PIPELINE_IID/$CI_PIPELINE_IID/g json.txt
        - curl -H "Authorization:${K8S_TOKEN}" -H "Content-Type:application/json" -d "@json.txt" -X PUT ${K8S_WORKLOAD_URL}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    我的代码.gitlab-ci.yml

    variables:
      DOCKER_IMAGE_NAME: training_platform_django
      DOCKER_IMAGE_TAG: 0.0.8
    
     
      
    services:
      - name: harbor-k8s.wzs.wistron.com.cn/base_image/docker:stable
        entrypoint: []
        command: ["--insecure-registry=harbor-k8s.wistron.com.cn"]
    
    stages:
      - docker_build
      - docker-update
    
    docker-build:
      image: harbor-k8s.wzs.wistron.com.cn/base_image/docker:stable
      stage: docker_build
      tags: 
        - wzs-runner01
      script:
        - docker info
        - echo $DOCKER_IMAGE_NAME
        - echo $DOCKER_IMAGE_TAG
        - docker build -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG .
        - docker tag $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG harbor-k8s.wzs.wistron.com.cn/season/$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-build$CI_PIPELINE_IID
        - echo "$HARBOR_PASSWORD" | docker login -u "$HARBOR_USER"  --password "$HARBOR_PASSWORD" harbor-k8s.wzs.wistron.com.cn
        - docker push harbor-k8s.wzs.wistron.com.cn/season/$DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG-build$CI_PIPELINE_IID
    
    
    
    docker-update:
      stage: docker-update
      image: harbor.wistron.com/base_image/alpine:3.10
      before_script:
        - apk add curl
        - export CI_JOB_TIMESTAMP=$(date +"%s")
      tags:
        - wzs-runner01
      script:
        - sed -i s/CHANGEME/$CI_JOB_TIMESTAMP/g json.txt
        - sed -i s/CI_PIPELINE_IID/$CI_PIPELINE_IID/g json.txt
        - curl -H "Authorization:${K8S_TOKEN}" -H "Content-Type:application/json" -d "@json.txt" -X PUT ${K8S_WORKLOAD_URL}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    gitlab pipeline

    显示成功
    在这里插入图片描述
    自动更新
    在这里插入图片描述
    在这里插入图片描述

  • 相关阅读:
    点击化学修饰多肽:DBCO-PEG-YIGSR/RVG29/R8/CCK8肽
    「Python」身份运算符 —— is 与 is not
    NLP-D58-nlp比赛D27&刷题D14&读论文&mathtype
    小白一键重装官网下载使用方法
    中间件漏洞 | Apache-路径穿越/任意命令执行
    2024年区块链、电子信息与计算机工程国际会议(ICBEICE 2024)
    Android6.0+修改通知栏与页面样式保持一致
    【SpringCloud】认识微服务、服务拆分以及远程调用
    Java笔记(4)
    手把手教你实现一个JavaWeb项目:创建一个自己的网页博客系统(前端+后端)(一)
  • 原文地址:https://blog.csdn.net/m0_46629123/article/details/132713313