dockerhabor部署使用

基于Ubuntu20.4 的安装部署以及镜像推送使用

Docker Hub 是 Docker 官方提供的公共镜像仓库,也是全球最大的容器镜像生态系统。它允许用户存储、共享和管理 Docker 镜像,支持从简单的应用到复杂的微服务架构。用户可以直接通过命令行或 Web 界面访问和操作镜像。

1、安装docker

sudo apt update && sudo apt upgrade -y
sudo apt install -y docker.io docker-compose wget gnupg2   #安装依赖包
#配置软件源
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  apt-get update

#安装软件
apt-get -y install docker-ce docker-ce-cli containerd.io

# 加速器配置

  echo '{"registry-mirrors": ["http://74f21445.m.daocloud.io"], "insecure-registries": ["10.0.0.19:80"]}' > /etc/docker/daemon.json
  systemctl restart docker 
  systemctl enable docker

##安装完显示
Processing triggers for systemd (245.4-4ubuntu3.24) ...
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
root@ubuntu:/data#

2.安装habor

root@ubuntu:/data# wget https://github.com/goharbor/harbor/releases/download/v2.3.2/harbor-offline-installer-v2.3.2.tgz
root@ubuntu:/data# tar -zxvf harbor-offline-installer-v2.3.2.tgz -C /usr/local/
root@ubuntu:/usr/local/harbor# docker load < harbor.v2.3.2.tar.gz
root@ubuntu:/usr/local/harbor# cp harbor.yml.tmpl harbor.yml
root@ubuntu:/usr/local/harbor# ls
common  common.sh  docker-compose.yml  harbor.v2.3.2.tar.gz  harbor.yml  install.sh  LICENSE  prepare

root@ubuntu:/usr/local/harbor# cat harbor.yml 
# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 10.0.0.19  #修改为本机地址

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80

# https related config
#https:                                      #关闭https
  # https port for harbor, default is 443
  #  port: 443
  # The path of cert and key files for nginx
  #certificate: /your/certificate/path
  #private_key: /your/private/key/path

# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
#   # set enabled to true means internal tls is enabled
#   enabled: true
#   # put your cert and key files on dir
#   dir: /etc/harbor/tls/internal

# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433

# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: 123456       #修改登录密码

# Harbor DB configuration
database:
  # The password for the root user of Harbor DB. Change this before any production use.
  password: root123
  # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
  max_idle_conns: 100
  # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
  # Note: the default number of connections is 1024 for postgres of harbor.
  max_open_conns: 900


root@ubuntu:/usr/local/harbor# ./prepare
root@ubuntu:/usr/local/harbor# ./install.sh

root@ubuntu:/usr/local/harbor# docker-compose up -d
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry      ... done
Creating registryctl   ... done
Creating harbor-portal ... done
Creating harbor-db     ... done
Creating redis         ... done
Creating harbor-core   ... done
Creating harbor-jobservice ... done
Creating nginx             ... done

3.网页登录,设置用户 创建项目 准备推送本地镜像

在这里插入图片描述

