CC00399.CloudKubernetes——|KuberNetes&CI/CD.V37|——|Jenkins.v03|生产UAT流水线设计.v03|

本文档介绍了如何在Jenkins中创建job,构建Node.js应用,并通过Kubernetes实现UAT环境的部署。涵盖了从配置jenkins宿主机到设置流水线参数,以及应用的滚动更新和访问验证。最后,还提供了在Jenkins中复制Jobs的操作指南。
摘要由CSDN通过智能技术生成
一、在jenkins下创建job
### --- 创建view item

~~~     Jenkins——>Dashboard——>+号——>View name:uat——> List View——>ok——>ok——>END
### --- 创建Jobs

~~~     Jenkins——>Dashboard——>New Item——>Enter an item name:nodejs-uat——>Copy from :nodejs-demo——>OK——>
~~~     ——>删除一些配置变量:BRANCH、REPO_URL、BUILD_COMMAND、DEPLOY——>
~~~     ——>更改一些配置变量:Hidden Parameter——>Name:CLUSTER——>Default Value:uat——>
~~~     ——>更改一些配置变量:Hidden ParameterName:NAMESPACE——>Default Value:nodejs-uat——>
~~~     ——>添加配置变量:Active Choices Reactive Parameter——>Name:IMAGE_TAG
~~~     ——>Groovy Script:见如下配置参数——>Fallback Script:Groovy Script:returm 'error'
~~~     ——>Choice Type:Single Select——>引用变量:Referenced parameters:REGISTRY_DIR,IMAGE_NAME——>
def get_tags = [ "bash", "-c", "aliyun cr GetRepoTags  --RepoNamespace ${REGISTRY_DIR} --RepoName ${IMAGE_NAME} | jq ' .data.tags[].tag' -r" ]

return get_tags.execute().text.tokenize('\n')
### --- ——>更改流水线配置:
~~~     Pipeline——>Definition:Pipeline script:Hello World:参数见下文——>Save

pipeline {
    agent any

    stages {
        stage('Hello') {
                steps {
                   sh """
                      echo ${IMAGE_TAG}
                   """
            }
        }
    }
}
二、build构建nodejs-demo
### --- build构建nodejs-demo

~~~     查看是否可以获取到镜像
~~~     查看是否可以打印出来tags
SuccessConsole Output
Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/nodejs-uat
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Hello)
[Pipeline] sh
+ echo 20210623-153619-87148f1-master
20210623-153619-87148f1-master          // tags打印完成
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
三、创建uat集群配置:在jenkins所在宿主机配置
### --- 创建multi-cluster.yaml文件

[root@k8s-node01 ~]# vim /mnt/.kube/multi-cluster.yaml
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ1RENDQXN5Z0F3SUJBZ0lVVGxFWHlnZFBnS0FURDh4SEJld0hEWUEyRnVvd0RRWUpLb1pJaHZjTkFRRUwKQlFBd2R6RUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFXcHBibWN4RURBT0JnTlZCQWNUQjBKbAphV3BwYm1jeEV6QVJCZ05WQkFvVENrdDFZbVZ5Ym1WMFpYTXhHakFZQmdOVkJBc1RFVXQxWW1WeWJtVjBaWE10CmJXRnVkV0ZzTVJNd0VRWURWUVFERXdwcmRXSmxjbTVsZEdWek1DQVhEVEl4TURVeE1qRXhNVGt3TUZvWUR6SXgKTWpFd05ERTRNVEV4T1RBd1dqQjNNUXN3Q1FZRFZRUUdFd0pEVGpFUU1BNEdBMVVFQ0JNSFFtVnBhbWx1WnpFUQpNQTRHQTFVRUJ4TUhRbVZwYW1sdVp6RVRNQkVHQTFVRUNoTUtTM1ZpWlhKdVpYUmxjekVhTUJnR0ExVUVDeE1SClMzVmlaWEp1WlhSbGN5MXRZVzUxWVd3eEV6QVJCZ05WQkFNVENtdDFZbVZ5Ym1WMFpYTXdnZ0VpTUEwR0NTcUcKU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQkFRQ1ZoNWhpSUtFcXBuK21oZDl1SndVK1ZCb1pYbmFKZ0JQOQpQTjRueGkvUittSmd5S01ZNlhEdWJXNzQ4Vm1jaG9qTWRzQWh1ZWNYeG5pUGVoZE9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0FURS0tLS0tCg==
    server: https://192.168.1.11:6443
  name: kubernetes
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQ1RENDQXN5Z0F3SUJBZ0lVVGxFWHlnZFBnS0FURDh4SEJld0hEWUEyRnVvd0RRWUpLb1pJaHZjTkFRRUwKQlFBd2R6RUxNQWtHQTFVRUJoTUNRMDR4RURBT0JnTlZCQWdUQjBKbGFXcHBibWN4RURBT0JnTlZCQWNUQjBKbAphV3BwYm1jeEV6QVJCZ05WQkFvVENrdDFZbVZ5Ym1WMFpYTXhHakFZQmdOVkJBc1RFVXQxWW1WeWJtVjBaWE10CmJXRnVkV0ZzTVJNd0VRWURWUVFERXdwcmRX
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yanqi_vip

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值