diff --git a/deploy/kessel-inventory-db-operations.yaml b/deploy/kessel-inventory-db-operations.yaml new file mode 100644 index 00000000..8b9c1ffb --- /dev/null +++ b/deploy/kessel-inventory-db-operations.yaml @@ -0,0 +1,91 @@ +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: inventory +objects: + - apiVersion: cloud.redhat.com/v1alpha1 + kind: ClowdApp + metadata: + name: kessel-inventory + spec: + envName: ${ENV_NAME} + database: + name: kessel-inventory + optionalDependencies: + - kessel-relations + deployments: + - name: api + replicas: ${{REPLICAS}} + podSpec: + initContainers: + - name: db-operations + image: registry.redhat.io/rhel9/postgresql-15:1-54 + command: ["/bin/sh", "-c"] + args: + - cd /tmp && curl -OL https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64 && mv jq-linux-amd64 jq && chmod +x jq; + export PGHOST=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.hostname'); + export PGPORT=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.port'); + export PGUSER=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.username'); + export PGDATABASE=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.name'); + export PGPASSWORD=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.password'); + for i in local_inventory_to_resources relationship_history relationships resource_history resources; + do psql -c "DROP TABLE $i"; + done; + inheritEnv: true + - name: migration + image: ${INVENTORY_IMAGE}:${IMAGE_TAG} + command: ["inventory-api"] + args: ["migrate"] + inheritEnv: true + image: ${INVENTORY_IMAGE}:${IMAGE_TAG} + command: ["inventory-api"] + args: ["serve"] + livenessProbe: + httpGet: + path: /api/inventory/v1/livez + port: 8000 + readinessProbe: + httpGet: + path: /api/inventory/v1/readyz + port: 8000 + env: + - name: CLOWDER_ENABLED + value: "true" + - name: INVENTORY_API_CONFIG + value: "/inventory/inventory-api-config.yaml" + - name: PGDATA + value: /temp/data + volumeMounts: + - name: config-volume + mountPath: "/inventory" + volumes: + - name: config-volume + secret: + secretName: inventory-api-config + webServices: + public: + enabled: true + apiPath: inventory + - kind: PodDisruptionBudget + apiVersion: policy/v1 + metadata: + name: kessel-inventory-api-pdb + spec: + minAvailable: 1 + selector: + matchLabels: + app: kessel-inventory +parameters: + - description: ClowdEnvironment name (ephemeral, stage, prod) + name: ENV_NAME + required: true + - description: App Image + name: INVENTORY_IMAGE + value: quay.io/redhat-services-prod/project-kessel-tenant/kessel-inventory/inventory-api + - description: Image Tag + name: IMAGE_TAG + required: true + value: latest + - description: Number of replicas + name: REPLICAS + value: "1" diff --git a/deploy/kessel-inventory-ephem-db-operations.yaml b/deploy/kessel-inventory-ephem-db-operations.yaml new file mode 100644 index 00000000..a3a0e1b6 --- /dev/null +++ b/deploy/kessel-inventory-ephem-db-operations.yaml @@ -0,0 +1,115 @@ +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: inventory +objects: + - apiVersion: v1 + kind: ConfigMap + metadata: + name: inventory-api-config + data: + inventory-api-config.yaml: | + authn: + psk: + pre-shared-key-file: /psks/psks.yaml + authz: + kessel: + insecure-client: true + enable-oidc-auth: false + log: + level: "info" + + - apiVersion: v1 + kind: ConfigMap + metadata: + name: psks + data: + psks.yaml: | + "1234": + tenant: "Example" + principal: "user@example.com" + is_reporter: true + type: "REPORTER_TYPE_ACM" + + - apiVersion: cloud.redhat.com/v1alpha1 + kind: ClowdApp + metadata: + name: kessel-inventory + spec: + envName: ${ENV_NAME} + database: + name: kessel-inventory + optionalDependencies: + - kessel-relations + deployments: + - name: api + replicas: ${{REPLICAS}} + podSpec: + initContainers: + - name: db-operations + image: registry.redhat.io/rhel9/postgresql-15:1-54 + command: ["/bin/sh", "-c"] + args: + - cd /tmp && curl -OL https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64 && mv jq-linux-amd64 jq && chmod +x jq; + export PGHOST=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.hostname'); + export PGPORT=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.port'); + export PGUSER=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.username'); + export PGDATABASE=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.name'); + export PGPASSWORD=$(cat /cdapp/cdappconfig.json | ./jq -r '.database.password'); + for i in local_inventory_to_resources relationship_history relationships resource_history resources; + do psql -c "DROP TABLE $i"; + done; + inheritEnv: true + - name: migration + image: ${INVENTORY_IMAGE}:${IMAGE_TAG} + command: ["inventory-api"] + args: ["migrate"] + inheritEnv: true + image: ${INVENTORY_IMAGE}:${IMAGE_TAG} + command: ["inventory-api"] + args: ["serve"] + livenessProbe: + httpGet: + path: /api/inventory/v1/livez + port: 8000 + readinessProbe: + httpGet: + path: /api/inventory/v1/readyz + port: 8000 + env: + - name: CLOWDER_ENABLED + value: "true" + - name: INVENTORY_API_CONFIG + value: "/inventory/inventory-api-config.yaml" + - name: PGDATA + value: /temp/data + volumeMounts: + - name: config-volume + mountPath: "/inventory" + - name: psks-volume + mountPath: /psks + volumes: + - name: config-volume + configMap: + name: inventory-api-config + - name: psks-volume + configMap: + name: psks + webServices: + public: + enabled: true + apiPath: inventory +parameters: + - description: ClowdEnvironment name (ephemeral, stage, prod) + name: ENV_NAME + required: true + - description: App Image + name: INVENTORY_IMAGE + value: quay.io/redhat-services-prod/project-kessel-tenant/kessel-inventory/inventory-api + - description: Image Tag + name: IMAGE_TAG + required: true + value: latest + - description: Number of replicas + name: REPLICAS + value: "1"