ZBLOG

k3s 搭建harbor配置文件

以下是k3s搭建Harbor的配置文件:

  1. 创建harbor.yaml文件
  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: harbor
  5. ---
  6. apiVersion: v1
  7. kind: ServiceAccount
  8. metadata:
  9. name: harbor-admin
  10. namespace: harbor
  11. ---
  12. apiVersion: rbac.authorization.k8s.io/v1beta1
  13. kind: ClusterRoleBinding
  14. metadata:
  15. name: harbor-admin
  16. roleRef:
  17. apiGroup: rbac.authorization.k8s.io
  18. kind: ClusterRole
  19. name: cluster-admin
  20. subjects:
  21. - kind: ServiceAccount
  22. name: harbor-admin
  23. namespace: harbor
  24. ---
  25. # Configuration for Harbor
  26. apiVersion: v1
  27. kind: ConfigMap
  28. metadata:
  29. name: harbor-config
  30. namespace: harbor
  31. data:
  32. harbor.yml: |
  33. # Configuration file for Harbor
  34. hostname: <your harbor hostname>
  35. http:
  36. port: 80
  37. tls:
  38. certificate: /harbor_cert/harbor.crt
  39. private_key: /harbor_cert/harbor.key
  40. ca_certificate: /harbor_cert/ca.crt
  41. https:
  42. port: 443
  43. tls:
  44. certificate: /harbor_cert/harbor.crt
  45. private_key: /harbor_cert/harbor.key
  46. ca_certificate: /harbor_cert/ca.crt
  47. db:
  48. password: <your db password>
  49. external_url: https://<your harbor hostname>
  50. jobservice:
  51. max_job_workers: 10
  52. log:
  53. level: info
  54. rotate_size: 200M
  55. persistence:
  56. enabled: true
  57. size: 20Gi
  58. registry:
  59. url: https://<your harbor hostname>
  60. storage:
  61. s3:
  62. accesskey: <your s3 accesskey>
  63. secretkey: <your s3 secretkey>
  64. region: <your s3 region>
  65. bucket: <your s3 bucket>
  66. token_service:
  67. issuer: harbor-token-issuer
  68. trivy:
  69. enabled: true
  70. image_ref: docker.io/aquasec/trivy:0.20.1
  71. insecure_skip_tls_verify: true
  72. ---
  73. # Harbor deployment
  74. apiVersion: apps/v1
  75. kind: Deployment
  76. metadata:
  77. name: harbor
  78. namespace: harbor
  79. spec:
  80. selector:
  81. matchLabels:
  82. app: harbor
  83. replicas: 1
  84. template:
  85. metadata:
  86. labels:
  87. app: harbor
  88. spec:
  89. serviceAccountName: harbor-admin
  90. containers:
  91. - name: harbor
  92. image: harbor/harbor:v2.1.4
  93. ports:
  94. - name: http
  95. containerPort: 80
  96. - name: https
  97. containerPort: 443
  98. volumeMounts:
  99. - name: harbor-cert
  100. mountPath: /harbor_cert
  101. - name: harbor-config
  102. mountPath: /etc/core
  103. readOnly: true
  104. volumes:
  105. - name: harbor-cert
  106. secret:
  107. secretName: harbor-tls
  108. - name: harbor-config
  109. configMap:
  110. name: harbor-config
  111. ---
  112. # Harbor service
  113. apiVersion: v1
  114. kind: Service
  115. metadata:
  116. name: harbor
  117. namespace: harbor
  118. spec:
  119. selector:
  120. app: harbor
  121. ports:
  122. - name: http
  123. port: 80
  124. targetPort: 80
  125. - name: https
  126. port: 443
  127. targetPort: 443
  128. ---
  129. # Ingress for Harbor
  130. apiVersion: networking.k8s.io/v1beta1
  131. kind: Ingress
  132. metadata:
  133. name: harbor-ingress
  134. namespace: harbor
  135. annotations:
  136. kubernetes.io/ingress.class: nginx
  137. nginx.ingress.kubernetes.io/proxy-body-size: "0"
  138. spec:
  139. rules:
  140. - host: <your harbor hostname>
  141. http:
  142. paths:
  143. - path: /
  144. backend:
  145. serviceName: harbor
  146. servicePort: https
  1. 创建harbor-tls.yaml文件
  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: harbor-tls
  5. namespace: harbor
  6. type: kubernetes.io/tls
  7. data:
  8. tls.crt: <base64 encoded TLS certificate>
  9. tls.key: <base64 encoded TLS private key>
  10. ca.crt: <base64 encoded CA certificate chain>

其中,<your harbor hostname>需要替换为你的Harbor主机名,<your db password>需要替换为你的数据库密码,<your s3 accesskey><your s3 secretkey><your s3 region>需要替换为你的S3存储的访问密钥、秘钥和区域,<your s3 bucket>需要替换为你的S3存储的桶名。

另外,<base64 encoded TLS certificate><base64 encoded TLS private key><base64 encoded CA certificate chain>需要分别替换为经过base64编码的TLS证书、私钥和CA证书链。

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

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

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

联系我们

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

微信号:3007537140

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

关注我们
x

注册

已经有帐号?