diff --git a/charts/podinfo/README.md b/charts/podinfo/README.md index c1b5f2d..b0bff2a 100644 --- a/charts/podinfo/README.md +++ b/charts/podinfo/README.md @@ -37,6 +37,7 @@ Parameter | Default | Description `backend` | `None` | Echo backend URL `backends` | `[]` | Array of echo backend URLs `cache` | `None` | Redis address in the format `:` +`redis.enabled` | `false` | Create Redis deployment for caching purposes `ui.color` | `#34577c` | UI color `ui.message` | `None` | UI greetings message `ui.logo` | `None` | UI logo diff --git a/charts/podinfo/templates/deployment.yaml b/charts/podinfo/templates/deployment.yaml index d53667a..141ca15 100644 --- a/charts/podinfo/templates/deployment.yaml +++ b/charts/podinfo/templates/deployment.yaml @@ -54,6 +54,8 @@ spec: {{- end }} {{- if .Values.cache }} - --cache-server={{ .Values.cache }} + {{- else if .Values.redis.enabled }} + - --cache-server={{ template "podinfo.fullname" . }}:6379 {{- end }} - --level={{ .Values.logLevel }} - --random-delay={{ .Values.faults.delay }} diff --git a/charts/podinfo/templates/redis/config.yaml b/charts/podinfo/templates/redis/config.yaml new file mode 100644 index 0000000..cd63785 --- /dev/null +++ b/charts/podinfo/templates/redis/config.yaml @@ -0,0 +1,12 @@ +{{- if .Values.redis.enabled -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "podinfo.fullname" . }}-redis +data: + redis.conf: | + maxmemory 64mb + maxmemory-policy allkeys-lru + save "" + appendonly no +{{- end }} diff --git a/charts/podinfo/templates/redis/deployment.yaml b/charts/podinfo/templates/redis/deployment.yaml new file mode 100644 index 0000000..7888855 --- /dev/null +++ b/charts/podinfo/templates/redis/deployment.yaml @@ -0,0 +1,68 @@ +{{- if .Values.redis.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "podinfo.fullname" . }}-redis + labels: + app: {{ template "podinfo.fullname" . }}-redis +spec: + strategy: + type: Recreate + selector: + matchLabels: + app: {{ template "podinfo.fullname" . }}-redis + template: + metadata: + labels: + app: {{ template "podinfo.fullname" . }}-redis + annotations: + checksum/config: {{ include (print $.Template.BasePath "/redis/config.yaml") . | sha256sum | quote }} + spec: + {{- if .Values.serviceAccount.enabled }} + serviceAccountName: {{ template "podinfo.serviceAccountName" . }} + {{- end }} + containers: + - name: redis + image: "{{ .Values.redis.repository }}:{{ .Values.redis.tag }}" + imagePullPolicy: IfNotPresent + command: + - redis-server + - "/redis-master/redis.conf" + ports: + - name: redis + containerPort: 6379 + protocol: TCP + livenessProbe: + tcpSocket: + port: redis + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - redis-cli + - ping + initialDelaySeconds: 5 + timeoutSeconds: 5 + resources: + limits: + cpu: 1000m + memory: 128Mi + requests: + cpu: 100m + memory: 32Mi + volumeMounts: + - mountPath: /var/lib/redis + name: data + - mountPath: /redis-master + name: config + volumes: + - name: data + emptyDir: {} + - name: config + configMap: + name: {{ template "podinfo.fullname" . }}-redis + items: + - key: redis.conf + path: redis.conf +{{- end }} diff --git a/charts/podinfo/templates/redis/service.yaml b/charts/podinfo/templates/redis/service.yaml new file mode 100644 index 0000000..e206851 --- /dev/null +++ b/charts/podinfo/templates/redis/service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.redis.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "podinfo.fullname" . }}-redis + labels: + app: {{ template "podinfo.fullname" . }}-redis +spec: + type: ClusterIP + selector: + app: {{ template "podinfo.fullname" . }}-redis + ports: + - name: redis + port: 6379 + protocol: TCP + targetPort: redis +{{- end }} diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index 758fa28..2d1b873 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -4,7 +4,6 @@ replicaCount: 1 logLevel: info backend: #http://backend-podinfo:9898/echo backends: [] -cache: "" ui: color: "#34577c" @@ -48,6 +47,14 @@ hpa: # average http requests per second per pod (k8s-prometheus-adapter) requests: +# Redis address in the format : +cache: "" +# Redis deployment +redis: + enabled: false + repository: redis + tag: 6.0.1 + serviceAccount: # Specifies whether a service account should be created enabled: false