Skip to content

Commit

Permalink
feature: update helm charts (#385)
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <majinjing3@gmail.com>
  • Loading branch information
jim3ma authored and gaius-qi committed Jun 28, 2023
1 parent fe01167 commit 008ae86
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 119 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Please refer to our [Code of Conduct][codeconduct].
[codeconduct]: CODE_OF_CONDUCT.md
[introduction]: https://github.com/dragonflyoss/Dragonfly2
[installation]: https://github.com/dragonflyoss/Dragonfly2
[quickstart]: https://github.com/dragonflyoss/Dragonfly2
[quickstart]: https://github.com/dragonflyoss/Dragonfly2/blob/main/docs/en/user-guide/quick-start.md
[website]: https://d7y.io
[discussion]: https://github.com/dragonflyoss/Dragonfly2/discussions
[logo-linear]: docs/en/images/logo/dragonfly-linear.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ data:
server {
listen {{ .Values.cdn.service.nginxTargetPort }};
location / {
root {{ .Values.cdn.config.plugins.storage.config.baseDir }};
root {{ with $s := index .Values.cdn.config.plugins.storageDriver 0 }}{{ $s.config.baseDir }} {{ end -}};
}
}
}
33 changes: 33 additions & 0 deletions deploy/charts/dragonfly/templates/cdn/cdn-rabc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.scheduler.config.staticCDN }}
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{template "dragonfly.cdn.fullname" . }}-role
namespace: {{ .Values.installation.namespace }}
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- update
- patch