root@ubuntu:/data/images# ls
flannel-v0.16.3.tar.gz  k8s-1.23.3.tar.gz  k8s-v1.22.1.tar
root@ubuntu:/data/images# docker load  <k8s-1.23.3.tar.gz 
root@ubuntu:/data/images# docker load <flannel-v0.16.3.tar.gz
#推送本地镜像
root@ubuntu:/data/images# for i in 10.0.0.19:80/google_containers/kube-scheduler:v1.23.3 10.0.0.19:80/google_containers/etcd:3.5.1-0 10.0.0.19:80/google_containers/coredns:v1.8.6 10.0.0.19:80/google_containers/pause:3.6 10.0.0.19:80/google_containers/kube-apiserver:v1.23.3 10.0.0.19:80/google_containers/kube-proxy:v1.23.3 10.0.0.19:80/google_containers/kube-controller-manager:v1.23.3 10.0.0.19:80/google_containers/mirrored-flannelcni-flannel:v0.16.3 10.0.0.19:80/google_containers/mirrored-flannelcni-flannel-cni-plugin:v1.0.1 10.0.0.19:80/google_containers/kube-apiserver:v1.22.1 10.0.0.19:80/google_containers/kube-controller-manager:v1.22.1 10.0.0.19:80/google_containers/kube-scheduler:v1.22.1 10.0.0.19:80/google_containers/kube-proxy:v1.22.1 10.0.0.19:80/google_containers/pause:3.5 10.0.0.19:80/google_containers/etcd:3.5.0-0 10.0.0.19:80/google_containers/coredns:v1.8.4; do docker push $i; done
The push refers to repository [10.0.0.19:80/google_containers/kube-scheduler]
5eaba3e55346: Pushed 
977c4a52660b: Pushed 
5b1fa8e3e100: Pushed 
v1.23.3: digest: sha256:a70ef5379ddb3f9179d8588f71a26fa0c82c814b6fb4820d207ab56b9fdaa9b3 size: 949
The push refers to repository [10.0.0.19:80/google_containers/etcd]
62ae031121b1: Pushed 
664dd6f2834b: Pushed 
d80003ff5706: Pushed 
b6e8c573c18d: Pushed 
6d75f23be3dd: Pushed 
3.5.1-0: digest: sha256:05c1a3be66823dcaca55ebe17c3c9a60de7ceb948047da3e95308348325ddd5a size: 1372
The push refers to repository [10.0.0.19:80/google_containers/coredns]
80e4a2390030: Pushed 
256bc5c338a6: Pushed 
v1.8.6: digest: sha256:8916c89e1538ea3941b58847e448a2c6d940c01b8e716b20423d2d8b189d3972 size: 739
The push refers to repository [10.0.0.19:80/google_containers/pause]
1021ef88c797: Pushed 
3.6: digest: sha256:74bf6fc6be13c4ec53a86a5acf9fdbc6787b176db0693659ad6ac89f115e182c size: 526
The push refers to repository [10.0.0.19:80/google_containers/kube-apiserver]
3958dfe3baa0: Pushed 
977c4a52660b: Mounted from google_containers/kube-scheduler 
5b1fa8e3e100: Mounted from google_containers/kube-scheduler 
v1.23.3: digest: sha256:add26e08df876fd8b92a53fab000bade34f624693f7944595776b75be17e5269 size: 949
The push refers to repository [10.0.0.19:80/google_containers/kube-proxy]
c964d4babc0f: Pushed 
2b8347a02bc5: Pushed 
194a408e97d8: Pushed 
v1.23.3: digest: sha256:8a4c23ffdc21dd2acf022daa8b978dcdca276daf2bcb6b72ccd01873d769e3ca size: 950
The push refers to repository [10.0.0.19:80/google_containers/kube-controller-manager]
23c275729951: Pushed 
977c4a52660b: Mounted from google_containers/kube-apiserver 
5b1fa8e3e100: Mounted from google_containers/kube-apiserver 
v1.23.3: digest: sha256:21497e34aa9ac971040333d886e4755dbe5770310a1da233f83fecf28231f20e size: 949
The push refers to repository [10.0.0.19:80/google_containers/mirrored-flannelcni-flannel]
277b2476e0a4: Pushed 
d2d744638528: Pushed 
9ba1db53cd50: Pushed 
ed91240b20f4: Pushed 
2d48447e7be9: Pushed 
d92b9fdf41ab: Pushed 
7fcb75871b21: Pushed 
v0.16.3: digest: sha256:faeff704d861b09cb48d5babf62a2799dd14207465b33fca53bbe9fefd85f787 size: 1785
The push refers to repository [10.0.0.19:80/google_containers/mirrored-flannelcni-flannel-cni-plugin]
5116ff75ddbe: Pushed 
7fcb75871b21: Mounted from google_containers/mirrored-flannelcni-flannel 
v1.0.1: digest: sha256:eea1dbf2704dcc91ae9e3770c64fd79d2d1ffc9deac9cb86458c5f3155312c75 size: 737
The push refers to repository [10.0.0.19:80/google_containers/kube-apiserver]
09a0fcc34bc8: Pushed 
71204d686e50: Pushed 
07363fa84210: Pushed 
v1.22.1: digest: sha256:d61567706f42ef70e6351e2fd5637e69bcef6d487442fbfa9d1fee15e694faa8 size: 949
The push refers to repository [10.0.0.19:80/google_containers/kube-controller-manager]
498fc61ea412: Pushed 
71204d686e50: Mounted from google_containers/kube-apiserver 
07363fa84210: Mounted from google_containers/kube-apiserver 
v1.22.1: digest: sha256:42617ed730cf7afdfccea9eb584abe3bb139a6dab56686bea0c6359037b4daec size: 949
The push refers to repository [10.0.0.19:80/google_containers/kube-scheduler]
03294f7c6532: Pushed 
71204d686e50: Mounted from google_containers/kube-controller-manager 
07363fa84210: Mounted from google_containers/kube-controller-manager 
v1.22.1: digest: sha256:75266a8babd79d39d7bede2ec5a3b81f2cd2cea482a957442432c415606107b3 size: 949
The push refers to repository [10.0.0.19:80/google_containers/kube-proxy]
54e23a97593b: Pushed 
48b90c7688a2: Pushed 
v1.22.1: digest: sha256:87ad8b02618b73419d77920e0556e7c484501ddfa79f7ad554f5d17a473e84da size: 740
The push refers to repository [10.0.0.19:80/google_containers/pause]
dee215ffc666: Pushed 
3.5: digest: sha256:2f4b437353f90e646504ec8317dacd6123e931152674628289c990a7a05790b0 size: 526
The push refers to repository [10.0.0.19:80/google_containers/etcd]
ce8b3ebd2ee7: Pushed 
eb364b1a02ca: Pushed 
13de6ee856e9: Pushed 
33158bca9fb5: Pushed 
417cb9b79ade: Pushed 
3.5.0-0: digest: sha256:de6a50021feadfde321d44cf1934a806595e59d9cc77d68f0ce85cef8d1ab2ed size: 1372
The push refers to repository [10.0.0.19:80/google_containers/coredns]
f72781b18181: Pushed 
225df95e717c: Pushed 
v1.8.4: digest: sha256:10683d82b024a58cc248c468c2632f9d1b260500f7cd9bb8e73f751048d7d6d4 size: 739

