使用DragonFly进行智能镜像分发 (2)


客户端以daemonSet的形式部署,yaml文件如下:

apiVersion: apps/v1 kind: DaemonSet metadata: name: dfdaemon namespace: kube-system spec: selector: matchLabels: app: dfdaemon template: metadata: annotations: scheduler.alpha.kubernetes.io/critical-pod: "" labels: app: dfdaemon spec: containers: - image: dragonflyoss/dfclient:v0.3.0 name: dfdaemon imagePullPolicy: IfNotPresent args: - --registry https://index.docker.io resources: requests: cpu: 250m volumeMounts: - mountPath: /etc/dragonfly/dfget.yml subPath: dfget.yml name: dragonconf hostNetwork: true dnsPolicy: ClusterFirstWithHostNet restartPolicy: Always tolerations: - effect: NoExecute operator: Exists - effect: NoSchedule operator: Exists volumes: - name: dragonconf configMap: name: dragonfly-conf

配置文件我们以configMap的形式挂载,所以我们还需要编写一个configMap的yaml文件,如下:

apiVersion: v1 kind: ConfigMap metadata: name: dragonfly-conf namespace: kube-system data: dfget.yml: | nodes: - 172.17.100.120

部署过后观察结果

# kubectl get pod -n kube-system | grep dfdaemon dfdaemon-mj4p6 1/1 Running 0 3m51s dfdaemon-wgq5d 1/1 Running 0 3m51s dfdaemon-wljt6 1/1 Running 0 3m51s


然后修改docker daemon的配置,如下:

{ "registry-mirrors": ["http://127.0.0.1:65001"] }

重启docker

systemctl restart docker


现在我们来拉取镜像测试,并观察日志输出。
下载镜像(在master上测试的):

docker pull nginx

然后观察日志

kubectl exec -n kube-system dfdaemon-wgq5d grep 'downloading piece' /root/.small-dragonfly/logs/dfclient.log

看到日志输出如下,表示成功

2020-06-20 17:14:54.578 INFO sign:128-1592673287.190 : downloading piece:{"taskID":"089dc52627a346df2a2ff67f6c07497167b35c4bad2bca1e9aad087441116982","superNode":"172.17.100.120","dstCid":"cdnnode:192.168.235.192~089dc52627a346df2a2ff67f6c07497167b35c4bad2bca1e9aad087441116982","range":"0-4194303","result":503,"status":701,"pieceSize":4194304,"pieceNum":0}

今天的测试就到这里,我这是自己的小集群实验室,效果其实并不明显,在大集群效果可能更好。

参考

https://d7y.io/zh-cn/docs/userguide/multi_machines_deployment.html

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpxsdj.html