diff --git a/fastdfs-nginx/.helmignore b/fastdfs-nginx/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/fastdfs-nginx/.helmignore @@ -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 diff --git a/fastdfs-nginx/Chart.yaml b/fastdfs-nginx/Chart.yaml new file mode 100644 index 0000000..6fa4619 --- /dev/null +++ b/fastdfs-nginx/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v2 +appVersion: "6.08" +dependencies: +- name: common + repository: https://charts.bitnami.com/bitnami + tags: + - bitnami-common + version: 1.x.x +description: FastDFS-Nginx chart for Kubernetes +name: fastdfs-nginx +version: 2.1.0 +home: https://github.com/happyfish100/fastdfs +icon: +keywords: +- fastdfs +maintainers: +- email: 29ygq@sina.com + name: ygqygq2 diff --git a/fastdfs-nginx/README.md b/fastdfs-nginx/README.md new file mode 100644 index 0000000..073c1db --- /dev/null +++ b/fastdfs-nginx/README.md @@ -0,0 +1,71 @@ +# FastDF-Nginx - Multiple tracker, Multiple storage + +[FastDFS](https://github.com/happyfish100/fastdfs) is an open source high performance distributed file system (DFS). It's major functions include: file storing, file syncing and file accessing, and design for high capacity and load balance. + +## Introduction + +This chart bootstraps tracker and storage stateful-application on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. Largely inspired by this [tutorial](https://kubernetes.io/docs/tutorials/stateful-application/run-replicated-stateful-application/), further work was made to 'production-ize' the example. + +## Prerequisites + +- Kubernetes 1.6+ +- PV provisioner support in the underlying infrastructure + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install my-release local/fastdfs-nginx +``` + +The command deploys FastDFS-Nginx cluster on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +### Uninstall + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +## Configuration + +The following table lists the configurable parameters of the FastDFS-Nginx chart and their default values. + +| Parameter | Description | Default | +| ----------------------- | ----------------------------------- | -------------------------------------- | +| `fastdfs.storage` | storage replicas number and pvc size| See `values.yaml` | +| `fastdfs.tracker` | tracker replicas number, pvc size and nginx config file.| See `values.yaml` | +| `service.type` | Service type. | `ClusterIP` | +| `image` | `fastdfs-nginx` image, tag. | `ygqygq2/fastdfs-nginx` `V6.07` | +| `trackerPorts` | tracker and nginx ports. | See `values.yaml` | +| `storagePorts` | storage and nginx ports. | See `values.yaml` | +| `ingress` | Ingress for the fastdfs tracker nginx.| `false` | +| `persistentVolume.enabled` | Create a volume to store data | true | +| `persistence.storageClass` | Type of persistent volume claim | `nil` | +| `persistence.accessModes` | Persistent volume access modes | `[ReadWriteOnce]` | +| `persistence.annotations` | Persistent volume annotations | `{}` | +| `resources` | CPU/Memory resource requests/limits | Memory: `128Mi`, CPU: `100m` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +## Persistence + +The [FastDFS image](https://github.com/ygqygq2/fastdfs-nginx) stores the data and configurations at the `/var/fdfs` path of the container. + +By default persistence is enabled, and a PersistentVolumeClaim is created and mounted in that directory. As a result, a persistent volume will need to be defined: + +``` +# https://kubernetes.io/docs/user-guide/persistent-volumes/#azure-disk +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: fast +provisioner: kubernetes.io/azure-disk +parameters: + skuName: Premium_LRS + location: westus +``` + +In order to disable this functionality you can change the values.yaml to disable persistence and use an emptyDir instead. diff --git a/fastdfs-nginx/templates/NOTES.txt b/fastdfs-nginx/templates/NOTES.txt new file mode 100644 index 0000000..ce420d9 --- /dev/null +++ b/fastdfs-nginx/templates/NOTES.txt @@ -0,0 +1,16 @@ +Thank you for installing {{ .Chart.Name }}. + +Your release is named {{ .Release.Name }}. + +Your can use tracker should look like: + {{ template "fastdfs-nginx.fullname" . }}-tracker-0.{{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ .Values.trackerPorts.tracker.containerPort }} + {{ template "fastdfs-nginx.fullname" . }}-tracker-1.{{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ .Values.trackerPorts.tracker.containerPort }} + +You can also use the service {{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ .Values.trackerPorts.tracker.containerPort }} to connect to an available tracker server. + +Your can access tracker nginx should look like: + {{ template "fastdfs-nginx.fullname" . }}-tracker-0.{{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ .Values.trackerPorts.trackernginx.containerPort }} + {{ template "fastdfs-nginx.fullname" . }}-tracker-1.{{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ .Values.trackerPorts.trackernginx.containerPort }} + +You can also use the service {{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ .Values.trackerPorts.trackernginx.containerPort }} to connect to an available tracker nginx server. + diff --git a/fastdfs-nginx/templates/_helpers.tpl b/fastdfs-nginx/templates/_helpers.tpl new file mode 100644 index 0000000..b33d2ba --- /dev/null +++ b/fastdfs-nginx/templates/_helpers.tpl @@ -0,0 +1,113 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "fastdfs-nginx.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 "fastdfs-nginx.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 "fastdfs-nginx.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Return the proper image name +*/}} +{{- define "fastdfs-nginx.image" -}} +{{- $registryName := .Values.image.registry -}} +{{- $repositoryName := .Values.image.repository -}} +{{- $tag := .Values.image.tag | toString -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. +Also, we can't use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} + {{- if .Values.global.imageRegistry }} + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} + {{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} + {{- end -}} +{{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} +{{- end -}} + +{{/* +Return the proper image name (for the metrics image) +*/}} +{{- define "fastdfs-nginx.metrics.image" -}} +{{- $registryName := .Values.metrics.image.registry -}} +{{- $repositoryName := .Values.metrics.image.repository -}} +{{- $tag := .Values.metrics.image.tag | toString -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic. +Also, we can't use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} + {{- if .Values.global.imageRegistry }} + {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}} + {{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} + {{- end -}} +{{- else -}} + {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}} +{{- end -}} +{{- end -}} + +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "fastdfs-nginx.imagePullSecrets" -}} +{{/* +Helm 2.11 supports the assignment of a value to a variable defined in a different scope, +but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic. +Also, we can not use a single if because lazy evaluation is not an option +*/}} +{{- if .Values.global }} +{{- if .Values.global.imagePullSecrets }} +imagePullSecrets: +{{- range .Values.global.imagePullSecrets }} + - name: {{ . }} +{{- end }} +{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- range .Values.metrics.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- else if or .Values.image.pullSecrets .Values.metrics.image.pullSecrets }} +imagePullSecrets: +{{- range .Values.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- range .Values.metrics.image.pullSecrets }} + - name: {{ . }} +{{- end }} +{{- end -}} +{{- end -}} diff --git a/fastdfs-nginx/templates/configmap.yaml b/fastdfs-nginx/templates/configmap.yaml new file mode 100644 index 0000000..a6ce05f --- /dev/null +++ b/fastdfs-nginx/templates/configmap.yaml @@ -0,0 +1,48 @@ +{{- $root := . -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fastdfs-nginx.fullname" $root }} + labels: + app: {{ template "fastdfs-nginx.fullname" $root }} + chart: {{ template "fastdfs-nginx.chart" $root }} + release: "{{ $.Release.Name }}" + heritage: "{{ $.Release.Service }}" +data: + tracker.conf: | + #tracker.conf + {{- range $skey, $svalue := $.Values.fastdfs.storage }} + upstream fdfs_{{ $svalue.name }} { + dynamic_resolve fallback=stale fail_timeout=30s; + {{- range $i, $e := until (int $svalue.replica) }} + {{- $storageNginxPort := $.Values.storagePorts.storagenginx.containerPort }} + {{- $storagePodName := (printf "%s-storage-%s-%d" (include "fastdfs-nginx.fullname" $root) $svalue.name $i) }} + {{- $storageServiceName := (printf "%s-storage-%s-headless" (include "fastdfs-nginx.fullname" $root) $svalue.name) }} + server {{ $storagePodName }}.{{ $storageServiceName }}:{{ $storageNginxPort }}; + {{- end }} + check interval=3000 rise=2 fall=5 timeout=1000 type=http; + } + {{- end }} + server { + listen 80 ; + # server_name _ ; + + location / { + root html; + index index.html index.htm; + } + location /status { + check_status; + access_log off; + allow 127.0.0.1; + deny all; + } + {{- range $skey, $svalue := $.Values.fastdfs.storage }} + location ~/{{ $svalue.name }}/ { + proxy_pass http://fdfs_{{ $svalue.name }}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + {{- end }} + } diff --git a/fastdfs-nginx/templates/ingress.yaml b/fastdfs-nginx/templates/ingress.yaml new file mode 100644 index 0000000..03892b9 --- /dev/null +++ b/fastdfs-nginx/templates/ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "fastdfs-nginx.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +{{- $http := .Values.trackerPorts.trackernginx.containerPort -}} +apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "fastdfs-nginx.name" . }} + chart: {{ template "fastdfs-nginx.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: + {{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }} + ingressClassName: {{ .Values.ingress.ingressClassName | quote }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: {{ $ingressPath }} + {{- if eq "true" (include "common.ingress.supportsPathType" $) }} + pathType: {{ $.Values.ingress.pathType }} + {{- end }} + backend: {{- include "common.ingress.backend" (dict "serviceName" (printf "%s-%s" (include "common.names.fullname" $) "tracker") "servicePort" $http "context" $) | nindent 14 }} + {{- end }} +{{- end }} diff --git a/fastdfs-nginx/templates/storage-service-headless.yaml b/fastdfs-nginx/templates/storage-service-headless.yaml new file mode 100644 index 0000000..dfe0aea --- /dev/null +++ b/fastdfs-nginx/templates/storage-service-headless.yaml @@ -0,0 +1,30 @@ +{{ $root := . }} +{{- range $skey, $svalue := $.Values.fastdfs.storage }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fastdfs-nginx.fullname" $root }}-storage-{{ $svalue.name }}-headless + labels: + app: {{ template "fastdfs-nginx.name" $root }} + chart: {{ template "fastdfs-nginx.chart" $root }} + release: {{ $.Release.Name }} + heritage: {{ $.Release.Service }} +{{- if $.Values.headless.annotations }} + annotations: +{{ $.Values.headless.annotations | toYaml | trimSuffix "\n" | indent 4 }} +{{- end }} +spec: + clusterIP: None + publishNotReadyAddresses: true + ports: +{{- range $key, $port := $.Values.storagePorts }} + - name: {{ $key }} + port: {{ $port.containerPort }} + targetPort: {{ $port.name }} + protocol: {{ $port.protocol }} +{{- end }} + selector: + app: {{ template "fastdfs-nginx.name" $root }}-storage-{{ $svalue.name }} + release: {{ $.Release.Name }} +--- +{{- end }} diff --git a/fastdfs-nginx/templates/storage-service.yaml b/fastdfs-nginx/templates/storage-service.yaml new file mode 100644 index 0000000..e757bb3 --- /dev/null +++ b/fastdfs-nginx/templates/storage-service.yaml @@ -0,0 +1,24 @@ +{{ $root := . }} +{{- range $skey, $svalue := $.Values.fastdfs.storage }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fastdfs-nginx.fullname" $root }}-storage-{{ $svalue.name }} + labels: + app: {{ template "fastdfs-nginx.name" $root }} + chart: {{ template "fastdfs-nginx.chart" $root }} + release: {{ $.Release.Name }} + heritage: {{ $.Release.Service }} +spec: + ports: +{{- range $key, $port := $.Values.storagePorts }} + - name: {{ $key }} + port: {{ $port.containerPort }} + targetPort: {{ $port.name }} + protocol: {{ $port.protocol }} +{{- end }} + selector: + app: {{ template "fastdfs-nginx.name" $root }}-storage-{{ $svalue.name }} + release: {{ $.Release.Name }} +--- +{{- end }} diff --git a/fastdfs-nginx/templates/storage-statefulset.yaml b/fastdfs-nginx/templates/storage-statefulset.yaml new file mode 100644 index 0000000..d5cb862 --- /dev/null +++ b/fastdfs-nginx/templates/storage-statefulset.yaml @@ -0,0 +1,118 @@ +{{- $root := . -}} +{{- range $skey, $svalue := .Values.fastdfs.storage }} +apiVersion: "{{ include "common.capabilities.statefulset.apiVersion" $root }}" +kind: StatefulSet +metadata: + labels: + app: {{ template "fastdfs-nginx.name" $root }} + chart: {{ template "fastdfs-nginx.chart" $root }} + heritage: {{ $.Release.Service }} + release: {{ $.Release.Name }} + name: {{ template "fastdfs-nginx.fullname" $root }}-storage-{{ $svalue.name }} +spec: + selector: + matchLabels: + app: {{ template "fastdfs-nginx.name" $root }}-storage-{{ $svalue.name }} + release: {{ $.Release.Name }} + serviceName: {{ template "fastdfs-nginx.fullname" $root }}-storage-{{ $svalue.name }}-headless + replicas: {{ $svalue.replica }} + template: + metadata: + labels: + app: {{ template "fastdfs-nginx.name" $root }}-storage-{{ $svalue.name }} + release: {{ $.Release.Name }} + annotations: + {{- if $.Values.podAnnotations }} +{{ toYaml $.Values.podAnnotations | indent 8 }} + {{- end }} + spec: + containers: + - name: {{ template "fastdfs-nginx.name" $root }} + image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}" + imagePullPolicy: "{{ $.Values.image.pullPolicy }}" + args: + - storage + env: + - name: GROUP_NAME + value: {{ $svalue.name }} + - name: TRACKER_SERVER + value: {{ template "fastdfs-nginx.fullname" $root }}-tracker-headless:{{ $.Values.trackerPorts.tracker.containerPort }} + ports: + - name: storage + containerPort: {{ $.Values.storagePorts.storage.containerPort }} + - name: storage-nginx + containerPort: {{ $.Values.storagePorts.storagenginx.containerPort }} + resources: +{{ toYaml $.Values.resources.storage | indent 12 }} + volumeMounts: + - name: data-storage + mountPath: /var/fdfs + readinessProbe: + exec: + command: + - bash + - "-c" + - | + set -x + ps aux |grep 'fdfs_storaged /etc/fdfs/storage.conf start'|grep -v grep \ + && curl --connect-timeout 1 -s 127.0.0.1:{{ $.Values.storagePorts.storagenginx.containerPort }} + initialDelaySeconds: 30 + periodSeconds: 20 + failureThreshold: 3 + livenessProbe: + exec: + command: + - bash + - "-c" + - | + set -x + ps aux |grep 'fdfs_storaged /etc/fdfs/storage.conf start'|grep -v grep \ + && curl --connect-timeout 1 -s 127.0.0.1:{{ $.Values.storagePorts.storagenginx.containerPort }} + initialDelaySeconds: 30 + periodSeconds: 20 + failureThreshold: 3 + volumes: + {{- with $.Values.nodeSelector }} + nodeSelector: + {{ toYaml $root | indent 8 }} + {{- end }} + {{- with $.Values.affinity }} + affinity: + {{ toYaml $root | indent 8 }} + {{- end }} + {{- with $.Values.tolerations }} + tolerations: + {{ toYaml $root | indent 8 }} + {{- end }} + {{- if $.Values.persistentVolume.enabled }} + volumeClaimTemplates: + - metadata: + name: data-storage + labels: + app: {{ template "fastdfs-nginx.name" $root }} + chart: {{ template "fastdfs-nginx.chart" $root }} + release: {{ $.Release.Name }} + heritage: {{ $.Release.Service }} + spec: + accessModes: + - {{ $.Values.persistentVolume.accessMode | quote }} + annotations: + {{- range $key, $value := $.Values.persistentVolume.annotations }} + {{ $key }}: {{ $value }} + {{- end }} + resources: + requests: + storage: {{ $svalue.size }} + {{- if $.Values.persistentVolume.storageClass }} + {{- if (eq "-" $.Values.persistentVolume.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ $.Values.persistentVolume.storageClass }}" + {{- end }} + {{- end }} + {{- else }} + - name: data-storage + emptyDir: {} + {{- end }} +--- +{{- end }} diff --git a/fastdfs-nginx/templates/tracker-service-headless.yaml b/fastdfs-nginx/templates/tracker-service-headless.yaml new file mode 100644 index 0000000..1558735 --- /dev/null +++ b/fastdfs-nginx/templates/tracker-service-headless.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fastdfs-nginx.fullname" . }}-tracker-headless + labels: + app: {{ template "fastdfs-nginx.name" . }} + chart: {{ template "fastdfs-nginx.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- if .Values.headless.annotations }} + annotations: +{{ .Values.headless.annotations | toYaml | trimSuffix "\n" | indent 4 }} +{{- end }} +spec: + clusterIP: None + publishNotReadyAddresses: true + ports: +{{- range $key, $port := .Values.trackerPorts }} + - name: {{ $key }} + port: {{ $port.containerPort }} + targetPort: {{ $port.name }} + protocol: {{ $port.protocol }} +{{- end }} + selector: + app: {{ template "fastdfs-nginx.name" . }}-tracker + release: {{ .Release.Name }} diff --git a/fastdfs-nginx/templates/tracker-service.yaml b/fastdfs-nginx/templates/tracker-service.yaml new file mode 100644 index 0000000..baf098a --- /dev/null +++ b/fastdfs-nginx/templates/tracker-service.yaml @@ -0,0 +1,21 @@ +{{ $root := . }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fastdfs-nginx.fullname" $root }}-tracker + labels: + app: {{ template "fastdfs-nginx.name" $root }} + chart: {{ template "fastdfs-nginx.chart" $root }} + release: {{ $.Release.Name }} + heritage: {{ $.Release.Service }} +spec: + ports: +{{- range $key, $port := $.Values.trackerPorts }} + - name: {{ $key }} + port: {{ $port.containerPort }} + targetPort: {{ $port.name }} + protocol: {{ $port.protocol }} +{{- end }} + selector: + app: {{ template "fastdfs-nginx.name" $root }}-tracker + release: {{ $.Release.Name }} diff --git a/fastdfs-nginx/templates/tracker-statefulset.yaml b/fastdfs-nginx/templates/tracker-statefulset.yaml new file mode 100644 index 0000000..9ce4fe3 --- /dev/null +++ b/fastdfs-nginx/templates/tracker-statefulset.yaml @@ -0,0 +1,124 @@ +apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} +kind: StatefulSet +metadata: + labels: + app: {{ template "fastdfs-nginx.name" . }} + chart: {{ template "fastdfs-nginx.chart" . }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + name: {{ template "fastdfs-nginx.fullname" . }}-tracker +spec: + selector: + matchLabels: + app: {{ template "fastdfs-nginx.name" . }}-tracker + release: {{ .Release.Name }} + serviceName: {{ template "fastdfs-nginx.fullname" . }}-tracker-headless + replicas: {{ .Values.fastdfs.tracker.replica }} + template: + metadata: + labels: + app: {{ template "fastdfs-nginx.name" . }}-tracker + release: {{ .Release.Name }} + annotations: + {{- if .Values.podAnnotations }} +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} + spec: + containers: + - name: {{ template "fastdfs-nginx.name" . }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: TRACKER_SERVER + value: {{ template "fastdfs-nginx.fullname" . }}-tracker-headless:{{ $.Values.trackerPorts.tracker.containerPort }} + ports: + - name: tracker + containerPort: {{ .Values.trackerPorts.tracker.containerPort }} + - name: tracker-nginx + containerPort: {{ .Values.trackerPorts.trackernginx.containerPort }} + resources: +{{ toYaml .Values.resources.tracker | indent 12 }} + volumeMounts: + - name: data-tracker + mountPath: /var/fdfs + - name: config-map + mountPath: /usr/local/nginx/conf/conf.d + readinessProbe: + exec: + command: + - bash + - "-c" + - | + set -x + curl --connect-timeout 1 -s 127.0.0.1:{{ $.Values.trackerPorts.trackernginx.containerPort }} \ + && /usr/local/nginx/sbin/nginx -s reload || { + {{- $root := . -}} + {{- range $skey, $svalue := .Values.fastdfs.storage }} + echo 127.0.0.1 {{ template "fastdfs-nginx.fullname" $root }}-storage-{{ $svalue.name }}-headless >> /etc/hosts + {{- end }} + /usr/local/nginx/sbin/nginx + cat /etc/hosts > /tmp/hosts.tmp + {{- $root := . -}} + {{- range $skey, $svalue := .Values.fastdfs.storage }} + sed -i "/{{ template "fastdfs-nginx.fullname" $root }}-storage-{{ $svalue.name }}-headless/d" /tmp/hosts.tmp + {{- end }} + cat /tmp/hosts.tmp > /etc/hosts + } + initialDelaySeconds: 5 + periodSeconds: 60 + livenessProbe: + exec: + command: + - bash + - "-c" + - | + set -ex + ps aux |grep 'fdfs_trackerd /etc/fdfs/tracker.conf start'|grep -v grep + initialDelaySeconds: 5 + periodSeconds: 20 + volumes: + - name: config-map + configMap: + name: {{ template "fastdfs-nginx.fullname" . }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} +{{- if .Values.persistentVolume.enabled }} + volumeClaimTemplates: + - metadata: + name: data-tracker + labels: + app: {{ template "fastdfs-nginx.name" . }} + chart: {{ template "fastdfs-nginx.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + spec: + accessModes: + - {{ .Values.persistentVolume.accessMode | quote }} + annotations: + {{- range $key, $value := .Values.persistentVolume.annotations }} + {{ $key }}: {{ $value }} + {{- end }} + resources: + requests: + storage: {{ .Values.fastdfs.tracker.size | quote }} + {{- if .Values.persistentVolume.storageClass }} + {{- if (eq "-" .Values.persistentVolume.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.persistentVolume.storageClass }}" + {{- end }} + {{- end }} +{{- else }} + - name: data-tracker + emptyDir: {} +{{- end -}} diff --git a/fastdfs-nginx/values.yaml b/fastdfs-nginx/values.yaml new file mode 100644 index 0000000..1460c31 --- /dev/null +++ b/fastdfs-nginx/values.yaml @@ -0,0 +1,148 @@ +## @section Global parameters +## Global Docker image parameters +## Please, note that this will override the image parameters, including dependencies, configured to use the global value +## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass +## + +## @param global.imageRegistry Global Docker image registry +## @param global.imagePullSecrets Global Docker registry secret names as an array +## @param global.storageClass Global StorageClass for Persistent Volume(s) +## @param global.redis.password Global Redis™ password (overrides `auth.password`) +## +global: + imageRegistry: "" + ## E.g. + ## imagePullSecrets: + ## - myRegistryKeySecretName + ## + imagePullSecrets: [] +# - myRegistryKeySecretName + +## @section Common parameters + +## @param nameOverride String to partially override nginx.fullname template (will maintain the release name) +## +nameOverride: "" +## @param fullnameOverride String to fully override nginx.fullname template +## +fullnameOverride: "" +## @param kubeVersion Force target Kubernetes version (using Helm capabilities if not set) +## +kubeVersion: "" +## @param clusterDomain Kubernetes Cluster Domain +## +clusterDomain: cluster.local +## @param extraDeploy Extra objects to deploy (value evaluated as a template) +## +extraDeploy: [] +## @param commonLabels Add labels to all the deployed resources +## +commonLabels: {} +## @param commonAnnotations Add annotations to all the deployed resources +## +commonAnnotations: {} + +# Default values for yapi. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + + +## replicas number and pvc size +fastdfs: + storage: + - name: group1 + replica: 2 + size: 20Gi + - name: group2 + replica: 2 + size: 2Gi + tracker: + replica: 2 + size: 5Gi + +service: + type: ClusterIP + annotations: {} + +image: + repository: ygqygq2/fastdfs-nginx + tag: V6.08-tengine + pullPolicy: IfNotPresent + +## Headless service. +## +headless: + annotations: {} + +trackerPorts: + tracker: + containerPort: 22122 # Port number for fastdfs container tracker port. + protocol: TCP # Protocol + trackernginx: + containerPort: 80 # Port number for fastdfs container nginx port. + protocol: TCP # Protocol + +storagePorts: + storage: + containerPort: 23000 # Port number for fastdfs container storage port. + protocol: TCP # Protocol + storagenginx: + containerPort: 8080 # Port number for fastdfs container nginx port. + protocol: TCP # Protocol + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + ingressClassName: "" + path: / + pathType: ImplementationSpecific + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +## Configure resource requests and limits +### ref: http://kubernetes.io/docs/user-guide/compute-resources/ +### +resources: + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + tracker: + requests: + cpu: 100m + memory: 128Mi + storage: + requests: + cpu: 100m + memory: 128Mi + +## Node labels and tolerations for pod assignment +### ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector +### ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#taints-and-tolerations-beta-feature +nodeSelector: {} +tolerations: [] +affinity: {} + +## Enable persistence using Persistent Volume Claims +## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ +## +persistentVolume: + enabled: false + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, azure-disk on + ## Azure, standard on GKE, AWS & OpenStack) + ## + storageClass: "-" + accessMode: ReadWriteOnce + annotations: {} diff --git a/local-values/mysql/crm1.yaml b/local-values/mysql/crm1.yaml index b4481c5..96e41a1 100644 --- a/local-values/mysql/crm1.yaml +++ b/local-values/mysql/crm1.yaml @@ -495,7 +495,7 @@ secondary: max_allowed_packet=16M bind-address=0.0.0.0 pid-file=/opt/bitnami/mysql/tmp/mysqld.pid - log-error=/opt/bitnami/mysql/logs/mysqld.log + log-error=/bitnami/mysql/logs/mysqld.log character-set-server=UTF8 collation-server=utf8_general_ci server_id=101