1. apiVersion: v1
    2. kind: Service
    3. metadata:
    4. name: zk-hs
    5. namespace: ufm-dev
    6. labels:
    7. k8s-app: zk
    8. spec:
    9. ports:
    10. - port: 2888
    11. name: server
    12. - port: 3888
    13. name: leader-election
    14. clusterIP: None
    15. selector:
    16. k8s-app: zk
    17. ---
    18. apiVersion: v1
    19. kind: Service
    20. metadata:
    21. name: zk-cs
    22. namespace: ufm-dev
    23. labels:
    24. k8s-app: zk
    25. spec:
    26. ports:
    27. - port: 2181
    28. name: client
    29. selector:
    30. k8s-app: zk
    31. ---
    32. apiVersion: policy/v1beta1
    33. kind: PodDisruptionBudget
    34. metadata:
    35. name: zk-pdb
    36. namespace: ufm-dev
    37. spec:
    38. selector:
    39. matchLabels:
    40. k8s-app: zk
    41. maxUnavailable: 1
    42. ---
    43. apiVersion: apps/v1
    44. kind: StatefulSet
    45. metadata:
    46. name: zk
    47. namespace: ufm-dev
    48. spec:
    49. selector:
    50. matchLabels:
    51. k8s-app: zk
    52. serviceName: zk-hs
    53. replicas: 1
    54. updateStrategy:
    55. type: RollingUpdate
    56. podManagementPolicy: Parallel
    57. template:
    58. metadata:
    59. labels:
    60. k8s-app: zk
    61. spec:
    62. affinity:
    63. podAffinity:
    64. requiredDuringSchedulingIgnoredDuringExecution:
    65. - labelSelector:
    66. matchExpressions:
    67. - key: "k8s-app"
    68. operator: In
    69. values:
    70. - zk
    71. topologyKey: "kubernetes.io/hostname"
    72. containers:
    73. - name: zookeeper
    74. imagePullPolicy: Always
    75. image: "registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/zookeeper:v3.4.10"
    76. resources:
    77. requests:
    78. cpu: 250m
    79. memory: 500Mi
    80. ports:
    81. - containerPort: 2181
    82. name: client
    83. - containerPort: 2888
    84. name: server
    85. - containerPort: 3888
    86. name: leader-election
    87. command:
    88. - sh
    89. - -c
    90. - "start-zookeeper \
    91. --servers=1 \
    92. --data_dir=/var/lib/zookeeper/data \
    93. --data_log_dir=/var/lib/zookeeper/data/log \
    94. --conf_dir=/opt/zookeeper/conf \
    95. --client_port=2181 \
    96. --election_port=3888 \
    97. --server_port=2888 \
    98. --tick_time=2000 \
    99. --init_limit=10 \
    100. --sync_limit=5 \
    101. --heap=512M \
    102. --max_client_cnxns=60 \
    103. --snap_retain_count=3 \
    104. --purge_interval=12 \
    105. --max_session_timeout=40000 \
    106. --min_session_timeout=4000 \
    107. --log_level=INFO"
    108. readinessProbe:
    109. exec:
    110. command:
    111. - sh
    112. - -c
    113. - "zookeeper-ready 2181"
    114. initialDelaySeconds: 10
    115. timeoutSeconds: 5
    116. livenessProbe:
    117. exec:
    118. command:
    119. - sh
    120. - -c
    121. - "zookeeper-ready 2181"
    122. initialDelaySeconds: 10
    123. timeoutSeconds: 5
    124. restartPolicy: Always
    125. securityContext:
    126. runAsUser: 1000
    127. fsGroup: 1000
    128. ######################################################################################################################
    129. ---
    130. kind: Service
    131. apiVersion: v1
    132. metadata:
    133. name: mysql-hs
    134. namespace: ufm-dev
    135. labels:
    136. k8s-app: mysql
    137. spec:
    138. ports:
    139. - port: 3306
    140. name: client
    141. selector:
    142. k8s-app: mysql
    143. clusterIP: None
    144. type: ClusterIP
    145. ---
    146. apiVersion: apps/v1
    147. kind: StatefulSet
    148. metadata:
    149. name: mysql
    150. namespace: ufm-dev
    151. labels:
    152. k8s-app: mysql
    153. spec:
    154. replicas: 1
    155. selector:
    156. matchLabels:
    157. k8s-app: mysql
    158. serviceName: mysql-hs
    159. template:
    160. metadata:
    161. labels:
    162. k8s-app: mysql
    163. spec:
    164. affinity:
    165. podAffinity:
    166. requiredDuringSchedulingIgnoredDuringExecution:
    167. - labelSelector:
    168. matchExpressions:
    169. - key: "k8s-app"
    170. operator: In
    171. values:
    172. - mysql
    173. topologyKey: "kubernetes.io/hostname"
    174. containers:
    175. - name: mysql
    176. image: registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/mysql:v5.7
    177. imagePullPolicy: Always
    178. env:
    179. - name: MYSQL_ROOT_PASSWORD
    180. value: root
    181. - name: "HOST_IP"
    182. valueFrom:
    183. fieldRef:
    184. fieldPath: status.podIP
    185. resources:
    186. requests:
    187. cpu: 250m
    188. memory: 500Mi
    189. livenessProbe:
    190. exec:
    191. command: ["mysqladmin", "-ucanal", "-pcanal", "ping"]
    192. initialDelaySeconds: 30
    193. periodSeconds: 10
    194. timeoutSeconds: 5
    195. readinessProbe:
    196. exec:
    197. command: ["mysql", "-hlocalhost", "-ucanal", "-pcanal", "-euse mysql;select 1"]
    198. initialDelaySeconds: 20
    199. periodSeconds: 2
    200. timeoutSeconds: 1
    201. ports:
    202. - containerPort: 3306
    203. name: client
    204. restartPolicy: Always
    205. ######################################################################################################################
    206. ---
    207. apiVersion: networking.k8s.io/v1beta1
    208. kind: Ingress
    209. metadata:
    210. labels:
    211. k8s-app: canal-admin
    212. name: canal-admin-ingress
    213. namespace: ufm-dev
    214. spec:
    215. rules:
    216. - host: canal.yalonglee.cn
    217. http:
    218. paths:
    219. - path: /
    220. backend:
    221. serviceName: canal-admin
    222. servicePort: 8089
    223. ---
    224. kind: Service
    225. apiVersion: v1
    226. metadata:
    227. name: canal-admin
    228. namespace: ufm-dev
    229. labels:
    230. k8s-app: canal-admin
    231. spec:
    232. ports:
    233. - port: 8089
    234. name: admin-port
    235. selector:
    236. k8s-app: canal-admin
    237. ---
    238. apiVersion: apps/v1
    239. kind: Deployment
    240. metadata:
    241. name: canal-admin
    242. namespace: ufm-dev
    243. labels:
    244. k8s-app: canal-admin
    245. spec:
    246. replicas: 1
    247. selector:
    248. matchLabels:
    249. k8s-app: canal-admin
    250. template:
    251. metadata:
    252. labels:
    253. k8s-app: canal-admin
    254. spec:
    255. containers:
    256. - name: canal-admin
    257. image: registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/canal-admin:v1.1.4
    258. imagePullPolicy: Always
    259. env:
    260. - name: "canal.adminUser"
    261. value: "admin"
    262. - name: "canal.adminPasswd"
    263. value: "admin"
    264. - name: "server.port"
    265. value: "8089"
    266. resources:
    267. requests:
    268. cpu: 500m
    269. memory: 1Gi
    270. ports:
    271. - containerPort: 8089
    272. name: admin-port
    273. initContainers:
    274. - name: init-db
    275. image: registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/busybox:1.28.4
    276. command: ['sh', '-c', 'until nslookup mysql-0.mysql-hs; do echo waiting for mysql-0.mysql-hs; sleep 2; done;']
    277. restartPolicy: Always
    278. ######################################################################################################################
    279. ---
    280. kind: Service
    281. apiVersion: v1
    282. metadata:
    283. name: canal-server-hs
    284. namespace: ufm-dev
    285. labels:
    286. k8s-app: canal-server
    287. spec:
    288. ports:
    289. - port: 11110
    290. name: canal-admin-port
    291. - port: 11111
    292. name: canal-server-port
    293. - port: 11112
    294. name: metrics-port
    295. selector:
    296. k8s-app: canal-server
    297. clusterIP: None
    298. type: ClusterIP
    299. ---
    300. apiVersion: apps/v1
    301. kind: StatefulSet
    302. metadata:
    303. name: canal-server
    304. namespace: ufm-dev
    305. labels:
    306. k8s-app: canal-server
    307. spec:
    308. replicas: 1
    309. selector:
    310. matchLabels:
    311. k8s-app: canal-server
    312. serviceName: canal-server-hs
    313. template:
    314. metadata:
    315. labels:
    316. k8s-app: canal-server
    317. spec:
    318. affinity:
    319. podAffinity:
    320. requiredDuringSchedulingIgnoredDuringExecution:
    321. - labelSelector:
    322. matchExpressions:
    323. - key: "k8s-app"
    324. operator: In
    325. values:
    326. - canal-server
    327. topologyKey: "kubernetes.io/hostname"
    328. containers:
    329. - name: canal-server
    330. image: registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/canal-server:v1.1.4
    331. imagePullPolicy: Always
    332. env:
    333. # tcp bind ip
    334. - name: "canal.ip"
    335. valueFrom:
    336. fieldRef:
    337. fieldPath: status.podIP
    338. # register ip to zookeeper
    339. - name: "canal.register.ip"
    340. valueFrom:
    341. fieldRef:
    342. fieldPath: status.podIP
    343. # podName + serviceName + namespace = hostname
    344. - name: "canal.pod.name"
    345. valueFrom:
    346. fieldRef:
    347. fieldPath: metadata.name
    348. - name: "canal.service.name"
    349. value: "canal-server-hs"
    350. - name: "canal.namespace"
    351. valueFrom:
    352. fieldRef:
    353. fieldPath: metadata.namespace
    354. # canal-admin的端口号
    355. - name: "canal.admin.port"
    356. value: "11110"
    357. # canal-server的tcp端口号
    358. - name: "canal.port"
    359. value: "11111"
    360. # canal-admin的账号
    361. - name: "canal.admin.user"
    362. value: "admin"
    363. # canal-admin的密码(数据库加密后的密文)
    364. - name: "canal.admin.passwd"
    365. value: "4ACFE3202A5FF5CF467898FC58AAB1D615029441"
    366. # 是否自动向canal-admin进行注册
    367. - name: "canal.admin.register.auto"
    368. value: "true"
    369. # 自动注册至对应的集群
    370. - name: "canal.admin.register.cluster"
    371. value: "default"
    372. resources:
    373. requests:
    374. cpu: 500m
    375. memory: 2Gi
    376. ports:
    377. - containerPort: 11110
    378. name: admin-port
    379. - containerPort: 11111
    380. name: canal-port
    381. - containerPort: 11112
    382. name: metrics-port
    383. initContainers:
    384. - name: init-zk
    385. image: registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/busybox:1.28.4
    386. command: ['sh', '-c', 'until nslookup zk-cs; do echo waiting for zk-hs; sleep 2; done;']
    387. - name: init-canal-admin
    388. image: registry.cn-hangzhou.aliyuncs.com/yalong_lee_release/busybox:1.28.4
    389. command: ['sh', '-c', 'until nslookup canal-admin; do echo waiting for zk-hs; sleep 2; done;']
    390. restartPolicy: Always

    用户 密码 admin/123456