dragonfly/docs/en/ecosystem/Kubernetes-with-Dragonfly.md

2.7 KiB

Kubernetes with Dragonfly

Now we can deploy all components of Dragonfly in Kubernetes cluster. We deploy scheduler and cdn as StatefulSets, daemon as DaemonSets.

Table of contents:

Kustomize Support

Prepare Kubernetes Cluster

If there is no available Kubernetes cluster for testing, minikube is recommended. Just run minikube start.

Build and Apply Kustomize Configuration

git clone https://github.com/dragonflyoss/Dragonfly2.git
kustomize build Dragonfly2/deploy/kustomize/single-cluster-native/overlays/sample | kubectl apply -f -

Wait Dragonfly Ready

Wait all pods running

kubectl -n dragonfly wait --for=condition=ready --all --timeout=10m pod

Configure Runtime

Use Containerd with CRI as example, more runtimes can be found here

For private registry:

[plugins."io.containerd.grpc.v1.cri".registry.mirrors."harbor.example.com"]
endpoint = ["http://127.0.0.1:65001", "https://harbor.example.com"]

For docker public registry:

[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["http://127.0.0.1:65001", "https://registry-1.docker.io"]

Add above config to /etc/containerd/config.toml and restart Containerd

systemctl restart containerd

Using Dragonfly

After all above steps, create a new pod with target registry. Or just pull an image with crictl:

crictl harbor.example.com/library/alpine:latest
crictl pull docker.io/library/alpine:latest

After pulled images, find logs in dfdaemon pod:

# find pods
kubectl -n dragonfly get pod -l component=dfdaemon
# find logs
pod_name=dfdaemon-xxxxx
kubectl -n dragonfly exec -it ${pod_name} -- grep "peer task done" /var/log/dragonfly/daemon/core.log

Example output:

{"level":"info","ts":"2021-06-28 06:02:30.924","caller":"peer/peertask_stream_callback.go:77","msg":"stream peer task done, cost: 2838ms","peer":"172.17.0.9-1-ed7a32ae-3f18-4095-9f54-6ccfc248b16e","task":"3c658c488fd0868847fab30976c2a079d8fd63df148fb3b53fd1a418015723d7","component":"streamPeerTask"}

Helm Support

Clone Chart

git clone https://github.com/dragonflyoss/Dragonfly2.git

Install

helm install --namespace dragonfly-system dragonfly Dragonfly2/deploy/charts/dragonfly

Wait Dragonfly Ready

Wait all pods running

kubectl -n dragonfly-system wait --for=condition=ready --all --timeout=10m pod

Next Steps

Following Configure Runtime to configure runtime. Following Using Dragonfly to use Dragonfly.

Upgrade Guide