k8s + gitlab + jenkins +docker 搭建企業級CI/CD 流水線操作
1.gitlab 安裝,管理項目源代碼
1.1 gitlab 安裝,優化
gitlab 優化 2.6G/8G
gitlab
puma =2
1.2 gitlab 管理界面--設定--項目通路令牌
1.3 webhooks 鈎子
2. jenkins 擷取gitlab 源代碼
2.1 系統配置--插件管理--安裝gitlab --gitlab plugin,gitlab hook plugin,ruby-runtime
2.2 配置 jenkins 憑證提供者:
源碼位址:
doman:全局憑據
類型選擇:gitlab api token
範圍:jenkins,nodes,items,all child items,tec
api token: gitlab 項目通路令牌
3.harbor 本地鏡像伺服器,存放鏡像
4.k8s叢集
pod:一個鏡像部署到3個容器,對外服務自動實作負載均衡
demo.yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: net6-demo-deployment
labels:
app: net6
spec:
# 配置rs
replicas: 3
selector:
matchLabels:
app: net6-rs
## 配置是POD模闆
template:
metadata:
labels:
app: net6-rs
env: testing
spec:
containers:
- name: net6-container
imagePullPolicy: Always
image: 192.168.3.251:9999/xxx/dotnet6-piepeline:1221
ports:
- name: net6-port
containerPort: 80 #必須和dockerfile中暴露端口一緻
---
apiVersion: v1
kind: Service
metadata:
name: net6-service
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 30335
selector:
app: net6-rs