Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add kustomize yaml for deploying #349

Merged
merged 5 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed deploy/kubernetes/.gitkeep
Empty file.
72 changes: 72 additions & 0 deletions deploy/kustomize/single-cluster-native/bases/cdn/cdn.yaml
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 deploy/kustomize/single-cluster-native/bases/cdn/nginx.conf
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 deploy/kustomize/single-cluster-native/bases/cdn/rabc.yaml
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 deploy/kustomize/single-cluster-native/bases/cdn/service.yaml
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: cdn
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
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
Loading