diff --git a/apps/contracts/base/deployment.yaml b/apps/contracts/base/deployment.yaml new file mode 100644 index 0000000..6c1d0cb --- /dev/null +++ b/apps/contracts/base/deployment.yaml @@ -0,0 +1,41 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend + namespace: contracts + labels: + app: backend +spec: + replicas: 1 + selector: + matchLabels: + app: backend + template: + metadata: + labels: + app: backend + spec: + containers: + - name: backend + image: cr.yandex/crp3ccidau046kdj8g9q/contracts:prod_d3bbd9fc + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8000 + protocol: TCP + env: + - name: ENABLE_SSL + value: "false" + - name: DB_URL + valueFrom: + secretKeyRef: + name: postgresql-secrets + key: db_url + - name: PUBLIC_KEY + valueFrom: + secretKeyRef: + name: auth-public-key + key: public_key + imagePullSecrets: + - name: regcred diff --git a/apps/contracts/base/kustomization.yaml b/apps/contracts/base/kustomization.yaml new file mode 100644 index 0000000..ec7df6a --- /dev/null +++ b/apps/contracts/base/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: contracts +resources: + - namespace.yaml +# - deployment.yaml + - service.yaml diff --git a/apps/contracts/base/namespace.yaml b/apps/contracts/base/namespace.yaml new file mode 100644 index 0000000..816bf00 --- /dev/null +++ b/apps/contracts/base/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: contracts + labels: + istio-injection: enabled diff --git a/apps/contracts/base/service.yaml b/apps/contracts/base/service.yaml new file mode 100644 index 0000000..d378151 --- /dev/null +++ b/apps/contracts/base/service.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: backend-service + namespace: contracts +spec: + type: ClusterIP + selector: + app: backend + ports: + - name: http + port: 8000 + targetPort: 8000 + protocol: TCP diff --git a/apps/contracts/yc-k8s-test/kustomization.yaml b/apps/contracts/yc-k8s-test/kustomization.yaml new file mode 100644 index 0000000..da21a4e --- /dev/null +++ b/apps/contracts/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 diff --git a/apps/contracts/yc-k8s-test/postgresql.yaml b/apps/contracts/yc-k8s-test/postgresql.yaml new file mode 100644 index 0000000..3ef1876 --- /dev/null +++ b/apps/contracts/yc-k8s-test/postgresql.yaml @@ -0,0 +1,110 @@ +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: postgresql + namespace: contracts +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" + databases: + - name: contracts_db + user: contracts + extensions: [] + restoreFromDump: false + s3-proxy: + endpointUrl: "s3-proxy-service.postgresql.svc.cluster.local" diff --git a/apps/contracts/yc-k8s-test/replicas.yaml b/apps/contracts/yc-k8s-test/replicas.yaml new file mode 100644 index 0000000..5e678e5 --- /dev/null +++ b/apps/contracts/yc-k8s-test/replicas.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend +spec: + replicas: 1 diff --git a/clusters/yc-k8s-test/kustomization.yaml b/clusters/yc-k8s-test/kustomization.yaml index abd5f52..109318e 100644 --- a/clusters/yc-k8s-test/kustomization.yaml +++ b/clusters/yc-k8s-test/kustomization.yaml @@ -14,4 +14,5 @@ resources: - ../../apps/attachments/yc-k8s-test - ../../apps/measurements/yc-k8s-test - ../../apps/drawings/yc-k8s-test - - ../../apps/comparisons/yc-k8s-test \ No newline at end of file + - ../../apps/comparisons/yc-k8s-test + - ../../apps/contracts/yc-k8s-test \ No newline at end of file