通过jenkins构建java应用程序发布到k8s集群中
本文已一个大数据的java项目来演示构建部署过程
支持发布和回滚
支持一套模板应用不同项目
k8s基础准备
创建项目名称空间
[root@k8s-master ~]# kubectl create ns architect namespace/architect created [root@k8s-master ~]# kubectl label namespace architect istio-injection=enabled namespace/architect labeled [root@k8s-master ~]# kubectl get namespace -L istio-injection NAME STATUS AGE ISTIO-INJECTION architect Active 87s enabled default Active 39d enabled istio-system Active 7d17h kube-public Active 39d kube-system Active 39d [root@k8s-master ~]#
创建全局配置文件
#创建大数据配置文件 [root@k8s-master ~]# ls bigdata-counter core-site.xml dmp_operator1.keytab hbase-site.xml hdfs-site.xml krb5.conf [root@k8s-master ~]# [root@k8s-master ~]# kubectl create configmap bigdata-config --from-file=/root/bigdata-counter/ -n architect configmap/bigdata-config created [root@k8s-master ~]# #全局环境变量 [root@k8s-master ~]# cat yaml/global-config.yaml apiVersion: v1 kind: ConfigMap metadata: name: global-config namespace: architect data: CONFIG_SERVER_URL: http://config.ms.xx.com CONFIG_SERVER_USER: myconfig ILOG_BOOTSTRAP_SERVERS: bootstrap.servers=192.168.1.122:9092 CONFIG_SERVER_PWDS: mc123456 [root@k8s-master ~]# [root@k8s-master ~]# kubectl apply -f yaml/global-config.yaml configmap/global-config created [root@k8s-master ~]# kubectl get configmap -n architect NAME DATA AGE bigdata-config 4 2m33s global-config 4 3s [root@k8s-master ~]#