内容简介:Dragonfly可以很好的节省kubernetes集群下载镜像的带宽,下文记录了在一个已经配置好的kubernetes集群中如何部署Dragonfly。Dragonfly分为两部分,均部署到namespace kube-system中:由于supernode需要在
Dragonfly可以很好的节省kubernetes集群下载镜像的带宽,下文记录了在一个已经配置好的kubernetes集群中如何部署Dragonfly。
Dragonfly分为两部分,均部署到namespace kube-system中:
- supernode,部署在master节点
- df-daemon,部署在所有节点
部署supernode
由于supernode需要在 /home/admin/dragonfly
目录下缓存镜像blob,不宜与根分区共享存储(万一Dragonfly的GC做的不好,会写满根分区,致命),所以我单独给虚拟机加了块盘,挂载到了 /data
目录下,通过hostpath挂载给supernode使用。
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: supernode namespace: kube-system spec: replicas: 1 template: metadata: labels: app: supernode spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: "node-role.kubernetes.io/master" operator: Exists tolerations: - key: "node-role.kubernetes.io/master" operator: "Exists" effect: "NoSchedule" containers: - name: supernode image: silenceshell/supernode:0.2.0 imagePullPolicy: Always ports: - containerPort: 8001 - containerPort: 8002 volumeMounts: - mountPath: /home/admin/supernode name: data volumes: - name: data hostPath: path: /data/dragonfly type: Directory --- apiVersion: v1 kind: Service metadata: name: supernode namespace: kube-system labels: svc: supernode spec: ports: - port: 8001 name: port1 protocol: TCP targetPort: 8001 - port: 8002 name: port2 protocol: TCP targetPort: 8002 selector: app: supernode sessionAffinity: None
df-daemon通过svc supernode建立与supernode的连接。
通过kubectl创建后,有如下Pod。
$ kubectl get pods -n kube-system -o wide|grep super supernode-6556bf8bf6-tj7d9 1/1 Running 0 18m 10.244.0.144 ubuntu-1 <none>
部署df-daemon
Daemonset很适合用来部署df-daemon。
df-daemon需要配置为hostnet模式,因为docker daemon需要连接df-daemon的65001端口。我的df-daemon的环境变量 REGISTRY
配置为 https://registry.docker-cn.com
,如果你是用来代理私有镜像,环境变量 REGISTRY
需要修改为对应的值。
apiVersion: extensions/v1beta1 kind: DaemonSet metadata: labels: k8s-app: df-daemon name: df-daemon namespace: kube-system spec: selector: matchLabels: k8s-app: df-daemon template: metadata: labels: k8s-app: df-daemon spec: tolerations: - key: "node-role.kubernetes.io/master" operator: "Exists" effect: "NoSchedule" - key: "external" operator: "Equal" value: "ingress" effect: "NoSchedule" containers: - env: - name: REGISTRY value: https://registry.docker-cn.com image: silenceshell/df-daemon:0.2.0 imagePullPolicy: Always name: df-daemon volumeMounts: - mountPath: /etc/dragonfly.conf name: config readOnly: true subPath: dragonfly.conf - mountPath: /root/.small-dragonfly/ name: data dnsPolicy: ClusterFirstWithHostNet hostNetwork: true restartPolicy: Always volumes: - configMap: defaultMode: 384 name: df-daemon-config name: config - hostPath: path: /data/dfdaemon name: data --- apiVersion: v1 kind: ConfigMap metadata: labels: k8s-app: df-daemon name: df-daemon-config namespace: kube-system data: dragonfly.conf: |- [node] address=supernode
通过kubectl部署后,有如下Pod。可以看到,容器运行在宿主机网络中。
$ kubectl get pods -n kube-system -o wide|grep df-daemon df-daemon-75rxn 1/1 Running 1 20m 192.168.0.3 ubuntu-3 <none> df-daemon-b25qt 1/1 Running 0 20m 192.168.0.2 ubuntu-2 <none> df-daemon-nkxsz 1/1 Running 1 20m 192.168.0.1 ubuntu-1 <none>
修改Docker daemon配置
Dragonfly配置好后,就可以修改Docker daemon的配置了。
修改 /etc/docker/daemon.json
,将df-daemon配置为Docker daemon的mirror。
{ "registry-mirrors": ["http://127.0.0.1:65001"] }
重启 Docker daemon,通过 docker info
可以查看到如下信息:
Insecure Registries: 127.0.0.0/8 Registry Mirrors: http://127.0.0.1:65001
至此,配置完成。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- linux 部署golang 项目(直接部署和基于nginx部署)
- 部署策略对比:蓝绿部署、金丝雀发布及其他
- 使用Docker容器化部署实践之Django应用部署(一)
- 【前端打包部署】谈一谈我在SPA项目打包=>部署的处理
- 「实战篇」开源项目docker化运维部署-后端java部署(七)
- Kubernetes 中的渐进式交付:蓝绿部署和金丝雀部署
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Haskell School of Music
Paul Hudak、Donya Quick / Cambridge University Press / 2018-10-4 / GBP 42.99
This book teaches functional programming through creative applications in music and sound synthesis. Readers will learn the Haskell programming language and explore numerous ways to create music and d......一起来看看 《The Haskell School of Music》 这本书的介绍吧!