4.仓库已存在数据

在这里插入图片描述

#k8s初始化使用镜像地址成功
root@k8s-master:~# kubeadm init --kubernetes-version=1.23.3 \
> --apiserver-advertise-address=10.0.0.71 \
> --image-repository 10.0.0.19:80/google_containers \
> --service-cidr=10.96.0.0/12 \
> --pod-network-cidr=10.244.0.0/16 \
> --ignore-preflight-errors=Swap
[init] Using Kubernetes version: v1.23.3
[preflight] Running pre-flight checks
	[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 28.0.2. Latest validated version: 20.10
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 10.0.0.71:6443 --token ito39e.6a6lq0t08gp23hpq \
	--discovery-token-ca-cert-hash sha256:7495f7125a578c082947395a55e217cb9b1d8308ac44c1aca40b8c57710f2145 
root@k8s-master:~#   mkdir -p $HOME/.kube
root@k8s-master:~#   sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
root@k8s-master:~#   sudo chown $(id -u):$(id -g) $HOME/.kube/config


root@k8s-master:/data/flannel# cat kube-flannel-v0.16.3.yml |grep 10.0
        image: 10.0.0.19:80/google_containers/mirrored-flannelcni-flannel-cni-plugin:v1.0.1
        image: 10.0.0.19:80/google_containers/mirrored-flannelcni-flannel:v0.16.3
        image: 10.0.0.19:80/google_containers/mirrored-flannelcni-flannel:v0.16.3
root@k8s-master:/data/flannel# kubectl apply -f kube-flannel-v0.16.3.yml 
Warning: policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
podsecuritypolicy.policy/psp.flannel.unprivileged created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created
root@k8s-master:/data/flannel# kubectl get nodes
NAME         STATUS   ROLES                  AGE   VERSION
k8s-master   Ready    control-plane,master   24m   v1.23.3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值