diff --git a/apps/drawings/base/deployment.yaml b/apps/drawings/base/deployment.yaml new file mode 100644 index 0000000..a2f376f --- /dev/null +++ b/apps/drawings/base/deployment.yaml @@ -0,0 +1,55 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend + namespace: drawings + labels: + app: backend +spec: + replicas: 1 + selector: + matchLabels: + app: backend + template: + metadata: + labels: + app: backend + spec: + containers: + - name: backend + image: cr.yandex/crp3ccidau046kdj8g9q/drawings-api:015e68e1b2a3dcc13f0b405e1f761b154a825d24 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + - name: POSTGRES_POOL_SIZE + value: "3" + - name: API_ADDRESS + value: 0.0.0.0:8000 + - name: ENABLE_SSL + value: "0" + - name: POSTGRES_ADDRESS + valueFrom: + secretKeyRef: + name: postgresql-secrets + key: hostname + - name: POSTGRES_DB + valueFrom: + secretKeyRef: + name: postgresql-secrets + key: database + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: postgresql-secrets + key: username + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: postgresql-secrets + key: password + imagePullSecrets: + - name: regcred diff --git a/apps/drawings/base/kustomization.yaml b/apps/drawings/base/kustomization.yaml new file mode 100644 index 0000000..49b3cd3 --- /dev/null +++ b/apps/drawings/base/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: drawings +resources: + - namespace.yaml + - deployment.yaml + - service.yaml diff --git a/apps/drawings/base/namespace.yaml b/apps/drawings/base/namespace.yaml new file mode 100644 index 0000000..5d80da8 --- /dev/null +++ b/apps/drawings/base/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: drawings + labels: + istio-injection: enabled diff --git a/apps/drawings/base/service.yaml b/apps/drawings/base/service.yaml new file mode 100644 index 0000000..c40903e --- /dev/null +++ b/apps/drawings/base/service.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: backend-service + namespace: drawings +spec: + type: ClusterIP + selector: + app: backend + ports: + - name: http + port: 8000 + targetPort: 8000 + protocol: TCP diff --git a/apps/drawings/yc-k8s-test/kustomization.yaml b/apps/drawings/yc-k8s-test/kustomization.yaml new file mode 100644 index 0000000..d90fb04 --- /dev/null +++ b/apps/drawings/yc-k8s-test/kustomization.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base + - postgresql.yaml +patches: + - path: replicas.yaml + target: + kind: Deployment + name: backend \ No newline at end of file diff --git a/apps/drawings/yc-k8s-test/postgresql.yaml b/apps/drawings/yc-k8s-test/postgresql.yaml new file mode 100644 index 0000000..7fbaace --- /dev/null +++ b/apps/drawings/yc-k8s-test/postgresql.yaml @@ -0,0 +1,110 @@ +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: postgresql + namespace: drawings +spec: + interval: 5m + timeout: 2h + chart: + spec: + chart: postgresql-contour + version: "17.0.2" + sourceRef: + kind: HelmRepository + name: yc-oci-charts + namespace: flux-system + + install: + timeout: 2h + remediation: + retries: 3 + + upgrade: + timeout: 2h + remediation: + retries: 3 + + values: + global: + security: + allowInsecureImages: true + defaultStorageClass: local-path + postgresql: + auth: + username: "" + database: "" + secretKeys: + userPasswordKey: "postgres-password" + auth: + username: "" + database: "" + secretKeys: + userPasswordKey: "postgres-password" + image: + registry: cr.yandex/crp3ccidau046kdj8g9q + repository: contour/postgresql + tag: 17.0.2 + pullPolicy: Always + metrics: + enabled: false + prometheusRule: + enabled: false + primary: + containerSecurityContext: + readOnlyRootFilesystem: false + persistence: + storageClass: local-path + size: 20Gi + customLivenessProbe: + exec: + command: + - /bin/sh + - -c + - exec pg_isready -U "sarex" -d postgres -h 127.0.0.1 -p 5432 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 6 + customReadinessProbe: + exec: + command: + - /bin/sh + - -c + - exec pg_isready -U "sarex" -d postgres -h 127.0.0.1 -p 5432 + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 6 + customStartupProbe: + exec: + command: + - /bin/sh + - -c + - exec pg_isready -U "sarex" -d postgres -h 127.0.0.1 -p 5432 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 6 + nodeSelector: + dedicated: db + tolerations: + - key: dedicated + operator: Equal + value: db + effect: NoSchedule + contour: + enabled: true + adminUser: "" + adminPasswordSecretKey: "" + sharedPreloadLibraries: "pg_stat_statements,uuid-ossp" + databases: + - name: drawings_db + user: drawings + extensions: [] + restoreFromDump: false + s3-proxy: + endpointUrl: "s3-proxy-service.postgresql.svc.cluster.local" \ No newline at end of file diff --git a/apps/drawings/yc-k8s-test/replicas.yaml b/apps/drawings/yc-k8s-test/replicas.yaml new file mode 100644 index 0000000..d9db022 --- /dev/null +++ b/apps/drawings/yc-k8s-test/replicas.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend + namespace: drawings +spec: + replicas: 1 diff --git a/clusters/yc-k8s-test/kustomization.yaml b/clusters/yc-k8s-test/kustomization.yaml index 833bd1a..d823a5d 100644 --- a/clusters/yc-k8s-test/kustomization.yaml +++ b/clusters/yc-k8s-test/kustomization.yaml @@ -12,4 +12,5 @@ resources: - ../../apps/cross-section/yc-k8s-test - ../../apps/mapper/yc-k8s-test - ../../apps/attachments/yc-k8s-test - - ../../apps/measurements/yc-k8s-test \ No newline at end of file + - ../../apps/measurements/yc-k8s-test + - ../../apps/drawings/yc-k8s-test \ No newline at end of file