diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml new file mode 100644 index 0000000..a013588 --- /dev/null +++ b/.github/workflows/lint-test.yaml @@ -0,0 +1,45 @@ +name: Lint and Test Charts + +on: pull_request + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.12.1 + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1.8.0 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..b3f2cf5 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,25 @@ +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a123916 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +### Helm template +# Chart dependencies +**/charts/*.tgz + diff --git a/charts/mongodb/.helmignore b/charts/mongodb/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/mongodb/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/mongodb/Chart.yaml b/charts/mongodb/Chart.yaml new file mode 100644 index 0000000..ffd58d8 --- /dev/null +++ b/charts/mongodb/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: mongodb +description: Mongo standalone Helm chart for Kubernetes +type: application +version: 0.3.1 +appVersion: "0.3.0" + diff --git a/charts/mongodb/templates/NOTES.txt b/charts/mongodb/templates/NOTES.txt new file mode 100644 index 0000000..23223e1 --- /dev/null +++ b/charts/mongodb/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.externalService.serviceType }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mongodb.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.externalService.serviceType }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mongodb.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mongodb.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.externalService.serviceType }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mongodb.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/mongodb/templates/_helpers.tpl b/charts/mongodb/templates/_helpers.tpl new file mode 100644 index 0000000..6b1b8c1 --- /dev/null +++ b/charts/mongodb/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "mongodb.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 "mongodb.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 "mongodb.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "mongodb.labels" -}} +helm.sh/chart: {{ include "mongodb.chart" . }} +{{ include "mongodb.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "mongodb.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mongodb.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "mongodb.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "mongodb.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/mongodb/templates/configmap.yaml b/charts/mongodb/templates/configmap.yaml new file mode 100644 index 0000000..a226a6f --- /dev/null +++ b/charts/mongodb/templates/configmap.yaml @@ -0,0 +1,16 @@ +{{- if .Values.mongoDBConfiguration }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-additional-config + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: database +data: + mongo.yaml: {{ .Values.mongoDBConfiguration | toYaml | indent 2 | trim }} +{{- end }} \ No newline at end of file diff --git a/charts/mongodb/templates/mongodb.yaml b/charts/mongodb/templates/mongodb.yaml new file mode 100644 index 0000000..b7bed01 --- /dev/null +++ b/charts/mongodb/templates/mongodb.yaml @@ -0,0 +1,62 @@ +--- +apiVersion: opstreelabs.in/v1alpha1 +kind: MongoDB +metadata: + name: {{ .Release.Name }} + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: database +spec: + kubernetesConfig: + image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" + securityContext: + fsGroup: 1001 + imagePullPolicy: {{ .Values.image.imagePullPolicy }} +{{- if .Values.image.pullSecret }} + imagePullSecret: {{ .Values.image.pullSecret }} +{{- end }} +{{- if .Values.nodeSelector }} + nodeSelector: + {{ toYaml .Values.nodeSelector | indent 6 }} +{{- end }} +{{- if .Values.priorityClassName }} + priorityClassName: "{{ .Values.priorityClassName }}" +{{- end }} +{{- if .Values.affinity }} + affinity: + {{ toYaml .Values.affinity | indent 6 }} +{{- end }} +{{- if .Values.tolerations }} + tolerations: + {{ toYaml .Values.tolerations | indent 6 }} +{{- end }} + resources: +{{ toYaml .Values.resources | indent 6 }} +{{- if .Values.storage.enabled }} + storage: + accessModes: {{ .Values.storage.accessModes }} + storageSize: {{ .Values.storage.storageSize }} +{{- if .Values.storage.storageClass }} + storageClass: {{ .Values.storage.storageClass }} +{{- end }} +{{- end }} + mongoDBSecurity: + mongoDBAdminUser: admin + secretRef: + name: {{ .Release.Name }}-secret + key: password +{{- if .Values.mongoDBConfiguration }} + mongoDBAdditionalConfig: {{ .Release.Name }}-additional-config +{{- end }} +{{- if .Values.mongoDBMonitoring.enabled }} + mongoDBMonitoring: + enableExporter: {{ .Values.mongoDBMonitoring.enabled }} + image: "{{ .Values.mongoDBMonitoring.image.name }}:{{ .Values.mongoDBMonitoring.image.tag }}" + imagePullPolicy: {{ .Values.mongoDBMonitoring.image.imagePullPolicy }} + resources: +{{ toYaml .Values.mongoDBMonitoring.resources | indent 6 }} +{{- end }} \ No newline at end of file diff --git a/charts/mongodb/templates/secret.yaml b/charts/mongodb/templates/secret.yaml new file mode 100644 index 0000000..fa54566 --- /dev/null +++ b/charts/mongodb/templates/secret.yaml @@ -0,0 +1,16 @@ +{{- if not (lookup "v1" "PersistentVolumeClaim" .Release.Namespace (print .Release.Name "-standalone-" .Release.Name "-standalone-0")) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-secret + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: database +type: Opaque +data: + password: {{ .Values.password | default (randAlphaNum 20) | b64enc }} +{{- end }} \ No newline at end of file diff --git a/charts/mongodb/templates/service.yaml b/charts/mongodb/templates/service.yaml new file mode 100644 index 0000000..d2a3673 --- /dev/null +++ b/charts/mongodb/templates/service.yaml @@ -0,0 +1,53 @@ +{{- if eq .Values.externalService.enabled true }} +--- +kind: Service +apiVersion: v1 +metadata: + name: {{ .Release.Name }}-headless +{{- if .Values.externalService.annotations }} + annotations: +{{ toYaml .Values.externalService.annotations | indent 4 }} +{{- end }} + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +spec: + clusterIP: None + selector: + app: {{ .Release.Name }}-standalone + mongodb_setup: standalone + role: standalone + ports: + - port: 27017 +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} +{{- if .Values.externalService.annotations }} + annotations: +{{ toYaml .Values.externalService.annotations | indent 4 }} +{{- end }} + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +spec: + type: {{ .Values.externalService.serviceType }} + selector: + app: {{ .Release.Name }}-standalone + mongodb_setup: standalone + role: standalone + ports: + - protocol: TCP + port: {{ .Values.externalService.port }} + targetPort: 27017 + name: client +{{- end }} \ No newline at end of file diff --git a/charts/mongodb/templates/servicemonitor.yaml b/charts/mongodb/templates/servicemonitor.yaml new file mode 100644 index 0000000..0d30023 --- /dev/null +++ b/charts/mongodb/templates/servicemonitor.yaml @@ -0,0 +1,27 @@ +{{- if eq .Values.serviceMonitor.enabled true }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ .Release.Name }}-prometheus-monitoring + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +spec: + selector: + matchLabels: + app: {{ .Release.Name }} + mongodb_setup: standalone + role: standalone + endpoints: + - port: metrics + interval: {{ .Values.serviceMonitor.interval }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + namespaceSelector: + matchNames: + - {{ .Values.serviceMonitor.namespace }} +{{- end }} \ No newline at end of file diff --git a/charts/mongodb/values.yaml b/charts/mongodb/values.yaml new file mode 100644 index 0000000..347a2b3 --- /dev/null +++ b/charts/mongodb/values.yaml @@ -0,0 +1,80 @@ +--- +image: + name: quay.io/opstree/mongo + tag: v5.0.6 + imagePullPolicy: IfNotPresent + # pullSecret: regcred + +nodeSelector: {} +# memory: high + +#priorityClassName: "-" + +#password: "" + +securityContext: + fsGroup: 1001 + +affinity: {} + # nodeAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # nodeSelectorTerms: + # - matchExpressions: + # - key: disktype + # operator: In + # values: +# - ssd + +resources: {} + # requests: + # cpu: 100m + # memory: 128Mi + # limits: + # cpu: 100m +# memory: 128Mi + +tolerations: [] +# - key: "example-key" +# operator: "Exists" +# effect: "NoSchedule" + +storage: + enabled: true + accessModes: ["ReadWriteOnce"] + storageSize: 1Gi + storageClass: + +mongoDBMonitoring: + enabled: false + image: + name: bitnami/mongodb-exporter + tag: 0.11.2-debian-10-r382 + imagePullPolicy: IfNotPresent + resources: {} + # requests: + # cpu: 100m + # memory: 128Mi + # limits: + # cpu: 100m + # memory: 128Mi + +mongoDBConfiguration: | + net: + bindIp: 0.0.0.0 + port: 27017 + +serviceMonitor: + enabled: false + interval: 30s + scrapeTimeout: 10s + namespace: monitoring + +externalService: + enabled: false + # annotations: + # foo: bar + serviceType: ClusterIP + port: 27017 + +ingress: + enabled: false diff --git a/charts/redis/.helmignore b/charts/redis/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/redis/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/redis/Chart.yaml b/charts/redis/Chart.yaml new file mode 100644 index 0000000..cfda4d5 --- /dev/null +++ b/charts/redis/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: redis +description: Redis standalone Helm chart for Kubernetes +type: application +version: 0.15.7 +appVersion: "0.15.0" diff --git a/charts/redis/templates/NOTES.txt b/charts/redis/templates/NOTES.txt new file mode 100644 index 0000000..6d9a7b5 --- /dev/null +++ b/charts/redis/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.externalService.serviceType }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "redis.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.externalService.serviceType }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "redis.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "redis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.externalService.serviceType }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "redis.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/redis/templates/_helpers.tpl b/charts/redis/templates/_helpers.tpl new file mode 100644 index 0000000..f6a718b --- /dev/null +++ b/charts/redis/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "redis.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 "redis.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 "redis.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "redis.labels" -}} +helm.sh/chart: {{ include "redis.chart" . }} +{{ include "redis.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "redis.selectorLabels" -}} +app.kubernetes.io/name: {{ include "redis.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "redis.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "redis.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/redis/templates/configmap.yaml b/charts/redis/templates/configmap.yaml new file mode 100644 index 0000000..4eab38c --- /dev/null +++ b/charts/redis/templates/configmap.yaml @@ -0,0 +1,17 @@ +{{- if eq .Values.externalConfig.enabled true }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-ext-config + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +data: + redis-additional.conf: | + {{ .Values.externalConfig.data | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/charts/redis/templates/redis.yaml b/charts/redis/templates/redis.yaml new file mode 100644 index 0000000..71261a4 --- /dev/null +++ b/charts/redis/templates/redis.yaml @@ -0,0 +1,83 @@ +--- +apiVersion: redis.redis.opstreelabs.in/v1beta1 +kind: Redis +metadata: + name: {{ .Release.Name }} + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +{{- if .Values.labels }} +{{- range $labelkey, $labelvalue := .Values.labels }} + {{ $labelkey}}: {{ $labelvalue }} +{{- end }} +{{- end }} +spec: +{{- if eq .Values.externalConfig.enabled true }} + redisConfig: + additionalRedisConfig: {{ .Release.Name }}-ext-config +{{- end }} + redisExporter: + enabled: {{ .Values.redisExporter.enabled }} + image: "{{ .Values.redisExporter.image }}:{{ .Values.redisExporter.tag }}" + imagePullPolicy: "{{ .Values.redisExporter.imagePullPolicy }}" + resources: +{{ toYaml .Values.redisExporter.resources | indent 6 }} +{{- if .Values.redisExporter.env }} + env: +{{ toYaml .Values.redisExporter.env | indent 4 }} +{{- end }} + kubernetesConfig: + image: "{{ .Values.redisStandalone.image }}:{{ .Values.redisStandalone.tag }}" + imagePullPolicy: "{{ .Values.redisStandalone.imagePullPolicy }}" + resources: +{{ toYaml .Values.redisStandalone.resources | indent 6 }} +{{- if .Values.redisStandalone.redisSecret }} + redisSecret: + name: "{{ .Values.redisStandalone.redisSecret.secretName }}" + key: "{{ .Values.redisStandalone.redisSecret.secretKey }}" +{{- end }} +{{- if .Values.imagePullSecrets }} + imagePullSecrets: +{{- range $imageSecrets := .Values.imagePullSecrets }} + - name: {{ $imageSecrets.name }} +{{- end }} +{{- end }} +{{- if .Values.storageSpec }} + storage: +{{ toYaml .Values.storageSpec | indent 4 }} +{{- end }} +{{- if .Values.priorityClassName }} + priorityClassName: "{{ .Values.priorityClassName }}" +{{- end }} +{{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 4 }} +{{- end }} +{{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 4 }} +{{- end }} +{{- if .Values.podSecurityContext }} + podSecurityContext: +{{ toYaml .Values.podSecurityContext | indent 4 }} + +{{- end }} +{{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 4 }} +{{- end }} +{{- if .Values.TLS }} + TLS: +{{ toYaml .Values.TLS | indent 4 }} +{{- end}} +{{- if .Values.sidecars }} + sidecars: +{{ toYaml .Values.sidecars | indent 4 }} +{{- end }} +{{- if .Values.serviceAccountName }} + serviceAccountName: "{{ .Values.serviceAccountName }}" +{{- end }} \ No newline at end of file diff --git a/charts/redis/templates/secret.yaml b/charts/redis/templates/secret.yaml new file mode 100644 index 0000000..99015b3 --- /dev/null +++ b/charts/redis/templates/secret.yaml @@ -0,0 +1,16 @@ +{{- if not (lookup "v1" "PersistentVolumeClaim" .Release.Namespace (print .Release.Name "-" .Release.Name "-0")) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-secret + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: database +type: Opaque +data: + password: {{ .Values.redisStandalone.password | default (randAlphaNum 20) | b64enc }} +{{- end }} \ No newline at end of file diff --git a/charts/redis/templates/service.yaml b/charts/redis/templates/service.yaml new file mode 100644 index 0000000..2a39d1e --- /dev/null +++ b/charts/redis/templates/service.yaml @@ -0,0 +1,29 @@ +{{- if eq .Values.externalService.enabled true }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-external-service +{{- if .Values.externalService.annotations }} + annotations: +{{ toYaml .Values.externalService.annotations | indent 4 }} +{{- end }} + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +spec: + type: {{ .Values.externalService.serviceType }} + selector: + app: {{ .Release.Name }} + redis_setup_type: standalone + role: standalone + ports: + - protocol: TCP + port: {{ .Values.externalService.port }} + targetPort: 6379 + name: client +{{- end }} \ No newline at end of file diff --git a/charts/redis/templates/servicemonitor.yaml b/charts/redis/templates/servicemonitor.yaml new file mode 100644 index 0000000..59abfd0 --- /dev/null +++ b/charts/redis/templates/servicemonitor.yaml @@ -0,0 +1,27 @@ +{{- if eq .Values.serviceMonitor.enabled true }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ .Release.Name }}-prometheus-monitoring + labels: + app.kubernetes.io/name: {{ .Release.Name }} + helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: middleware +spec: + selector: + matchLabels: + app: {{ .Release.Name }} + redis_setup_type: standalone + role: standalone + endpoints: + - port: redis-exporter + interval: {{ .Values.serviceMonitor.interval }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + namespaceSelector: + matchNames: + - {{ .Values.serviceMonitor.namespace }} + {{- end }} \ No newline at end of file diff --git a/charts/redis/values.yaml b/charts/redis/values.yaml new file mode 100644 index 0000000..b4d39be --- /dev/null +++ b/charts/redis/values.yaml @@ -0,0 +1,126 @@ +--- +redisStandalone: + image: quay.io/opstree/redis + tag: v7.0.5 + imagePullPolicy: IfNotPresent + # password: "" + # redisSecret: + # secretName: redis-secret + # secretKey: password + serviceType: ClusterIP + resources: {} + # requests: + # cpu: 100m + # memory: 128Mi + # limits: + # cpu: 100m + # memory: 128Mi + +# labels: +# foo: bar +# test: echo + +externalConfig: + enabled: false + data: | + tcp-keepalive 400 + slowlog-max-len 158 + stream-node-max-bytes 2048 + +externalService: + enabled: false + # annotations: + # foo: bar + serviceType: NodePort + port: 6379 + +serviceMonitor: + enabled: false + interval: 30s + scrapeTimeout: 10s + namespace: monitoring + +redisExporter: + enabled: false + image: quay.io/opstree/redis-exporter + tag: "v1.44.0" + imagePullPolicy: IfNotPresent + resources: {} + # requests: + # cpu: 100m + # memory: 128Mi + # limits: + # cpu: 100m + # memory: 128Mi + # env: + # - name: REDIS_EXPORTER_INCL_SYSTEM_METRICS + # value: "true" + # - name: UI_PROPERTIES_FILE_NAME + # valueFrom: + # configMapKeyRef: + # name: game-demo + # key: ui_properties_file_name + # - name: SECRET_USERNAME + # valueFrom: + # secretKeyRef: + # name: mysecret + # key: username + +sidecars: [] + # - name: "sidecar1" + # image: "image:1.0" + # imagePullPolicy: Always + # resources: + # limits: + # cpu: 50m + # memory: 64Mi + # requests: + # cpu: 10m + # memory: 32M + # env: + # - name: VAR_NAME +# value: "value1" + +# priorityClassName: "-" + +# imagePullSecrets: +# - name: regcred + +nodeSelector: {} +# memory: medium + +storageSpec: + volumeClaimTemplate: + spec: + # storageClassName: standard + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi + # selector: {} + +podSecurityContext: + runAsUser: 1000 + fsGroup: 1000 + +affinity: {} + # nodeAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # nodeSelectorTerms: + # - matchExpressions: + # - key: disktype + # operator: In + # values: +# - ssd + +# serviceAccountName: redis-sa + +# TLS: +# ca: ca.key +# cert: tls.crt +# key: tls.key +# secret: +# secretName: redis-tls-cert + +ingress: + enabled: false \ No newline at end of file