-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add kustomize yaml for deploying (#349)
* feature: add kustomize yaml for deploying Signed-off-by: Jim Ma <[email protected]> * fix: remove unused folder Signed-off-by: Jim Ma <[email protected]> * feature: update documents Signed-off-by: Jim Ma <[email protected]> * feature: update dfdaemon netns config Signed-off-by: Jim Ma <[email protected]> * feature: update Kubernetes-with-Dragonfly.md and quick-start.md Signed-off-by: Jim Ma <[email protected]>
- Loading branch information
Showing
39 changed files
with
1,427 additions
and
9 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# This file is the template of cdn system configuration file. | ||
# You can configure your cdn system by change the parameter according your requirement. | ||
--- | ||
base: | ||
# listenPort is the port cdn server listens on. | ||
# default: 8003 | ||
listenPort: 8003 | ||
|
||
# DownloadPort is the port for download files from cdn. | ||
# And you should start a file server firstly which listens on the download port. | ||
# default: 8001 | ||
downloadPort: 8001 | ||
|
||
# SystemReservedBandwidth is the network bandwidth reserved for system software. | ||
# default: 20 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte. | ||
systemReservedBandwidth: 20M | ||
|
||
# MaxBandwidth is the network bandwidth that cdn can use. | ||
# default: 200 MB, in format of G(B)/g/M(B)/m/K(B)/k/B, pure number will also be parsed as Byte. | ||
maxBandwidth: 1024M | ||
|
||
# Whether to enable profiler | ||
# default: false | ||
enableProfiler: false | ||
|
||
# FailAccessInterval is the interval time after failed to access the URL. | ||
# If a task failed to be downloaded from the source, it will not be retried in the time since the last failure. | ||
# default: 3m | ||
failAccessInterval: 3m | ||
|
||
# GCInitialDelay is the delay time from the start to the first GC execution. | ||
# default: 6s | ||
gcInitialDelay: 6s | ||
|
||
# GCMetaInterval is the interval time to execute GC meta. | ||
# default: 2m0s | ||
gcMetaInterval: 2m | ||
|
||
# gcStorageInterval is the interval time to execute GC storage. | ||
# default: 15s | ||
gcStorageInterval: 15s | ||
|
||
# TaskExpireTime when a task is not accessed within the taskExpireTime, | ||
# and it will be treated to be expired. | ||
# default: 3m0s | ||
taskExpireTime: 3m | ||
|
||
# StoragePattern is the pattern of storage policy, [disk/hybrid] | ||
storagePattern: disk | ||
|
||
# Console shows log on console | ||
console: false | ||
|
||
plugins: | ||
storageDriver: | ||
- name: disk | ||
enable: true | ||
config: | ||
baseDir: /tmp/cdn | ||
storageManager: | ||
- name: disk | ||
enable: true | ||
config: | ||
gcInitialDelay: 5s | ||
gcInterval: 15s | ||
driverConfigs: | ||
disk: | ||
gcConfig: | ||
youngGCThreshold: 100G | ||
fullGCThreshold: 5G | ||
cleanRatio: 1 | ||
intervalThreshold: 2h |
51 changes: 51 additions & 0 deletions
51
deploy/kustomize/single-cluster-native/bases/cdn/nginx.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
worker_rlimit_nofile 100000; | ||
|
||
events { | ||
use epoll; | ||
worker_connections 20480; | ||
} | ||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
root /home/admin/cai/htdocs; | ||
sendfile on; | ||
tcp_nopush on; | ||
|
||
server_tokens off; | ||
keepalive_timeout 5; | ||
|
||
client_header_timeout 1m; | ||
send_timeout 1m; | ||
client_max_body_size 3m; | ||
|
||
index index.html index.htm; | ||
access_log off; | ||
log_not_found off; | ||
|
||
gzip on; | ||
gzip_http_version 1.0; | ||
gzip_comp_level 6; | ||
gzip_min_length 1024; | ||
gzip_proxied any; | ||
gzip_vary on; | ||
gzip_disable msie6; | ||
gzip_buffers 96 8k; | ||
gzip_types text/xml text/plain text/css application/javascript application/x-javascript application/rss+xml application/json; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header Web-Server-Type nginx; | ||
proxy_set_header WL-Proxy-Client-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_redirect off; | ||
proxy_buffers 128 8k; | ||
proxy_intercept_errors on; | ||
|
||
server { | ||
listen 8001; | ||
location / { | ||
root /tmp/cdn; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
deploy/kustomize/single-cluster-native/bases/cdn/rabc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: cdn-role | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- update | ||
- patch | ||
|
||
--- | ||
|
||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: cdn-role-binding | ||
roleRef: | ||
kind: Role | ||
name: cdn-role | ||
apiGroup: rbac.authorization.k8s.io | ||
subjects: | ||
- kind: ServiceAccount | ||
name: cdn |
19 changes: 19 additions & 0 deletions
19
deploy/kustomize/single-cluster-native/bases/cdn/service.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cdn | ||
spec: | ||
selector: | ||
app: dragonfly | ||
component: cdn | ||
type: ClusterIP | ||
clusterIP: None | ||
ports: | ||
- name: grpc | ||
port: 8003 | ||
protocol: TCP | ||
targetPort: 8003 | ||
- name: http | ||
port: 8001 | ||
protocol: TCP | ||
targetPort: 8001 |
4 changes: 4 additions & 0 deletions
4
deploy/kustomize/single-cluster-native/bases/cdn/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: cdn |
87 changes: 87 additions & 0 deletions
87
deploy/kustomize/single-cluster-native/bases/cdn/statefulset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: cdn | ||
labels: | ||
app: dragonfly | ||
component: cdn | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: dragonfly | ||
component: cdn | ||
replicas: 1 | ||
serviceName: cdn | ||
template: | ||
metadata: | ||
labels: | ||
app: dragonfly | ||
component: cdn | ||
spec: | ||
serviceAccountName: cdn | ||
initContainers: | ||
- name: update-configmap | ||
image: bitnami/kubectl | ||
command: | ||
- /bin/bash | ||
- -xc | ||
- | | ||
HOSTNAME=$(cat /etc/hostname) | ||
cat <<EOF > /tmp/patch.json | ||
{ | ||
"data": { | ||
"$POD_NAME.json": "{\"host_info\": {\"host_name\": \"$HOSTNAME\",\"ip\":\"$POD_IP\"},\"rpc_port\": 8003,\"down_port\": 8001}" | ||
} | ||
} | ||
EOF | ||
echo data to patch: | ||
cat /tmp/patch.json | ||
for i in `seq 1 10`; do | ||
kubectl -n $POD_NAMESPACE \ | ||
patch configmap scheduler-static-cdn --type=merge \ | ||
--patch-file /tmp/patch.json | ||
if [[ "$?" -eq 0 ]]; then | ||
echo updated configmap: | ||
kubectl -n $POD_NAMESPACE get configmap scheduler-static-cdn -oyaml | ||
break | ||
fi | ||
done | ||
env: | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
imagePullPolicy: "Always" | ||
containers: | ||
- name: cdn | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
cp /etc/dragonfly/nginx.conf /etc/nginx/nginx.conf | ||
nginx | ||
exec /opt/dragonfly/df-cdn/cdn | ||
image: dragonflyoss/cdn | ||
imagePullPolicy: "Always" | ||
ports: | ||
- containerPort: 8001 | ||
- containerPort: 8003 | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/dragonfly | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: cdn |
46 changes: 46 additions & 0 deletions
46
deploy/kustomize/single-cluster-native/bases/dfdaemon/daemonset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: dfdaemon | ||
labels: | ||
app: dragonfly | ||
component: dfdaemon | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: dragonfly | ||
component: dfdaemon | ||
updateStrategy: | ||
rollingUpdate: | ||
maxUnavailable: 10 | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: dragonfly | ||
component: dfdaemon | ||
spec: | ||
serviceAccountName: dfdaemon | ||
containers: | ||
- name: dfdaemon | ||
image: dragonflyoss/dfget | ||
imagePullPolicy: "Always" | ||
volumeMounts: | ||
- name: config | ||
mountPath: /etc/dragonfly | ||
- name: netns # the mountPath is setting in proxy.tcp_listen.namespace | ||
mountPath: /host/ns/net | ||
ports: # 65001 is in host network, no need here | ||
- containerPort: 65000 | ||
- containerPort: 65002 | ||
securityContext: | ||
capabilities: | ||
add: | ||
- SYS_ADMIN # setns need CAP_SYS_ADMIN capability | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: dfdaemon | ||
- name: netns | ||
hostPath: | ||
path: /proc/1/ns/net # bind mount host net ns to pod, dfdaemon can listen 65001 in host network |
Oops, something went wrong.