Skip to content

Commit

Permalink
Add helm chart for CacheFSRuntime
Browse files Browse the repository at this point in the history
Fixes: fluid-cloudnative#3674
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
  • Loading branch information
eryugey committed Jan 18, 2024
1 parent db86559 commit 8b800d9
Show file tree
Hide file tree
Showing 17 changed files with 1,338 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/cachefs/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
3 changes: 3 additions & 0 deletions charts/cachefs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.1.0

- Support Kubernetes Orchestration via Fluid
10 changes: 10 additions & 0 deletions charts/cachefs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: cachefs
apiVersion: v1
description: File system that cache & accelerate any POSIX directory with distributed cache
version: 0.1.0
appVersion: v1.0.0
maintainers:
- name: Eryu Guan
email: eguan@linux.alibaba.com
- name: Qinqi Qu
email: quqinqi@linux.alibaba.com
7 changes: 7 additions & 0 deletions charts/cachefs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CacheFS

CacheFS is a distributed file system that could cache & accelerate any given POSIX directory with distributed cache.

## Introduction

This chart bootstraps cachefs on a [Kubernetes](https://kubernetes.io/) cluster using the [Helm](https://helm.sh/) package manager.
32 changes: 32 additions & 0 deletions charts/cachefs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cachefs.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "cachefs.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "cachefs.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
169 changes: 169 additions & 0 deletions charts/cachefs/templates/fuse/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{{ if .Values.fuse.enabled -}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ template "cachefs.fullname" . }}-fuse
labels:
app: {{ template "cachefs.name" . }}
chart: {{ template "cachefs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: cachefs-fuse
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
updateStrategy:
type: {{ .Values.fuse.updateStrategy.type }}
selector:
matchLabels:
app: {{ template "cachefs.name" . }}
chart: {{ template "cachefs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: cachefs-fuse
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
{{- if .Values.fuse.annotations }}
{{- range $key, $val := .Values.fuse.annotations}}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
labels:
app: {{ template "cachefs.name" . }}
chart: {{ template "cachefs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: cachefs-fuse
{{- if .Values.fuse.labels }}
{{- range $key, $val := .Values.fuse.labels }}
{{ $key | quote }}: {{ $val | quote }}
{{- end }}
{{- end }}
spec:
{{- if .Values.fuse.criticalPod }}
priorityClassName: system-node-critical
{{- end }}
{{- if .Values.fuse.hostNetwork }}
hostNetwork: {{ .Values.fuse.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
nodeSelector:
{{- if .Values.fuse.nodeSelector }}
{{ toYaml .Values.fuse.nodeSelector | trim | indent 8 }}
{{- else if .Values.nodeSelector }}
{{ toYaml .Values.nodeSelector | trim | indent 8 }}
{{- end }}
tolerations:
- operator: Exists
containers:
- name: cachefs-fuse
image: {{ .Values.fuse.image }}:{{ .Values.fuse.imageTag }}
imagePullPolicy: {{ .Values.fuse.imagePullPolicy }}
{{- if .Values.fuse.resources }}
resources:
{{ toYaml .Values.fuse.resources | trim | indent 12 }}
{{- end }}
command: ["sh", "/root/script/script.sh"]
env:
- name: CFS_FOREGROUND
value: "1"
{{- if .Values.fuse.envs }}
{{ toYaml .Values.fuse.envs | trim | indent 10 }}
{{- end }}
{{- if .Values.configs.metaurlSecret }}
- name: METAURL
valueFrom:
secretKeyRef:
name: {{ .Values.configs.metaurlSecret }}
key: {{ .Values.configs.metaurlSecretKey }}
{{- end }}
{{- if and .Values.configs.encryptEnvOptions (gt (len .Values.configs.encryptEnvOptions) 0) }}
{{- range $encryptEnvOption := .Values.configs.encryptEnvOptions }}
- name: {{ $encryptEnvOption.envName }}
valueFrom:
secretKeyRef:
name: {{ $encryptEnvOption.secretKeyRefName }}
key: {{ $encryptEnvOption.secretKeyRefKey }}
{{- end }}
{{- end }}
- name: FLUID_RUNTIME_TYPE
value: "cachefs"
- name: FLUID_RUNTIME_NS
value: {{ .Values.runtimeIdentity.namespace }}
- name: FLUID_RUNTIME_NAME
value: {{ .Values.runtimeIdentity.name }}
ports:
{{- if .Values.fuse.metricsPort }}
- containerPort: {{ .Values.fuse.metricsPort }}
name: metrics
protocol: TCP
{{- end }}
securityContext:
runAsUser: 0
{{- if .Values.fuse.privileged }}
privileged: true
{{- end }}
lifecycle:
preStop:
exec:
command: ["sh", "-c", "umount {{ .Values.fuse.mountPath }}"]
volumeMounts:
- name: cachefs-fuse-mount
mountPath: {{ .Values.fuse.hostMountPath }}
mountPropagation: Bidirectional
- mountPath: /root/script
name: script
{{- if .Values.fuse.volumeMounts }}
{{ toYaml .Values.fuse.volumeMounts | indent 12 }}
{{- end }}
restartPolicy: Always
volumes:
- name: cachefs-fuse-mount
hostPath:
path: {{ .Values.fuse.hostMountPath }}
type: DirectoryOrCreate
- name: script
configMap:
name: {{ template "cachefs.fullname" . }}-fuse-script
defaultMode: 0755
{{- if .Values.fuse.volumes }}
{{ toYaml .Values.fuse.volumes | indent 8 }}
{{- end }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "cachefs.fullname" . }}-fuse-script
labels:
app: {{ template "cachefs.name" . }}
chart: {{ template "cachefs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: cachefs-fuse
ownerReferences:
{{- if .Values.owner.enabled }}
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
data:
script.sh: |
#!/bin/bash
set -e
echo "$(date '+%Y/%m/%d %H:%M:%S').$(printf "%06d" $(echo $(date '+%N')/1000|bc)) cachefs mount start."
{{ .Values.fuse.command }}
{{- end }}
48 changes: 48 additions & 0 deletions charts/cachefs/templates/master/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2024 The Fluid Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

{{- if .Values.master.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "cachefs.fullname" . }}-master-svc
labels:
app: {{ template "cachefs.name" . }}
chart: {{ template "cachefs.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
role: cachefs-master-svc
{{- if .Values.owner.enabled }}
ownerReferences:
- apiVersion: {{ .Values.owner.apiVersion }}
blockOwnerDeletion: {{ .Values.owner.blockOwnerDeletion }}
controller: {{ .Values.owner.controller }}
kind: {{ .Values.owner.kind }}
name: {{ .Values.owner.name }}
uid: {{ .Values.owner.uid }}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
selector:
app: {{ template "cachefs.name" . }}
chart: {{ template "cachefs.chart" . }}
release: {{ .Release.Name }}
role: cachefs-master
ports:
- name: master-port
port: {{ .Values.master.port }}
protocol: TCP
{{- end }}
Loading

0 comments on commit 8b800d9

Please sign in to comment.