真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

jenkins部署k8s項(xiàng)目-CICD-創(chuàng)新互聯(lián)

一 環(huán)境準(zhǔn)備

1 docker倉(cāng)庫(kù),harbor我這里用的是線上的hub https://hub.docker.com/ 自己注冊(cè)即可
2 準(zhǔn)備git倉(cāng)庫(kù),我這里用的是碼云 https://gitee.com/huningfei/java.git
3 準(zhǔn)備好k8s環(huán)境,一主兩從,可以二進(jìn)制安裝,也可以kubeadmin安裝
master:172.16.78.103 node1:172.16.78.102 node2:172.16.78.101
4 準(zhǔn)備好jenkins環(huán)境,(我是利用jenkins.war包直接部署的,也可以用k8s部署jenkins)

雨湖ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書(shū)未來(lái)市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書(shū)銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書(shū)合作)期待與您的合作!

二 k8s部署

我是用kubeadmin快速部署的 參考 https://cloud.tencent.com/developer/article/1509412
安裝之前,把iptables和selinux關(guān)掉。
1 master節(jié)點(diǎn)安裝

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
  269   yum -y install docker-ce-18.06.1.ce-3.el7

  271  curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
  272  systemctl enable docker && systemctl start docker
# 添加kubernetes YUM軟件源
  275  cat > /etc/yum.repos.d/kubernetes.repo << EOF
  276  [kubernetes]
  277  name=Kubernetes
  278  baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
  279  enabled=1
  280  gpgcheck=0
  281  repo_gpgcheck=0
  282  gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
  283  EOF
  284  ll /etc/yum.repos.d/kubernetes.repo 
#安裝kubeadm,kubelet和kubectl
  285  yum install -y kubelet-1.15.0 kubeadm-1.15.0 kubectl-1.15.0
  286  kubectl systemctl enable kubelet

 # 部署Kubernetes Master  只需要在Master 節(jié)點(diǎn)執(zhí)行,這里的apiserve需要修改成自己的master地址
 kubeadm init --apiserver-advertise-address=172.16.78.103 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.15.0 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16
 最后出現(xiàn)  Your Kubernetes control-plane has initialized successfully! 即為安裝成功

# 最后根據(jù)提示操作
 mkdir -p $HOME/.kube
 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
 sudo chown $(id -u):$(id -g) $HOME/.kube/config

# 安裝網(wǎng)絡(luò)插件
wget https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml

修改鏡像地址:(有可能默認(rèn)不能拉取,確保能夠訪問(wèn)到quay.io這個(gè)registery,否則修改如下內(nèi)容)
    cat -n  kube-flannel.yml|grep lizhenliang/flannel:v0.11.0-amd64
   106          image: lizhenliang/flannel:v0.11.0-amd64
   120          image: lizhenliang/flannel:v0.11.0-amd64
kubectl apply -f kube-flannel.yml 

2 node節(jié)點(diǎn)安裝

#!/bin/bash
#install docker
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
  yum -y install docker-ce-18.06.1.ce-3.el7
   curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
  systemctl enable docker && systemctl start docker

# repo
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

#install k8s
yum install -y kubelet-1.15.0 kubeadm-1.15.0 kubectl-1.15.0
systemctl enable kubelet

echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables

