标签:eve push start exp star selector tar 根据 四十二
总体流程:
在第四十三章 微服务CICD(5)- gitlab + jenkins + docker中,实现了前两步。本节实现第三步
一、打通jenkins与k8s-master两台机器之间的ssh无密码访问
参考:第四十二章 微服务CICD(4)- jenkins + gitlab + webhooks + publish-over-ssh(2)
添加ssh server:
说明:由于不需要拷贝jenkins机器上的文件到10.211.55.6,所以Remote Directory不填。
二、jenkins服务配置
选择机器,执行命令。
三、k8s-master(10.211.55.6)
1、在/data/目录下创建rc和svc文件
1.1、myservice1-docker-rc.yaml
1 apiVersion: v1 2 kind: ReplicationController 3 metadata: 4 name: myservice1-docker 5 spec: 6 replicas: 2 7 selector: 8 app: myservice1-docker 9 template: 10 metadata: 11 labels: 12 app: myservice1-docker 13 spec: 14 containers: 15 - name: myservice1-docker 16 image: 10.211.55.4:5000/com.xxx/myservice1-docker:1.0-SNAPSHOT 17 imagePullPolicy: Always 18 ports: 19 - containerPort: 8080
说明:imagePullPolicy:
1.2、myservice1-docker-svc.yaml
1 apiVersion: v1 2 kind: Service 3 metadata: 4 name: myservice1-docker 5 spec: 6 type: NodePort 7 ports: 8 - port: 8080 9 nodePort: 30001 10 selector: 11 app: myservice1-docker
2、在/data/script/目录下创建service_start.sh脚本
1 #!/bin/bash 2 export service_name=$1 3 sleep_second=3 4 5 echo ‘kubectl delete rc ${service_name}‘ 6 kubectl delete rc ${service_name} 7 8 echo ‘kubectl delete service ${service_name}‘ 9 kubectl delete service ${service_name} 10 11 echo ‘kubectl delete pods -l app=${service_name}‘ 12 kubectl delete pods -l app=${service_name} 13 14 sleep ${sleep_second} 15 16 echo ‘create rc‘ 17 kubectl create -f /data/${service_name}-rc.yaml 18 19 echo ‘create service‘ 20 kubectl create -f /data/${service_name}-svc.yaml
说明:
三、测试
1、本地:
2、查看jenkins的console
3、浏览器访问http://10.211.55.8:30001/docker/hello
gitlab + jenkins + docker + k8s
标签:eve push start exp star selector tar 根据 四十二
原文地址:http://www.cnblogs.com/wudonghang/p/7017060.html