• centOS 7 Install Harbor(私有镜像仓库)V2


    一、安装docker环境

    略. 

    二、下载离线安装包

    下载地址https://github.com/goharbor/harbor/releases/download/v1.10.15/harbor-offline-installer-v1.10.15.tgz三、拷贝到服务器/application

    1. #解压
    2. tar -xvf harbor-online-installer-v1.2.0.tgz
    3. #生成证书
    4. cd /application
    5. mkdir cert && cd cert
    6. openssl req -sha256 -x509 -days 365 -nodes -newkey rsa:4096 -keyout harbor.example.com.key -out harbor.example.com.crt
    7. #编辑配置文件
    8. nano /application/harbor/harbor.yml
    9. #############修改#############
    10. hostname: harbor.example.com
    11. certificate: /application/cert/harbor.example.com.crt
    12. private_key: /application/cert/harbor.example.com.key
    13. ##############################
    14. cd /application/harbor
    15. ./install.sh

    访问:windowns 机器上配置host

    登录: http://harobr.example.com 

    用户名:admin
    密码:Harbor12345

    四、上传镜像

     设置Linux设置Host

    1. sed -i '$a 127.0.0.1 harbor.example.com' /etc/hosts
    2. nano /etc/docker/daemon.json
    3. ###########添加一段###########
    4. "insecure-registries":["192.168.31.105"]
    5. #############################
    6. #重启docker
    7. sudo systemctl daemon-reload
    8. sudo systemctl restart docker

    例如现在已构建了一个镜像:netcore6.demo:v1.0.1 需要上传,则先执行

    1. docker tag netcore6.demo:v1.0.1 192.168.31.105/demos/netcore6.demo:v1.0.1
    2. #登录成功
    3. docker login 192.168.31.105 #admin Harbor12345
    4. #上传
    5. docker push 192.168.31.105/demos/netcore6.demo:v1.0.1

    五、k8s拉取镜像部属

    k8服务器上添加镜像库地址:

    1. sed -i '$a 192.168.31.105 harbor.example.com' /etc/hosts
    2. nano /etc/docker/daemon.json 添加一段:"insecure-registries":["harbor.example.com"]
    3. {
    4. "insecure-registries":["harbor.example.com"],
    5. "registry-mirrors": ["https://nlrpuctd.mirror.aliyuncs.com"],
    6. }
    7. systemctl restart docker

    1. kubectl create -f /root/k8sdeploy/netcore6.demo/api-demo-harbor-com-deployment.yaml
    2. kubectl create -f /root/k8sdeploy/netcore6.demo/api-demo-harbor-com-service.yaml

    api-demo-harbor-com-deployment.yaml

    1. {
    2. "apiVersion": "apps/v1",
    3. "kind": "Deployment",
    4. "metadata": {
    5. "annotations": {},
    6. "name": "api-demo-harbor-com-deployment",
    7. "namespace": "default"
    8. },
    9. "spec": {
    10. "replicas": 1,
    11. "revisionHistoryLimit": 2,
    12. "selector": {
    13. "matchLabels": {
    14. "app": "api-demo-harbor-com"
    15. }
    16. },
    17. "template": {
    18. "metadata": {
    19. "labels": {
    20. "app": "api-demo-harbor-com"
    21. }
    22. },
    23. "spec": {
    24. "containers": [
    25. {
    26. "image": "harbor.example.com/demos/netcore6.demo:v1.0.1",
    27. "imagePullPolicy": "IfNotPresent",
    28. "name": "api-demo-harbor-com",
    29. "ports": [
    30. {
    31. "containerPort": 80
    32. }
    33. ],
    34. "resources": {
    35. "limits": {
    36. "cpu": "200m",
    37. "memory": "500Mi"
    38. },
    39. "requests": {
    40. "cpu": "200m",
    41. "memory": "100Mi"
    42. }
    43. },
    44. "volumeMounts": [
    45. {
    46. "mountPath": "/mnt/api.demo.harbor.com",
    47. "name": "data"
    48. },
    49. {
    50. "mountPath": "/mnt/cert",
    51. "name": "cert"
    52. }
    53. ]
    54. }
    55. ],
    56. "hostAliases": [
    57. {
    58. "hostnames": [
    59. "api.demo.harbor.com"
    60. ],
    61. "ip": "192.168.1.107"
    62. }
    63. ],
    64. "volumes": [
    65. {
    66. "hostPath": {
    67. "path": "/kubernetes/wwwroot/api.demo.harbor.com"
    68. },
    69. "name": "data"
    70. },
    71. {
    72. "hostPath": {
    73. "path": "/kubernetes/cert"
    74. },
    75. "name": "cert"
    76. }
    77. ]
    78. }
    79. }
    80. }
    81. }

    api-demo-harbor-com-service.yaml

    1. {
    2. "apiVersion": "v1",
    3. "kind": "Service",
    4. "metadata": {
    5. "annotations": {},
    6. "labels": {
    7. "app": "api-demo-harbor-com"
    8. },
    9. "name": "api-demo-harbor-com",
    10. "namespace": "default"
    11. },
    12. "spec": {
    13. "ports": [
    14. {
    15. "port": 80,
    16. "nodePort": 32767,
    17. "protocol": "TCP",
    18. "targetPort": 80
    19. }
    20. ],
    21. "selector": {
    22. "app": "api-demo-harbor-com"
    23. },
    24. "type": "NodePort"
    25. }
    26. }

     

     

  • 相关阅读:
    数据分析:小红书品牌“共情力”缔造指南
    最易懂的贪心算法
    C#将对象转换为Dictionary字典集合
    MySQL主主复制
    RabbitMQ之死信队列
    具体项目下解决Echarts多端同步开发和维护的问题
    ubuntu18.04编译GB28181Server
    MyBatis ognl.NoSuchPropertyException 或者 Invalid bound statement (not found)
    数据库系列:MySQL索引优化总结(综合版)
    商城系统优化
  • 原文地址:https://blog.csdn.net/xiaoxionglove/article/details/128057016