#join master
kubeadm join 172.16.78.103:6443 --token culxlo.ovuhhraplwritzgh     --discovery-token-ca-cert-hash sha256:3dfb2e64dfc2c603c1cfccceff82dbc1b680b117fdbbe0512889d3a74240a3b8
# 在加入的時(shí)候提示報(bào)錯(cuò):
[ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables]: /proc/sys/net/bridge/bridge-nf-call-iptables contents are not set to 1
    [ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

# 解決辦法
echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables

3 最后查看查看集群node狀態(tài)
jenkins部署k8s項(xiàng)目-CICD

三設(shè)置jenkins

1 安裝Kubernetes 和git,pipeline 安裝這三個(gè)插件,安裝maven和docker環(huán)境。

yum install maven
# install docker
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
  yum -y install docker-ce-18.06.1.ce-3.el7
   curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
  systemctl enable docker && systemctl start docker

 # 還需要注意一點(diǎn),如果你的jenkins是用普通用戶啟動(dòng)的,當(dāng)構(gòu)建的時(shí)候可能會(huì)提示權(quán)限問(wèn)題, 要改一下/var/run/docker.sock  這個(gè)文件的權(quán)限

2 設(shè)置jenkins去連接k8s api

系統(tǒng)管理---系統(tǒng)設(shè)置-cloud
jenkins部署k8s項(xiàng)目-CICD

kubernetes 服務(wù)證書(shū)從哪里來(lái)?

2-1 如果是kubeadmin部署的k8s,就比較麻煩,進(jìn)入到 /etc/kubernetes目錄下面打開(kāi)admin.conf配置文件,文件中有三個(gè)值 certificate-authority-data 、client-certificate-data 、 client-key-data 分別用這三部分生成證書(shū),這里我把生成的證書(shū)都放到了tmp目錄下面

echo LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1USXlOVEE0TVRFMU4xb1hEVEk1TVRJeU1qQTRNVEUxTjFvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh3Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBT0d6Ckl0RzFDMTMxL09ObXNJeERraTFrWDFyZ25kZ0hLRnBLTmJxNVl2R21jamh4a21SVjdnc3g2VGVIakpCY01welUKUFFGU3FkcjRldUJQTTM1MGhTSnkrODZpSWl5NWRzZTNONGw2bng1cjVyQzB1TEk1c1BLTXdLb3pGaHc4a0pFUwpLQnBpTFd2Q0VsTTljVlJKWnpiRENISWNHc09ZUklaWDBPcDJWNEh0U21FdlRuU0wrL1hEZmEzcUR1Y0NLVGNWCnNVWjNwdmRvMERCbEZzUUZPZDVQVDF4Rm13WmlSeDBneVJDS1VITDc0V1A3akk1eFZsYWMwczJ2QlRzaEp5L2IKTjBIcDM2RXQ2NUlLRHFrVjM4RS9ONEZEN3B2eWkxTGtxcWI3QXF5VG1VQlpsd2taclpPTnhuZFhUeGdWeXZVVApSRTBtZW1KNnAxaWp1MVFGKzZjQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFDUERiRXBzdlhVWVc2bW1LZjB2TjNkS0ZGN0kKbldUcUJBU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后到tmp目錄,在生成一個(gè)ca.crt證書(shū)和一個(gè)cert.pfx

openssl pkcs12 -export -out cert.pfx -inkey client.key -in client.crt -certfile ca.crt
 生成一個(gè)pfx的證書(shū),會(huì)提示你輸入密碼 111

然后將ca.crt里面的內(nèi)容放到j(luò)enkisn服務(wù)證書(shū)key的地方即可。

如何添加憑據(jù)?

點(diǎn)擊add,選擇kind類型,然后上傳你剛才生成的cert.pfx這個(gè)證書(shū),并且輸入剛才的密碼
jenkins部署k8s項(xiàng)目-CICD

最終去測(cè)試jenkins能否連接成功,如圖
jenkins部署k8s項(xiàng)目-CICD

2-2 如果你的jenkins是直接部署在k8s之內(nèi)的,就比較簡(jiǎn)單,不需要填寫(xiě)證書(shū),直接這樣,如圖:

jenkins部署k8s項(xiàng)目-CICD

2-3如果你是用的二進(jìn)制安裝的k8s,這個(gè)證書(shū)在安裝過(guò)程中,會(huì)產(chǎn)生,我測(cè)試了用ca.pem和server.pem發(fā)現(xiàn)都可以連接,并且不需要添加憑據(jù)。

jenkins部署k8s項(xiàng)目-CICD

四 用pipeline發(fā)布k8s項(xiàng)目

jenkins部署k8s項(xiàng)目-CICD

腳本內(nèi)容如下:

// 公共
def registry = "huningfei"
// 項(xiàng)目
def project = "welcome"
def app_name = "demo"
def image_name = "${registry}/${project}:${BUILD_NUMBER}"
def git_address = "https://gitee.com/huningfei/java.git"
// 認(rèn)證
def secret_name = "registry-pull-secret"
def docker_registry_auth = "450fb8b4-62c9-43fe-8a69-ec30705e724e"
def git_auth = "b363af0f-a96c-465c-a14e-60f7127727eb"
def k8s_auth = "a60b4b7f-2aef-4622-94a5-6efef67c4ac9"

  node(){
      // 第一步
      stage('拉取代碼'){
         checkout([$class: 'GitSCM', branches: [[name: '${Branch}']], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_address}"]]])
      }
      // 第二步
      stage('代碼編譯'){
          sh "mvn clean package -Dmaven.test.skip=true"
      }
      // 第三步
      stage('構(gòu)建鏡像'){
          withCredentials([usernamePassword(credentialsId: "${docker_registry_auth}", passwordVariable: 'password', usernameVariable: 'username')]) {
            sh """
              echo '
                FROM lizhenliang/tomcat 
                RUN rm -rf /usr/local/tomcat/webapps/*
                ADD target/*.war /usr/local/tomcat/webapps/ROOT.war 
              ' > Dockerfile
              docker build -t ${image_name} .
              docker login -u ${username} -p '${password}'
              docker push ${image_name}
            """
            }
      }
      // 第四步
      stage('部署到K8S平臺(tái)'){
          sh """
          sed -i 's#\$IMAGE_NAME#${image_name}#' deploy.yml
          sed -i 's#\$SECRET_NAME#${secret_name}#' deploy.yml
          """
          kubernetesDeploy configs: 'deploy.yml', kubeconfigId: "${k8s_auth}"
      }
  }

###注意: 腳本里面的deploy.yml是部署k8s的文件,這個(gè)文件必須存到gitlab倉(cāng)庫(kù)里面就是要跟代碼在同一級(jí)目錄里面

腳本上面三個(gè)認(rèn)證的id從哪里獲取?

jenkins部署k8s項(xiàng)目-CICD

添加完成之后,去憑據(jù)里面查看即可

jenkins部署k8s項(xiàng)目-CICD

最后構(gòu)建項(xiàng)目
出現(xiàn)下面即可成功

jenkins部署k8s項(xiàng)目-CICD

然后到k8s-master上面查看是否生成新的pod容器
jenkins部署k8s項(xiàng)目-CICD

查看ingress
jenkins部署k8s項(xiàng)目-CICD

綁定host即可訪問(wèn)

jenkins部署k8s項(xiàng)目-CICD

五 測(cè)試修復(fù)一個(gè)bug,提交代碼,重新部署

這個(gè)java項(xiàng)目需要連接數(shù)據(jù)庫(kù),在配置文件改一下數(shù)據(jù)庫(kù)的地址,然后提交代碼,重新構(gòu)建
1 準(zhǔn)備一個(gè)數(shù)據(jù)庫(kù),授權(quán)一個(gè)用戶


 grant all on *.* to 'demo'@'%'identified by '123456';

2 修改代碼里面連接數(shù)據(jù)庫(kù)的地址

vim tomcat-java-demo-master/src/main/resources/application.yml

 url: jdbc:mysql://db-0.mysql:3306/test?characterEncoding=utf-8

3 安裝mysql,我這里用k8s直接創(chuàng)建

[root@sass001 java-demo]# cat mysql.yaml 
apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels: 
    project: java-demo
    app: mysql
spec:
  ports:
  - port: 3306 
    name: mysql 
  clusterIP: None
  selector:
    project: java-demo
    app: mysql

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: db
spec:
  selector:
    matchLabels:
      project: java-demo
      app: mysql
  serviceName: "mysql"
  template:
    metadata:
      labels:
        project: java-demo
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql:5.7 
        ports: 
        - containerPort: 3306
        env: 
        - name: MYSQL_ROOT_PASSWORD
          value: "123456"
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: data
  volumeClaimTemplates:
  - metadata:
      name: data 
    spec:
      accessModes: ["ReadWriteOnce"]
      storageClassName: "managed-nfs-storage"
      resources:
        requests:
          storage: 2Gi

kubectl create -f mysql.yaml

jenkins部署k8s項(xiàng)目-CICD

修改完代碼之后,提交到git倉(cāng)庫(kù),最后在重新發(fā)布項(xiàng)目

最后測(cè)試功能

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。


標(biāo)題名稱:jenkins部署k8s項(xiàng)目-CICD-創(chuàng)新互聯(lián)
當(dāng)前地址:http://weahome.cn/article/dopegp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部