diff --git a/crud/.cartridge.yml b/crud-storage/.cartridge.yml similarity index 100% rename from crud/.cartridge.yml rename to crud-storage/.cartridge.yml diff --git a/crud/.editorconfig b/crud-storage/.editorconfig similarity index 100% rename from crud/.editorconfig rename to crud-storage/.editorconfig diff --git a/crud/.gitignore b/crud-storage/.gitignore similarity index 100% rename from crud/.gitignore rename to crud-storage/.gitignore diff --git a/crud/.luacheckrc b/crud-storage/.luacheckrc similarity index 100% rename from crud/.luacheckrc rename to crud-storage/.luacheckrc diff --git a/crud/.luacov b/crud-storage/.luacov similarity index 100% rename from crud/.luacov rename to crud-storage/.luacov diff --git a/crud/Dockerfile.build.cartridge b/crud-storage/Dockerfile.build.cartridge similarity index 100% rename from crud/Dockerfile.build.cartridge rename to crud-storage/Dockerfile.build.cartridge diff --git a/crud/Dockerfile.cartridge b/crud-storage/Dockerfile.cartridge similarity index 100% rename from crud/Dockerfile.cartridge rename to crud-storage/Dockerfile.cartridge diff --git a/crud/cartridge.post-build b/crud-storage/cartridge.post-build similarity index 100% rename from crud/cartridge.post-build rename to crud-storage/cartridge.post-build diff --git a/crud/cartridge.pre-build b/crud-storage/cartridge.pre-build similarity index 100% rename from crud/cartridge.pre-build rename to crud-storage/cartridge.pre-build diff --git a/crud/crud-scm-1.rockspec b/crud-storage/crud-storage-scm-1.rockspec similarity index 91% rename from crud/crud-scm-1.rockspec rename to crud-storage/crud-storage-scm-1.rockspec index a759c4a..ba40656 100644 --- a/crud/crud-scm-1.rockspec +++ b/crud-storage/crud-storage-scm-1.rockspec @@ -1,4 +1,4 @@ -package = 'crud' +package = 'crud-storage' version = 'scm-1' source = { url = '/dev/null', diff --git a/crud/deps.sh b/crud-storage/deps.sh similarity index 100% rename from crud/deps.sh rename to crud-storage/deps.sh diff --git a/crud-storage/helm-chart/Chart.yaml b/crud-storage/helm-chart/Chart.yaml new file mode 100644 index 0000000..ffa350a --- /dev/null +++ b/crud-storage/helm-chart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Tarantool CRUD +name: crud-storage +version: 0.0.1 diff --git a/crud-storage/helm-chart/templates/_helpers.tpl b/crud-storage/helm-chart/templates/_helpers.tpl new file mode 100644 index 0000000..e79ca1f --- /dev/null +++ b/crud-storage/helm-chart/templates/_helpers.tpl @@ -0,0 +1,45 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "tarantool.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 "tarantool.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 "tarantool.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "tarantool.labels" -}} +app.kubernetes.io/name: {{ include "tarantool.name" . }} +helm.sh/chart: {{ include "tarantool.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} diff --git a/crud-storage/helm-chart/templates/deployment.yaml b/crud-storage/helm-chart/templates/deployment.yaml new file mode 100644 index 0000000..6c646fa --- /dev/null +++ b/crud-storage/helm-chart/templates/deployment.yaml @@ -0,0 +1,149 @@ +apiVersion: tarantool.io/v1alpha1 +kind: Cluster +metadata: + name: {{ .Values.ClusterName }} + namespace: {{ .Values.namespace }} +spec: + selector: + matchLabels: + tarantool.io/cluster-id: {{ .Values.ClusterName }} +--- +{{- range .Values.RoleConfig }} +{{- $r := .RolesToAssign | toJson | quote }} +apiVersion: tarantool.io/v1alpha1 +kind: Role +metadata: + name: {{ .RoleName | replace "_" "" }} + namespace: {{ $.Values.namespace }} + labels: + tarantool.io/cluster-id: {{ $.Values.ClusterName }} + tarantool.io/role: {{ .RoleName }} + annotations: + tarantool.io/rolesToAssign: {{ $r }} +spec: + selector: + matchLabels: + tarantool.io/replicaset-template: "{{ .RoleName }}-template" + numReplicasets: {{ .ReplicaSetCount }} +--- +apiVersion: tarantool.io/v1alpha1 +kind: ReplicasetTemplate +metadata: + name: "{{ .RoleName | replace "_" "" }}-template" + namespace: {{ $.Values.namespace }} + labels: + tarantool.io/cluster-id: {{ $.Values.ClusterName }} + tarantool.io/replicaset-template: "{{ .RoleName }}-template" + tarantool.io/role: {{ .RoleName }} + tarantool.io/useVshardGroups: "0" + annotations: + tarantool.io/rolesToAssign: {{ $r }} +spec: + replicas: {{ .ReplicaCount }} + serviceName: {{ .RoleName }} + selector: + matchLabels: + tarantool.io/pod-template: "{{ .RoleName }}-pod-template" + volumeClaimTemplates: + - metadata: + name: www + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: {{ .DiskSize }} + template: + metadata: + labels: + tarantool.io/cluster-id: {{ $.Values.ClusterName }} + tarantool.io/pod-template: "{{ .RoleName }}-pod-template" + tarantool.io/useVshardGroups: "0" + environment: "{{ $.Values.ClusterEnv }}" + annotations: + tarantool.io/rolesToAssign: {{ $r }} + prometheus.io/path: "{{ $.Values.Prometheus.path }}" + prometheus.io/port: "{{ $.Values.Prometheus.port}}" + prometheus.io/scrape: "true" + spec: + terminationGracePeriodSeconds: 10 + dnsConfig: + options: + - name: ndots + value: "1" + updateStrategy: + type: OnDelete + securityContext: + fsGroup: 1000 + capabilities: + add: ["SYS_ADMIN"] + containers: + - name: pim-storage + image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}" + volumeMounts: + - name: www + mountPath: "/data" + resources: + requests: + cpu: "{{ .CPUallocation }}" + memory: "{{ .MemtxMemoryMB }}M" + limits: + cpu: "{{ .CPUallocation }}" + memory: "{{ .MemtxMemoryMB }}M" + ports: + - containerPort: 3301 + protocol: TCP + name: app + - containerPort: 3301 + protocol: UDP + name: app-udp + - containerPort: 8081 + protocol: TCP + name: http + env: + - name: ENVIRONMENT + value: "{{ $.Values.ClusterEnv }}" + - name: TARANTOOL_INSTANCE_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: TARANTOOL_MEMTX_MEMORY + value: "{{ mul .MemtxMemoryMB 1048576 }}" + - name: TARANTOOL_BUCKET_COUNT + value: "30000" + - name: TARANTOOL_ADVERTISE_TMP + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: TARANTOOL_ADVERTISE_HOST + value: "$(TARANTOOL_ADVERTISE_TMP).{{ $.Values.ClusterName }}.{{ $.Values.namespace }}.svc.cluster.local" + - name: TARANTOOL_ADVERTISE_URI + value: "$(TARANTOOL_ADVERTISE_HOST):3301" + - name: TARANTOOL_PROBE_URI_TIMEOUT + value: "60" + - name: TARANTOOL_HTTP_PORT + value: "8081" + readinessProbe: + tcpSocket: + port: http + initialDelaySeconds: 15 + periodSeconds: 10 +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .RoleName }} + namespace: {{ $.Values.namespace }} + labels: + tarantool.io/role: {{ .RoleName }} +spec: + ports: + - port: 8081 + name: web + protocol: TCP + - port: 3301 + name: app + protocol: TCP + selector: + tarantool.io/role: {{ .RoleName }} +--- +{{- end }} diff --git a/crud-storage/helm-chart/templates/tests/test-connection.yaml b/crud-storage/helm-chart/templates/tests/test-connection.yaml new file mode 100644 index 0000000..1e552c6 --- /dev/null +++ b/crud-storage/helm-chart/templates/tests/test-connection.yaml @@ -0,0 +1,18 @@ +--- +{{- range .Values.RoleConfig }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{.RoleName}}-test-connection" + annotations: + helm.sh/hook: test-success + helm.sh/hook-delete-policy: hook-succeeded +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ["{{.RoleName}}:{{ $.Values.service.port }}"] + restartPolicy: Never +--- +{{- end }} diff --git a/crud-storage/helm-chart/values.yaml b/crud-storage/helm-chart/values.yaml new file mode 100644 index 0000000..2c17ce6 --- /dev/null +++ b/crud-storage/helm-chart/values.yaml @@ -0,0 +1,31 @@ +# Declare variables to be passed into your templates. + +ClusterEnv: dev +ClusterName: tarantool-crud + +namespace: tarantool + +image: + repository: vasiliyt/tarantool-crud + tag: 0.0.2 + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 8081 + +Prometheus: + port: 8081 + path: /metrics + +RoleConfig: + - RoleName: storage + ReplicaCount: 1 + ReplicaSetCount: 3 + DiskSize: 1Gi + CPUallocation: 0.25 + MemtxMemoryMB: 256 + RolesToAssign: + - crud-storage + - vshard-router + - metrics diff --git a/crud/init.lua b/crud-storage/init.lua similarity index 100% rename from crud/init.lua rename to crud-storage/init.lua diff --git a/crud/instances.yml b/crud-storage/instances.yml similarity index 100% rename from crud/instances.yml rename to crud-storage/instances.yml diff --git a/crud/stateboard.init.lua b/crud-storage/stateboard.init.lua similarity index 100% rename from crud/stateboard.init.lua rename to crud-storage/stateboard.init.lua diff --git a/crud/test/helper.lua b/crud-storage/test/helper.lua similarity index 100% rename from crud/test/helper.lua rename to crud-storage/test/helper.lua diff --git a/crud/test/helper/integration.lua b/crud-storage/test/helper/integration.lua similarity index 100% rename from crud/test/helper/integration.lua rename to crud-storage/test/helper/integration.lua diff --git a/crud/test/helper/unit.lua b/crud-storage/test/helper/unit.lua similarity index 100% rename from crud/test/helper/unit.lua rename to crud-storage/test/helper/unit.lua diff --git a/crud/test/integration/api_test.lua b/crud-storage/test/integration/api_test.lua similarity index 100% rename from crud/test/integration/api_test.lua rename to crud-storage/test/integration/api_test.lua diff --git a/crud/test/unit/sample_test.lua b/crud-storage/test/unit/sample_test.lua similarity index 100% rename from crud/test/unit/sample_test.lua rename to crud-storage/test/unit/sample_test.lua diff --git a/crud/values.yaml b/crud-storage/values.yaml similarity index 100% rename from crud/values.yaml rename to crud-storage/values.yaml