Skip to content

Commit

Permalink
RHINENG-13972 pcp generator server setup
Browse files Browse the repository at this point in the history
  • Loading branch information
r14chandra committed Nov 26, 2024
1 parent 28785f5 commit d97a34d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 332 deletions.
287 changes: 8 additions & 279 deletions clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,21 @@
apiVersion: v1
kind: Template
metadata:
name: ros-backend
name: ros-backend-pcp-zeroconf
objects:
- apiVersion: cloud.redhat.com/v1alpha1
kind: ClowdApp
metadata:
name: ros-backend
name: ros-backend-pcp-zeroconf
spec:
envName: ${ENV_NAME}
featureFlags: true
dependencies:
- host-inventory
- rbac
- engine
deployments:
- name: api
replicas: ${{API_REPLICA_COUNT}}
webServices:
public:
enabled: true
apiPath: ros
podSpec:
image: ${IMAGE}:${IMAGE_TAG}
command: ["sh"]
args: ["-c", "export FLASK_APP=manage.py && poetry run flask db upgrade && poetry run flask seed && poetry run gunicorn ros.api.main:app"]
resources:
requests:
cpu: ${CPU_REQUEST_ROSRHEL}
memory: ${MEMORY_REQUEST_ROSRHEL}
limits:
cpu: ${CPU_LIMIT_ROSRHEL}
memory: ${MEMORY_LIMIT_ROSRHEL}
livenessProbe:
failureThreshold: 3
httpGet:
path: /api/ros/v1/status
port: 8000
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /api/ros/v1/status
port: 8000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
env:
- name: PATH_PREFIX
value: /api
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
- name: ENABLE_RBAC
value: "${ENABLE_RBAC}"
- name: DB_POOL_SIZE
value: ${DB_POOL_SIZE}
- name: DB_MAX_OVERFLOW
value: ${DB_MAX_OVERFLOW}
- name: UNLEASH_URL
value: ${UNLEASH_URL}
- name: UNLEASH_TOKEN
valueFrom:
secretKeyRef:
name: ${UNLEASH_SECRET_NAME}
key: CLIENT_ACCESS_TOKEN
optional: true
- name: BYPASS_UNLEASH
value: ${BYPASS_UNLEASH}

- name: inventory-events-processor
replicas: ${{INVENTORY_PROCESSOR_REPLICA_COUNT}}
- name: pcp-generator
replicas: ${{PCP_GENERATOR_REPLICA_COUNT}}
podSpec:
image: ${IMAGE}:${IMAGE_TAG}
command: ["bash"]
args: ["-c", "python -m ros.processor.inventory_events_consumer"]
args: ["-c", "python -m ros.processor.pcp_generator"]
resources:
requests:
cpu: ${CPU_REQUEST_ROSRHEL}
Expand Down Expand Up @@ -111,198 +47,22 @@ objects:
env:
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
- name: DB_POOL_SIZE
value: ${DB_POOL_SIZE}
- name: DB_MAX_OVERFLOW
value: ${DB_MAX_OVERFLOW}
- name: UNLEASH_URL
value: ${UNLEASH_URL}
- name: UNLEASH_TOKEN
valueFrom:
secretKeyRef:
name: ${UNLEASH_SECRET_NAME}
key: CLIENT_ACCESS_TOKEN
optional: true
- name: BYPASS_UNLEASH
value: ${BYPASS_UNLEASH}

- name: engine-result-processor
replicas: ${{ENGINE_PROCESSOR_REPLICA_COUNT}}
podSpec:
image: ${IMAGE}:${IMAGE_TAG}
command: ["bash"]
args: ["-c", "python -m ros.processor.insights_engine_consumer"]
resources:
requests:
cpu: ${CPU_REQUEST_ROSRHEL}
memory: ${MEMORY_REQUEST_ROSRHEL}
limits:
cpu: ${CPU_LIMIT_ROSRHEL}
memory: ${MEMORY_LIMIT_ROSRHEL}
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 9000
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /
port: 9000
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
env:
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
- name: DB_POOL_SIZE
value: ${DB_POOL_SIZE}
- name: DB_MAX_OVERFLOW
value: ${DB_MAX_OVERFLOW}
- name: UNLEASH_URL
value: ${UNLEASH_URL}
- name: UNLEASH_TOKEN
valueFrom:
secretKeyRef:
name: ${UNLEASH_SECRET_NAME}
key: CLIENT_ACCESS_TOKEN
optional: true
- name: BYPASS_UNLEASH
value: ${BYPASS_UNLEASH}

- name: garbage-collector-processor
replicas: ${{GARBAGE_COLLECTOR_REPLICA_COUNT}}
podSpec:
image: ${IMAGE}:${IMAGE_TAG}
command: ["bash"]
args: ["-c", "python -m ros.processor.garbage_collector"]
resources:
requests:
cpu: ${CPU_REQUEST_ROSRHEL}
memory: ${MEMORY_REQUEST_ROSRHEL}
limits:
cpu: ${CPU_LIMIT_ROSRHEL}
memory: ${MEMORY_LIMIT_ROSRHEL}
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 9000
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /
port: 9000
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
failureThreshold: 3
timeoutSeconds: 3
env:
- name: CLOWDER_ENABLED
value: ${CLOWDER_ENABLED}
- name: GARBAGE_COLLECTION_INTERVAL
value: ${GARBAGE_COLLECTION_INTERVAL}
- name: DAYS_UNTIL_STALE
value: ${DAYS_UNTIL_STALE}
- name: DB_POOL_SIZE
value: ${DB_POOL_SIZE}
- name: DB_MAX_OVERFLOW
value: ${DB_MAX_OVERFLOW}
- name: UNLEASH_URL
value: ${UNLEASH_URL}
- name: UNLEASH_TOKEN
valueFrom:
secretKeyRef:
name: ${UNLEASH_SECRET_NAME}
key: CLIENT_ACCESS_TOKEN
optional: true
- name: BYPASS_UNLEASH
value: ${BYPASS_UNLEASH}

