diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..5fe08ec --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: negar +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/templates/configmap.yml b/templates/configmap.yml new file mode 100644 index 0000000..9df86d1 --- /dev/null +++ b/templates/configmap.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: db-configs + labels: + app: postgres +data: + POSTGRES_DB: "postgres" + POSTGRES_USER: "postgres" + POSTGRES_PASSWORD: "postgres" + HOST: "postgres" + PORT: "{{ .Values.postgres.port }}" + POSTGRES_CONNECTION_STRING: "Host=postgres;Database=postgres;Username=postgres;Password=postgres;" diff --git a/templates/deployment-backend.yml b/templates/deployment-backend.yml new file mode 100644 index 0000000..a84a2a5 --- /dev/null +++ b/templates/deployment-backend.yml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend +spec: + replicas: {{ .Values.backend.replicaCount }} + selector: + matchLabels: + app: backend + template: + metadata: + labels: + app: backend + spec: + imagePullSecrets: + - name: {{ .Values.abrimentImagePullSecret.name }} + initContainers: + - name: migrate + image: {{ .Values.backend.repository }}:{{ .Values.backend.tag }} + imagePullPolicy: {{ .Values.backend.pullPolicy }} + env: + - name: CONNECTION_STRING + valueFrom: + configMapKeyRef: + name: db-configs + key: POSTGRES_CONNECTION_STRING + command: ["dotnet", "./RelationAnalysis.Migrations.dll"] + ports: + - containerPort: {{ .Values.backend.port }} + resources: + requests: + memory: {{ .Values.backend.resources.requests.memory }} + cpu: {{ .Values.backend.resources.requests.cpu }} + limits: + memory: {{ .Values.backend.resources.limits.memory }} + cpu: {{ .Values.backend.resources.limits.cpu }} + containers: + - name: backend + image: {{ .Values.backend.repository }}:{{ .Values.backend.tag }} + imagePullPolicy: {{ .Values.backend.pullPolicy }} + env: + - name: CONNECTION_STRING + valueFrom: + configMapKeyRef: + name: db-configs + key: POSTGRES_CONNECTION_STRING + ports: + - containerPort: {{ .Values.backend.port }} + resources: + requests: + memory: {{ .Values.backend.resources.requests.memory }} + cpu: {{ .Values.backend.resources.requests.cpu }} + limits: + memory: {{ .Values.backend.resources.limits.memory }} + cpu: {{ .Values.backend.resources.limits.cpu }} diff --git a/templates/deployment-frontend.yml b/templates/deployment-frontend.yml new file mode 100644 index 0000000..b5a095a --- /dev/null +++ b/templates/deployment-frontend.yml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend +spec: + replicas: {{ .Values.frontend.replicaCount }} + selector: + matchLabels: + app: frontend + template: + metadata: + labels: + app: frontend + spec: + imagePullSecrets: + - name: {{ .Values.abrimentImagePullSecret.name }} + containers: + - name: frontend + image: {{ .Values.frontend.repository }}:{{ .Values.frontend.tag }} + imagePullPolicy: {{ .Values.frontend.pullPolicy }} + ports: + - containerPort: {{ .Values.frontend.port }} + resources: + requests: + memory: {{ .Values.frontend.resources.requests.memory }} + cpu: {{ .Values.frontend.resources.requests.cpu }} + limits: + memory: {{ .Values.frontend.resources.limits.memory }} + cpu: {{ .Values.frontend.resources.limits.cpu }} diff --git a/templates/deployment-postgres.yml b/templates/deployment-postgres.yml new file mode 100644 index 0000000..105e37d --- /dev/null +++ b/templates/deployment-postgres.yml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres +spec: + replicas: {{ .Values.postgres.replicaCount }} + selector: + matchLabels: + app: postgres + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: {{ .Values.postgres.repository }}:{{ .Values.postgres.tag }} + imagePullPolicy: {{ .Values.postgres.pullPolicy }} + ports: + - containerPort: {{ .Values.postgres.port }} + env: + - name: POSTGRES_USER + valueFrom: + configMapKeyRef: + name: db-configs + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + configMapKeyRef: + name: db-configs + key: POSTGRES_PASSWORD + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: db-configs + key: POSTGRES_DB + - name: HOST + valueFrom: + configMapKeyRef: + name: db-configs + key: HOST + - name: PORT + valueFrom: + configMapKeyRef: + name: db-configs + key: PORT + volumeMounts: + - mountPath: /var/lib/postgres/data + name: db-data + resources: + requests: + memory: {{ .Values.postgres.resources.requests.memory }} + cpu: {{ .Values.postgres.resources.requests.cpu }} + limits: + memory: {{ .Values.postgres.resources.limits.memory }} + cpu: {{ .Values.postgres.resources.limits.cpu }} + volumes: + - name: db-data + persistentVolumeClaim: + claimName: db-persistent-pvc diff --git a/templates/ingress.yml b/templates/ingress.yml new file mode 100644 index 0000000..d50bd4a --- /dev/null +++ b/templates/ingress.yml @@ -0,0 +1,27 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: my-ingress + namespace: 0b12e0d24d4541c097bbaab164438125-negar + labels: + app: nginxn +spec: + ingressClassName: my-ingress + rules: + - host: noice.abriment.com + http: + paths: + - path: /api + pathType: Prefix + backend: + service: + name: back-service + port: + number: {{ .Values.backend.service.port }} + - path: / + pathType: Prefix + backend: + service: + name: front-service + port: + number: {{ .Values.frontend.service.port }} diff --git a/templates/pvc.yml b/templates/pvc.yml new file mode 100644 index 0000000..8b69ae5 --- /dev/null +++ b/templates/pvc.yml @@ -0,0 +1,10 @@ +#apiVersion: v1 +#kind: PersistentVolumeClaim +#metadata: +# name: db-persistent-pvc +#spec: +# accessModes: +# - ReadWriteOnce +# resources: +# requests: +# storage: {{ .Values.postgres.pvc.storage }} diff --git a/templates/service-backend.yml b/templates/service-backend.yml new file mode 100644 index 0000000..9d17ac9 --- /dev/null +++ b/templates/service-backend.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: back-service +spec: + type: {{ .Values.backend.service.type }} + selector: + app: backend + ports: + - port: {{ .Values.backend.port }} + targetPort: {{ .Values.backend.service.port }} diff --git a/templates/service-frontend.yml b/templates/service-frontend.yml new file mode 100644 index 0000000..2dc9148 --- /dev/null +++ b/templates/service-frontend.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: front-service +spec: + type: {{ .Values.frontend.service.type }} + selector: + app: frontend + ports: + - port: {{ .Values.frontend.service.port }} + targetPort: {{ .Values.frontend.port }} diff --git a/templates/service-postgres.yml b/templates/service-postgres.yml new file mode 100644 index 0000000..03dd891 --- /dev/null +++ b/templates/service-postgres.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres +spec: + type: {{ .Values.postgres.service.type }} + ports: + - port: {{ .Values.postgres.port }} + targetPort: {{ .Values.postgres.service.port }} + selector: + app: postgres diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..1f18644 --- /dev/null +++ b/values.yaml @@ -0,0 +1,68 @@ +backend: + #repository: registry.abriment.com/mhch/negar-backend + repository: docker.arvancloud.ir/mhchah/imagebuilder + #repository: negar-backend + pullPolicy: IfNotPresent + #pullPolicy: Always + tag: v0.0.3 + replicaCount: 1 + port: 80 + + service: + type: ClusterIP + port: 80 + + resources: + requests: + memory: "3000Mi" + cpu: "2000m" + limits: + memory: "3000Mi" + cpu: "2000m" + +postgres: + repository: postgres + tag: "16.3" + pullPolicy: IfNotPresent + replicaCount: 1 + port: 5432 + + service: + type: ClusterIP + port: 5432 + + resources: + requests: + memory: "3000Mi" + cpu: "2000m" + limits: + memory: "3000Mi" + cpu: "2000m" + pvc: + storage: "3Gi" + +frontend: + # repository: docker.arvancloud.ir/mhchah/negar-frontend + #repository: negar-frontend + repository: docker.arvancloud.ir/mhchah/imagebuilder + pullPolicy: IfNotPresent + # tag: v0.11.3 + tag: v0.0.8 + replicaCount: 1 + port: 80 + + service: + type: ClusterIP + port: 80 + + resources: + requests: + memory: "3000Mi" + cpu: "2000m" + limits: + memory: "3000Mi" + cpu: "2000m" + +abrimentImagePullSecret: + name: negar-abrsecret +