---

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{template "dragonfly.cdn.fullname" . }}-role-binding
namespace: {{ .Values.installation.namespace }}
roleRef:
kind: Role
name: {{template "dragonfly.cdn.fullname" . }}-role
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: {{template "dragonfly.cdn.fullname" . }}
{{ end }}
5 changes: 5 additions & 0 deletions deploy/charts/dragonfly/templates/cdn/cdn-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{template "dragonfly.cdn.fullname" . }}
namespace: {{ .Values.installation.namespace }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
labels:
app: {{ template "dragonfly.cdn.fullname" . }}
Expand All @@ -9,9 +9,9 @@ metadata:
release: {{ .Release.Name }}
name: {{ template "dragonfly.cdn.fullname" . }}
namespace: {{ .Values.installation.namespace }}
{{- if .Values.cdn.deploymentAnnotations }}
{{- if .Values.cdn.statefulsetAnnotations }}
annotations:
{{ toYaml .Values.cdn.deploymentAnnotations | indent 4 }}
{{ toYaml .Values.cdn.statefulsetAnnotations | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.cdn.replicas }}
Expand All @@ -20,6 +20,7 @@ spec:
app: {{ template "dragonfly.cdn.fullname" . }}
component: "{{ .Values.cdn.name }}"
release: {{ .Release.Name }}
serviceName: cdn
template:
metadata:
labels:
Expand All @@ -31,6 +32,7 @@ spec:
{{ toYaml .Values.cdn.podAnnotations | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{template "dragonfly.cdn.fullname" . }}
{{- if .Values.cdn.nodeSelector }}
nodeSelector:
{{ toYaml .Values.cdn.nodeSelector | indent 8 }}
Expand Down Expand Up @@ -66,6 +68,53 @@ spec:
- name: nginx-config
mountPath: "/etc/nginx/nginx.conf"
subPath: "nginx.conf"
{{- if .Values.scheduler.config.staticCDN }}
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"
{{- end}}
volumes:
- name: config
configMap:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ metadata:
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
dfget-daemon.yaml: |-
dfget.yaml: |-
alive_time: {{ .Values.dfdaemon.config.alive_time }}
gc_interval: {{ .Values.dfdaemon.config.gc_interval }}
pid_file: {{ .Values.dfdaemon.config.pid_file }}
lock_file: {{ .Values.dfdaemon.config.lock_file }}
data_dir: {{ .Values.dfdaemon.config.data_dir }}
work_home: {{ .Values.dfdaemon.config.work_home }}
keep_storage: {{ .Values.dfdaemon.config.keep_storage }}
verbose: {{ .Values.dfdaemon.config.verbose }}
scheduler:
net_addrs:
- type: tcp
addr: {{template "dragonfly.scheduler.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.scheduler.service.port }}
{{- $count := .Values.scheduler.replicas | int}}
{{- range $i, $x := until $count }}
- type: tcp
addr: {{template "dragonfly.scheduler.fullname" $ }}-{{$i}}.{{ $.Release.Namespace }}.svc{{ $.Values.installation.clusterDomain }}:{{ $.Values.scheduler.service.port }}
{{- end }}
schedule_timeout: 5m
host:
{{ toYaml .Values.dfdaemon.config.host | indent 6 }}
Expand All @@ -32,4 +31,16 @@ data:
storage:
{{ toYaml .Values.dfdaemon.config.storage | indent 6 }}
proxy:
{{ toYaml .Values.dfdaemon.config.proxy | indent 6 }}
tcp_listen:
{{- if not .Values.dfdaemon.hostNetwork }}
namespace: /host/ns/net
{{- end }}
listen: {{ .Values.dfdaemon.config.proxy.tcp_listen.listen }}
port: {{ .Values.dfdaemon.config.proxy.tcp_listen.port }}
security:
{{ toYaml .Values.dfdaemon.config.proxy.security | indent 8 }}
registry_mirror:
{{ toYaml .Values.dfdaemon.config.proxy.registry_mirror | indent 8 }}
proxies:
{{ toYaml .Values.dfdaemon.config.proxy.proxies | indent 8 }}

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ metadata:
component: "{{ .Values.dfdaemon.name }}"
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.dfdaemon.deploymentAnnotations }}
{{- if .Values.dfdaemon.daemonsetAnnotations }}
annotations:
{{ toYaml .Values.dfdaemon.deploymentAnnotations | indent 4 }}
{{ toYaml .Values.dfdaemon.daemonsetAnnotations | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.dfdaemon.replicas }}
selector:
matchLabels:
app: {{ template "dragonfly.dfdaemon.fullname" . }}
Expand All @@ -35,6 +34,7 @@ spec:
nodeSelector:
{{ toYaml .Values.dfdaemon.nodeSelector | indent 8 }}
{{- end }}
hostNetwork: {{ .Values.dfdaemon.hostNetwork }}
{{- if .Values.dfdaemon.tolerations }}
tolerations:
{{ toYaml .Values.dfdaemon.tolerations | indent 8 }}
Expand All @@ -55,17 +55,29 @@ spec:
imagePullPolicy: {{ .Values.dfdaemon.pullPolicy | quote }}
resources:
{{ toYaml .Values.dfdaemon.resources | indent 12 }}
{{- if .Values.dfdaemon.hostNetwork }}
ports:
- containerPort: 65001
hostPort: 65001
protocol: TCP
{{- end}}
volumeMounts:
- name: config
mountPath: "/etc/dragonfly"
{{- if not .Values.dfdaemon.hostNetwork }}
- name: netns
mountPath: /host/ns/net
securityContext:
capabilities:
add:
- SYS_ADMIN
{{- end}}
volumes:
- name: config
configMap:
name: {{ template "dragonfly.dfdaemon.fullname" . }}
items:
- key: dfget-daemon.yaml
path: dfget-daemon.yaml
{{- if not .Values.dfdaemon.hostNetwork }}
- name: netns
hostPath:
path: /proc/1/ns/net
{{- end}}
42 changes: 0 additions & 42 deletions deploy/charts/dragonfly/templates/scheduler-svc.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ data:
port: {{ .Values.scheduler.containerPort }}
worker:
{{ toYaml .Values.scheduler.config.worker | indent 6 }}
cdn:
list:
- - cdn-name: {{template "dragonfly.cdn.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
ip: {{template "dragonfly.cdn.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
rpc-port: {{ .Values.cdn.service.port }}
download-port: {{ .Values.cdn.service.nginxPort }}
{{- if .Values.scheduler.config.staticCDN }}
dynconfig:
cdnDirPath: /opt/dragonfly/scheduler-cdn
{{- end}}

---

{{- if .Values.scheduler.config.staticCDN }}
apiVersion: v1
kind: ConfigMap
metadata:
name: scheduler-static-cdn
namespace: {{ .Values.installation.namespace }}
{{- end}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
labels:
app: {{ template "dragonfly.scheduler.fullname" . }}
Expand All @@ -9,9 +9,9 @@ metadata:
release: {{ .Release.Name }}
namespace: {{ .Values.installation.namespace }}
name: {{ template "dragonfly.scheduler.fullname" . }}
{{- if .Values.scheduler.deploymentAnnotations }}
{{- if .Values.scheduler.statefulsetAnnotations }}
annotations:
{{ toYaml .Values.scheduler.deploymentAnnotations | indent 4 }}
{{ toYaml .Values.scheduler.statefulsetAnnotations | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.scheduler.replicas }}
Expand All @@ -20,6 +20,7 @@ spec:
app: {{ template "dragonfly.scheduler.fullname" . }}
component: "{{ .Values.scheduler.name }}"
release: {{ .Release.Name }}
serviceName: scheduler
template:
metadata:
labels:
Expand Down Expand Up @@ -61,10 +62,19 @@ spec:
volumeMounts:
- name: config
mountPath: "/etc/dragonfly"
{{- if .Values.scheduler.config.staticCDN }}
- name: cdn-config
mountPath: /opt/dragonfly/scheduler-cdn
{{- end}}
volumes:
- name: config
configMap:
name: {{ template "dragonfly.scheduler.fullname" . }}
items:
- key: scheduler.yaml
path: scheduler.yaml
{{- if .Values.scheduler.config.staticCDN }}
- name: cdn-config
configMap:
name: scheduler-static-cdn
{{- end}}
Loading

0 comments on commit 008ae86

Please sign in to comment.