Skip to content

Commit

Permalink
Add proxy templates
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?
Reactivate pr Alluxio#12165
### Why are the changes needed?
Add proxy templates to helm-chart, in k8s we can use s3 or rest client
api by this proxy.
### Does this PR introduce any user facing changes?

Please list the user-facing changes introduced by your change, including
1. change in user-facing APIs
2. addition or removal of property keys
3. webui

pr-link: Alluxio#14759
change-id: cid-bbb92d2ec41d89c383b46998e1a0690fa094a94a
  • Loading branch information
bzheng888 authored Jul 25, 2022
1 parent debbf8b commit 9bb61b9
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 1 deletion.
2 changes: 2 additions & 0 deletions integration/kubernetes/helm-chart/alluxio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,5 @@

- Support ConfigMap mounts and allow users to mount ConfigMap volumes similar to Secrets

0.6.47
- Support alluxio proxy
2 changes: 1 addition & 1 deletion integration/kubernetes/helm-chart/alluxio/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name: alluxio
apiVersion: v1
description: Open source data orchestration for analytics and machine learning in any cloud.
version: 0.6.46
version: 0.6.47
home: https://www.alluxio.io/
maintainers:
- name: Adit Madan
Expand Down
9 changes: 9 additions & 0 deletions integration/kubernetes/helm-chart/alluxio/helm-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function generateTemplates {
if [[ ! -d "${dir}/worker" ]]; then
mkdir -p ${dir}/worker
fi
if [[ ! -d "${dir}/proxy" ]]; then
mkdir -p ${dir}/proxy
fi
if [[ ! -d "${dir}/logserver" ]]; then
mkdir -p ${dir}/logserver
fi
Expand All @@ -58,6 +61,7 @@ EOF
generateConfigTemplates
generateMasterTemplates
generateWorkerTemplates
generateProxyTemplates
generateFuseTemplates
generateLoggingTemplates
generateCsiTemplates
Expand Down Expand Up @@ -88,6 +92,11 @@ function generateWorkerTemplates {
helm template --name-template ${RELEASE_NAME} . --show-only templates/worker/domain-socket-pvc.yaml -f $dir/config.yaml > "$dir/worker/alluxio-worker-pvc.yaml.template"
}

function generateProxyTemplates {
echo "Generating proxy templates"
helm template --name-template ${RELEASE_NAME} helm-chart/alluxio/ --set proxy.enabled=true --show-only templates/proxy/daemonset.yaml -f $dir/config.yaml > "$dir/proxy/alluxio-proxy-daemonset.yaml.template"
}

function generateFuseTemplates {
echo "Generating fuse templates into $(pwd)fuse/"
if [[ ! -d ./fuse ]]; then
Expand Down
22 changes: 22 additions & 0 deletions integration/kubernetes/helm-chart/alluxio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ resources:
{{- end }}
{{- end -}}

{{- define "alluxio.proxy.resources" -}}
resources:
limits:
{{- if .Values.proxy.resources.limits }}
{{- if .Values.proxy.resources.limits.cpu }}
cpu: {{ .Values.proxy.resources.limits.cpu }}
{{- end }}
{{- if .Values.proxy.resources.limits.memory }}
memory: {{ .Values.proxy.resources.limits.memory }}
{{- end }}
{{- end }}
requests:
{{- if .Values.proxy.resources.requests }}
{{- if .Values.proxy.resources.requests.cpu }}
cpu: {{ .Values.proxy.resources.requests.cpu }}
{{- end }}
{{- if .Values.proxy.resources.requests.memory }}
memory: {{ .Values.proxy.resources.requests.memory }}
{{- end }}
{{- end }}
{{- end -}}

{{- define "alluxio.master.resources" -}}
resources:
limits:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@
{{- $fuseJavaOpts = concat $fuseJavaOpts .Values.fuse.jvmOptions }}
{{- end }}
{{- end }}

{{- /* ===================================== */}}
{{- /* ALLUXIO_PROXY_JAVA_OPTS */}}
{{- /* ===================================== */}}
{{- $proxyJavaOpts := list }}
{{- if eq .Values.proxy.enabled true }}
{{- $proxyJavaOpts = print "-Dalluxio.user.hostname=${ALLUXIO_CLIENT_HOSTNAME}" | append $proxyJavaOpts }}
{{- range $key, $val := .Values.proxy.properties }}
{{- $proxyJavaOpts = printf "-D%v=%v" $key $val | append $proxyJavaOpts }}
{{- end }}
{{- if .Values.proxy.jvmOptions }}
{{- $proxyJavaOpts = concat $proxyJavaOpts .Values.proxy.jvmOptions }}
{{- end }}
{{- end }}

apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -203,6 +218,9 @@ data:
ALLUXIO_WORKER_JAVA_OPTS: |-
{{- /* Format ALLUXIO_WORKER_JAVA_OPTS list to one line */}}
{{ range $key := $workerJavaOpts }}{{ printf "%v " $key }}{{ end }}
ALLUXIO_PROXY_JAVA_OPTS: |-
{{- /* Format ALLUXIO_PROXY_JAVA_OPTS list to one line */}}
{{ range $key := $proxyJavaOpts }}{{ printf "%v " $key }}{{ end }}
ALLUXIO_JOB_WORKER_JAVA_OPTS: |-
{{- /* Format ALLUXIO_JOB_WORKER_JAVA_OPTS list to one line */}}
{{ range $key := $jobWorkerJavaOpts }}{{ printf "%v " $key }}{{ end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#
# The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
# (the "License"). You may not use this work except in compliance with the License, which is
# available at www.apache.org/licenses/LICENSE-2.0
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied, as more fully set forth in the License.
#
# See the NOTICE file distributed with this work for information regarding copyright ownership.
#

{{- if .Values.proxy.enabled }}
{{- $hostNetwork := .Values.proxy.hostNetwork }}
{{- $hostPID := .Values.proxy.hostPID }}
{{- $fullName := include "alluxio.fullname" . }}

apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "alluxio.fullname" . }}-proxy
labels:
app: {{ template "alluxio.name" . }}
chart: {{ template "alluxio.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-proxy
spec:
selector:
matchLabels:
app: {{ template "alluxio.name" . }}
chart: {{ template "alluxio.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-proxy
template:
metadata:
labels:
app: {{ template "alluxio.name" . }}
chart: {{ template "alluxio.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: alluxio-proxy
spec:
hostNetwork: {{ $hostNetwork }}
dnsPolicy: {{ .Values.proxy.dnsPolicy | default ($hostNetwork | ternary "ClusterFirstWithHostNet" "ClusterFirst") }}
nodeSelector:
{{- if .Values.proxy.nodeSelector }}
{{ toYaml .Values.proxy.nodeSelector | trim | indent 8 }}
{{- else if .Values.nodeSelector }}
{{ toYaml .Values.nodeSelector | trim | indent 8 }}
{{- end }}
tolerations:
{{- if .Values.proxy.tolerations }}
{{ toYaml .Values.proxy.tolerations | trim | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
{{ toYaml .Values.tolerations | trim | indent 8 }}
{{- end }}
securityContext:
runAsUser: {{ .Values.user }}
runAsGroup: {{ .Values.group }}
fsGroup: {{ .Values.fsGroup }}
{{- if .Values.proxy.serviceAccount }}
serviceAccountName: {{ .Values.proxy.serviceAccount }}
{{- else if .Values.serviceAccount }}
serviceAccountName: {{ .Values.serviceAccount }}
{{- end }}
{{- if .Values.imagePullSecrets }}
{{ include "alluxio.imagePullSecrets" . | indent 6 }}
{{- end}}
containers:
- name: alluxio-proxy
image: {{ .Values.image }}:{{ .Values.imageTag }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
{{- if .Values.proxy.resources }}
{{ include "alluxio.proxy.resources" . | indent 10 }}
{{- end }}
command: ["/entrypoint.sh"]
{{- if .Values.proxy.args }}
args:
{{ toYaml .Values.proxy.args | trim | indent 12 }}
{{- end }}
env:
{{- range $key, $value := .Values.proxy.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
- name: ALLUXIO_CLIENT_HOSTNAME
valueFrom:
fieldRef:
fieldPath: status.podIP
envFrom:
- configMapRef:
name: {{ $fullName }}-config
ports:
- containerPort: {{ .Values.proxy.ports.web }}
name: web
{{- end }} # proxy enabled
34 changes: 34 additions & 0 deletions integration/kubernetes/helm-chart/alluxio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,40 @@ tieredstore:
high: 0.95
low: 0.7

## Proxy ##
proxy:
enabled: false # Enable this to enable the proxy for REST API
env:
# Extra environment variables for the Proxy pod
# Example:
# JAVA_HOME: /opt/java
args:
- proxy
# Properties for the proxy component
properties:
resources:
requests:
cpu: "0.5"
memory: "1G"
limits:
cpu: "4"
memory: "4G"
ports:
web: 39999
hostNetwork: false
# dnsPolicy will be ClusterFirstWithHostNet if hostNetwork: true
# and ClusterFirst if hostNetwork: false
# You can specify dnsPolicy here to override this inference
# dnsPolicy: ClusterFirst
# JVM options specific to proxy containers
jvmOptions:
nodeSelector: {}
tolerations: []
podAnnotations: {}
# The ServiceAccount provided here will have precedence over
# the global `serviceAccount`
serviceAccount:

# Short circuit related properties
shortCircuit:
enabled: true
Expand Down

0 comments on commit 9bb61b9

Please sign in to comment.