本文共 1529 字,大约阅读时间需要 5 分钟。
Jenkins + Kubernetes CI/CD
步骤如下在Jenkins所在ECS安装kubectl,用以访问Kubernetes集群
wget https://dl.k8s.io/v1.10.6/kubernetes-client-linux-amd64.tar.gztar -xvf kubernetes-client-linux-amd64.tar.gzcd kubernetes/client/binchmod +x ./kubectlsudo mv ./kubectl /usr/local/bin/kubectlmkdir /root/.kubevi /root/.kube/config
安装Docker
# step 1: 安装必要的一些系统工具sudo apt-get updatesudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common# step 2: 安装GPG证书curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -# Step 3: 写入软件源信息sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"# Step 4: 更新并安装 Docker-CEsudo apt-get -y updatesudo apt-get -y install docker-ce
apt-get install maven -y
选择Spring Boot Demo项目,Dockerfile放根目录
FROM openjdk:8-jdk-alpineVOLUME /tmpARG JAR_FILECOPY ${JAR_FILE} app.jarENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
mvn clean packagedocker build --build-arg JAR_FILE=target/gs-spring-boot-docker-0.1.0.jar -t registry.cn-beijing.aliyuncs.com/ycdocker/demo:$BUILD_NUMBER .docker login --username=***** --password=***** registry.cn-beijing.aliyuncs.comdocker push registry.cn-beijing.aliyuncs.com/ycdocker/demo:$BUILD_NUMBERkubectl set image deployment/demo demo=registry.cn-beijing.aliyuncs.com/ycdocker/demo:$BUILD_NUMBER
转载地址:http://sphna.baihongyu.com/