通过 web 界面 上传 镜像 到服务 器
将镜像推送到 registry 镜像仓库
通过 k8s 接口部署服务
通过 k8s 接口暴露服务
npm install express @kubernetes/client-node
curl -X POST http://localhost:3000/deploy \
-H " Content-Type: application/json" \
-d ' {"imageName": "nginx:latest", "containerPort": 80}'
{
"deploymentName": "app-1698598100000-deployment",
"serviceName": "app-1698598100000-service",
"servicePort": 32345,
"nodeIp": "192.168.1.100",
"message": "Service 'app-1698598100000-service' is exposed on node '192.168.1.100:32345'"
}
helm repo add harbor https://helm.goharbor.io
helm repo update
helm install harbor harbor/harbor --namespace harbor --set expose.type=nodePort --set expose.tls.enabled=false --set persistence.enabled=true
helm install harbor harbor/harbor --namespace harbor --set expose.type=nodePort --set expose.hostname=192.168.110.116 --set expose.tls.enabled=false --set persistence.enabled=true
helm install harbor harbor/harbor --namespace harbor \
--set expose.type=nodePort \
--set expose.hostname=192.168.110.116 \
--set expose.tls.enabled=false \
--set persistence.enabled=true
helm uninstall -n harbor harbor harbor/harbor
kubectl get pods -n harbor
kubectl get svc -n harbor
harbo 帐号:admin 密码:Harbor12345
harbor 如果麻烦,请使用 docker 官方的部署 registry
docker tag io3d-server:latest 192.168.110.116:30500/vendor/io3d-server:latest
docker push 192.168.110.116:30500/vendor/io3d-server:latest
curl -i 192.168.110.116:30500/v2/_catalog
curl -X POST http://localhost:3000/deploy \
-H " Content-Type: application/json" \
-d ' {"imageName": "192.168.110.116:30500/vendor/io3d-server:latest", "containerPort": 8100}'
sudo vi /etc/containerd/config.toml
# ####
[plugins." io.containerd.grpc.v1.cri" .registry]
[plugins." io.containerd.grpc.v1.cri" .registry.mirrors]
[plugins." io.containerd.grpc.v1.cri" .registry.mirrors." 192.168.110.116:30500" ]
endpoint = [" http://192.168.110.116:30500" ]
# ####
sudo systemctl restart containerd
apiVersion: apps/v1
kind: Deployment
metadata:
name: image-pull-test
spec:
replicas: 1
selector:
matchLabels:
app: image-pull-test
template:
metadata:
labels:
app: image-pull-test
spec:
containers:
- name: test-container
image: 192.168.110.116:30500/my-image:latest # 你的私有镜像地址
imagePullPolicy: Always