ZBLOG

k3s 搭建harbor配置文件

以下是使用 k3s 搭建 Harbor 的配置文件示例。请将该文件保存为 harbor.yaml 并使用 kubectl apply -f harbor.yaml 命令应用该配置:

  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: harbor
  5. ---
  6. # 创建 MySQL 数据库
  7. apiVersion: v1
  8. kind: PersistentVolumeClaim
  9. metadata:
  10. name: harbor-database-pvc
  11. namespace: harbor
  12. spec:
  13. accessModes:
  14. - ReadWriteOnce
  15. resources:
  16. requests:
  17. storage: 20Gi
  18. ---
  19. apiVersion: apps/v1
  20. kind: Deployment
  21. metadata:
  22. name: harbor-database
  23. namespace: harbor
  24. spec:
  25. selector:
  26. matchLabels:
  27. app: harbor-database
  28. replicas: 1
  29. template:
  30. metadata:
  31. labels:
  32. app: harbor-database
  33. spec:
  34. containers:
  35. - name: harbor-database
  36. image: mysql:5.7
  37. env:
  38. - name: MYSQL_ROOT_PASSWORD
  39. valueFrom:
  40. secretKeyRef:
  41. name: harbor-database-secret
  42. key: password
  43. - name: MYSQL_DATABASE
  44. value: registry
  45. ports:
  46. - containerPort: 3306
  47. name: mysql
  48. volumeMounts:
  49. - name: harbor-database-data
  50. mountPath: /var/lib/mysql
  51. volumes:
  52. - name: harbor-database-data
  53. persistentVolumeClaim:
  54. claimName: harbor-database-pvc
  55. ---
  56. # 创建 Redis 缓存
  57. apiVersion: v1
  58. kind: Service
  59. metadata:
  60. name: harbor-cache
  61. namespace: harbor
  62. spec:
  63. ports:
  64. - port: 6379
  65. targetPort: 6379
  66. protocol: TCP
  67. selector:
  68. app: harbor-cache
  69. type: ClusterIP
  70. ---
  71. apiVersion: apps/v1
  72. kind: Deployment
  73. metadata:
  74. name: harbor-cache
  75. namespace: harbor
  76. spec:
  77. selector:
  78. matchLabels:
  79. app: harbor-cache
  80. replicas: 1
  81. template:
  82. metadata:
  83. labels:
  84. app: harbor-cache
  85. spec:
  86. containers:
  87. - name: harbor-cache
  88. image: redis:5.0.4-alpine
  89. ports:
  90. - containerPort: 6379
  91. name: redis
  92. ---
  93. # 创建 Harbor Core 组件
  94. apiVersion: v1
  95. kind: Service
  96. metadata:
  97. name: harbor-core
  98. namespace: harbor
  99. spec:
  100. ports:
  101. - port: 80
  102. targetPort: 80
  103. protocol: TCP
  104. - port: 443
  105. targetPort: 443
  106. protocol: TCP
  107. selector:
  108. app: harbor-core
  109. type: NodePort
  110. ---
  111. apiVersion: apps/v1
  112. kind: Deployment
  113. metadata:
  114. name: harbor-core
  115. namespace: harbor
  116. spec:
  117. selector:
  118. matchLabels:
  119. app: harbor-core
  120. replicas: 1
  121. template:
  122. metadata:
  123. labels:
  124. app: harbor-core
  125. spec:
  126. containers:
  127. - name: harbor-core
  128. image: harbor/harbor-core:v2.2.3
  129. env:
  130. - name: DATABASE_PASSWORD
  131. valueFrom:
  132. secretKeyRef:
  133. name: harbor-database-secret
  134. key: password
  135. - name: REDIS_PASSWORD
  136. valueFrom:
  137. secretKeyRef:
  138. name: harbor-redis-secret
  139. key: password
  140. - name: HARBOR_ADMIN_PASSWORD
  141. valueFrom:
  142. secretKeyRef:
  143. name: harbor-admin-secret
  144. key: password
  145. - name: HARBOR_SECRETKEY
  146. valueFrom:
  147. secretKeyRef:
  148. name: harbor-core-secret
  149. key: secretkey
  150. - name: HARBOR_TOKEN_SERVICE_HOST
  151. value: "harbor-core"
  152. - name: HARBOR_TOKEN_SERVICE_PORT_HTTPS
  153. value: "4443"
  154. ports:
  155. - containerPort: 80
  156. name: http
  157. - containerPort: 443
  158. name: https
  159. volumeMounts:
  160. - name: harbor-data
  161. mountPath: /data
  162. volumes:
  163. - name: harbor-data
  164. persistentVolumeClaim:
  165. claimName: harbor-data-pvc
  166. ---
  167. # 创建 Harbor Registry 组件
  168. apiVersion: v1
  169. kind: Service
  170. metadata:
  171. name: harbor-registry
  172. namespace: harbor
  173. spec:
  174. ports:
  175. - port: 5000
  176. targetPort: 5000
  177. protocol: TCP
  178. selector:
  179. app: harbor-registry
  180. type: NodePort
  181. ---
  182. apiVersion: apps/v1
  183. kind: Deployment
  184. metadata:
  185. name: harbor-registry
  186. namespace: harbor
  187. spec:
  188. selector:
  189. matchLabels:
  190. app: harbor-registry
  191. replicas: 1
  192. template:
  193. metadata:
  194. labels:
  195. app: harbor-registry
  196. spec:
  197. containers:
  198. - name: harbor-registry
  199. image: harbor/harbor-registry:v2.2.3
  200. env:
  201. - name: REGISTRY_STORAGE_DELETE_ENABLED
  202. value: "true"
  203. - name: REGISTRY_LOG_LEVEL
  204. value: "debug"
  205. - name: REGISTRY_STORAGE
  206. value: filesystem
  207. - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
  208. value: /storage
  209. - name: REGISTRY_HTTP_TLS_CERTIFICATE
  210. valueFrom:
  211. secretKeyRef:
  212. name: harbor-registry-secret
  213. key: tls.crt
  214. - name: REGISTRY_HTTP_TLS_KEY
  215. valueFrom:
  216. secretKeyRef:
  217. name: harbor-registry-secret
  218. key: tls.key
  219. ports:
  220. - containerPort: 5000
  221. name: registry
  222. volumeMounts:
  223. - name: harbor-data
  224. mountPath: /data
  225. volumes:
  226. - name: harbor-data
  227. persistentVolumeClaim:
  228. claimName: harbor-data-pvc
  229. ---
  230. # 创建 Harbor UI 组件
  231. apiVersion: v1
  232. kind: Service
  233. metadata:
  234. name: harbor-ui
  235. namespace: harbor
  236. spec:
  237. ports:
  238. - port: 80
  239. targetPort: 80
  240. protocol: TCP
  241. selector:
  242. app: harbor-core
  243. type: NodePort
  244. ---
  245. apiVersion: apps/v1
  246. kind: Deployment
  247. metadata:
  248. name: harbor-ui
  249. namespace: harbor
  250. spec:
  251. selector:
  252. matchLabels:
  253. app: harbor-core
  254. replicas: 1
  255. template:
  256. metadata:
  257. labels:
  258. app: harbor-core
  259. spec:
  260. containers:
  261. - name: harbor-ui
  262. image: harbor/harbor-ui:v2.2.3
  263. env:
  264. - name: HARBOR_ADMIN_PASSWORD
  265. valueFrom:
  266. secretKeyRef:
  267. name: harbor-admin-secret
  268. key: password
  269. - name: HARBOR_SECRETKEY
  270. valueFrom:
  271. secretKeyRef:
  272. name: harbor-core-secret
  273. key: secretkey
  274. ports:
  275. - containerPort: 80
  276. name: http
  277. volumeMounts:
  278. - name: harbor-data
  279. mountPath: /data
  280. volumes:
  281. - name: harbor-data
  282. persistentVolumeClaim:
  283. claimName: harbor-data-pvc

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=1910

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?