Skip to content

Commit

Permalink
Merge pull request #223 from tonytheleg/RHCLOUD-35930-add-db-cleaner
Browse files Browse the repository at this point in the history
adds db-cleaner deploy files for db operation needs
  • Loading branch information
tonytheleg authored Nov 7, 2024
2 parents 924cd82 + bf913be commit d59a52f
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 0 deletions.
91 changes: 91 additions & 0 deletions deploy/kessel-inventory-db-operations.yaml
Original file line number Diff line number Diff line change
@@ -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"
115 changes: 115 additions & 0 deletions deploy/kessel-inventory-ephem-db-operations.yaml
Original file line number Diff line number Diff line change
@@ -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: "[email protected]"
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"

0 comments on commit d59a52f

Please sign in to comment.