database:
name: ros
version: 13
inMemoryDb: true
kafkaTopics:
- topicName: platform.inventory.events
partitions: 1
- topicName: platform.engine.results
partitions: 1
- topicName: platform.notifications.ingress
partitions: 1
testing:
iqePlugin: ros

jobs:
- name: org-id-populator
podSpec:
image: quay.io/cloudservices/tenant-utils:latest
command:
- ./org-id-column-populator
- -C
- -a
- account
- -o
- org_id
- -t
- rh_accounts
- --ean-translator-addr
- http://${TENANT_TRANSLATOR_HOST}:${TENANT_TRANSLATOR_PORT}
- --prometheus-push-addr
- ${PROMETHEUS_PUSHGATEWAY}
env:
- name: TENANT_TRANSLATOR_HOST
value: ${TENANT_TRANSLATOR_HOST}
- name: TENANT_TRANSLATOR_PORT
value: ${TENANT_TRANSLATOR_PORT}
- name: LOG_FORMAT
value: ${POPULATOR_LOG_FORMAT}
- name: LOG_BATCH_FREQUENCY
value: '1s'
resources:
limits:
cpu: 300m
memory: 1Gi
requests:
cpu: 50m
memory: 512Mi

parameters:
- description: Enable rbac needs to be "True" or "False"
name: ENABLE_RBAC
value: "True"
- description : ClowdEnvironment name
name: ENV_NAME
required: true
- description: Replica count for api pod
name: API_REPLICA_COUNT
value: "1"
- description: Replica count for inventory processor pod
name: INVENTORY_PROCESSOR_REPLICA_COUNT
value: "1"
- description: Replica count for engine processor pod
name: ENGINE_PROCESSOR_REPLICA_COUNT
value: "1"
- description: Replica count for garbage collector pod
name: GARBAGE_COLLECTOR_REPLICA_COUNT
- description: Replica count for pcp generator
name: PCP_GENERATOR_REPLICA_COUNT
value: "1"
- description: Image NAME
name: IMAGE
required: true
value: quay.io/redhat-services-prod/insights-management-tenant/insights-resource-optimization/ros-backend
value: quay.io/repository/cloudservices/ros-backend
- description: Image tag
name: IMAGE_TAG
required: true
Expand All @@ -329,34 +89,3 @@ parameters:
- description: Is clowder enabled
name: CLOWDER_ENABLED
value: "True"
- description: The interval at which garbage collection should run (in seconds)
name: GARBAGE_COLLECTION_INTERVAL
value: "86400"
- description: Number of days after which data is considered to be outdated
name: DAYS_UNTIL_STALE
value: "45"
- description: Host for the EAN to OrgId translator.
name: TENANT_TRANSLATOR_HOST
required: true
value: 'gateway.3scale-dev.svc.cluster.local'
- description: Port for the EAN to OrgId translator.
name: TENANT_TRANSLATOR_PORT
value: '8892'
- name: PROMETHEUS_PUSHGATEWAY
value: "localhost"
- name: POPULATOR_LOG_FORMAT
value: cloudwatch
- name: DB_POOL_SIZE
value: "20"
- name: DB_MAX_OVERFLOW
value: "20"

# Feature flags
- description: Unleash secret name
name: UNLEASH_SECRET_NAME
value: bypass
- description: Unleash API url
name: UNLEASH_URL
- description: disable Unleash (feature flags), defaulting to fallback values
name: BYPASS_UNLEASH
value: 'false'
1 change: 1 addition & 0 deletions ros/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def build_endpoint_url(ep):
DAYS_UNTIL_STALE = int(os.getenv("DAYS_UNTIL_STALE", '45'))
CW_LOGGING_FORMAT = '%(asctime)s - %(levelname)s - %(funcName)s - %(message)s'
ROS_PROCESSOR_PORT = int(os.getenv("ROS_PROCESSOR_PORT", "8000"))
ROS_PCP_PROCESSOR_PORT = int(os.getenv("ROS_PCP_PROCESSOR_PORT", "8000"))
ROS_API_PORT = int(os.getenv("ROS_API_PORT", "8000"))
# Timeout in seconds to set against keys of deleted systems in a cache
CACHE_TIMEOUT_FOR_DELETED_SYSTEM = int(
Expand Down
9 changes: 9 additions & 0 deletions ros/processor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from flask import Flask


def create_app():
app = Flask(__name__)
return app


app = create_app()
53 changes: 0 additions & 53 deletions ros/processor/main.py

This file was deleted.

Loading

0 comments on commit d97a34d

Please sign in to comment.