-
Notifications
You must be signed in to change notification settings - Fork 1
Configure env-specific scaling for contextapi #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
acmeguy
wants to merge
1
commit into
main
Choose a base branch
from
feat/contextapi-env-specific-scaling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: contextapi | ||
| spec: | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: contextapi | ||
| minReplicas: 1 | ||
| maxReplicas: 4 | ||
| metrics: | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| target: | ||
| type: Utilization | ||
| averageUtilization: 60 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: contextapi | ||
| labels: | ||
| app: contextapi # Standard label for grouping | ||
| # Add any other labels your Prometheus Operator setup might require for discovery | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: contextapi # Selects the Service for contextapi | ||
| namespaceSelector: | ||
| matchNames: | ||
| - api # Assuming the service is in the 'api' namespace, as per fleet.yaml | ||
| endpoints: | ||
| - port: http # Matches the name given to the containerPort in the Deployment | ||
| path: /metrics # Standard path for Prometheus metrics | ||
| interval: 30s # How frequently to scrape |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| resources: | ||
| - contextapi-deployment.yaml | ||
| - contextapi-service.yaml | ||
| - contextapi-service.yaml | ||
| - networkpolicy.yaml # Added this line | ||
| - contextapi-hpa.yaml | ||
| - contextapi-servicemonitor.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: contextapi-default | ||
| namespace: api # Assuming the namespace is 'api' as seen in fleet.yaml | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: contextapi # Selects the contextapi pods | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: | ||
| # Allow traffic from NGINX ingress controller pods | ||
| - from: | ||
| - podSelector: | ||
| matchLabels: | ||
| app: nginx # Placeholder: Label for NGINX ingress pods | ||
| namespaceSelector: {} # Allows from any namespace if NGINX is in a different one, adjust if NGINX is in the same namespace | ||
| # Allow traffic from other contextapi pods (for circular requests) | ||
| - from: | ||
| - podSelector: | ||
| matchLabels: | ||
| app: contextapi | ||
| egress: | ||
| # Allow all egress traffic by default | ||
| - {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
apps/contextapi/overlays/development/contextapi-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: contextapi-config | ||
| # NO SECRETS SHOULD BE STORED IN CONFIGMAPS [See the docs](/README.md)) | ||
| data: | ||
| ZONE: 'dev_sbx' | ||
|
|
||
| # Redis | ||
| REDIS_URL: 'redis-master.data' | ||
| REDIS_USER: '' | ||
| LOCAL_REDIS: 'false' | ||
|
|
||
| # Postgres | ||
| LIST_DB_NAME: 'list_db' | ||
| DB_CLIENT: 'pg' | ||
| DB_HOST: 'cxs-pg-pgbouncer.data' | ||
| DB_USER: 'cxs-pg' | ||
| DB_PORT: '5432' | ||
| DB_NAME: 'ssp' | ||
| DB_SSL: 'false' | ||
|
|
||
| # Neo4j | ||
| NEO4J_USER: 'neo4j' | ||
| NEO4J_URI: 'neo4j://neo4j.data:7687' | ||
| NEO4J_DATABASE: 'contextsuite' | ||
|
|
||
| # Solr | ||
| SOLR_PORT: '8983' | ||
| SOLR_PATH: '/solr/quicklookup' | ||
| SOLR_CORE: 'quicklookup' | ||
| SOLR_COLLECTION: 'quicklookup' | ||
| SOLR_HOST: 'solr.data' | ||
| SOLR_PROTOCALL: 'http' | ||
|
|
||
| # Clickhouse | ||
| # CLICKHOUSE_CONNECTION: 'http://10.180.122.46:8123' | ||
| CLICKHOUSE_CONNECTION: 'http://10.180.122.32:8123' | ||
| CLICKHOUSE_USER: 'default' | ||
|
|
||
| GRAPHQL_SERVER_PORT: '4001' | ||
| GRAPHQL_SERVER_PATH: '/context' | ||
| WKT_FOLDER: '/cdn/wkt_cache' | ||
|
|
||
| # Sentry | ||
| SENTRY_ENVIRONMENT: 'contextsuite-prod' | ||
| NEXT_PUBLIC_SENTRY_DSN: 'https://97964f08ea76422f830fba0618967fc4@o982223.ingest.sentry.io/5937160' | ||
| SENTRY_DSN: 'https://97964f08ea76422f830fba0618967fc4@o982223.ingest.sentry.io/5937160' | ||
| HASH_SECRET: 'context-suite' |
37 changes: 37 additions & 0 deletions
37
apps/contextapi/overlays/development/contextapi-ingress.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: Ingress | ||
| metadata: | ||
| name: contextapi # Name can remain contextapi | ||
| annotations: | ||
| cert-manager.io/cluster-issuer: letsencrypt-prod | ||
| spec: | ||
| ingressClassName: nginx | ||
| rules: | ||
| - host: dev.app.contextsuite.com # Updated host | ||
| http: | ||
| paths: | ||
| - backend: | ||
| service: | ||
| name: contextapi | ||
| port: | ||
| number: 4001 | ||
| path: /stats | ||
| pathType: Prefix | ||
| - backend: | ||
| service: | ||
| name: contextapi | ||
| port: | ||
| number: 4001 | ||
| path: /context | ||
| pathType: Prefix | ||
| - backend: | ||
| service: | ||
| name: contextapi | ||
| port: | ||
| number: 4001 | ||
| path: /graph | ||
| pathType: Prefix | ||
| tls: | ||
| - hosts: | ||
| - dev.app.contextsuite.com # Updated host for TLS | ||
| secretName: contextapi-dev-tls # Updated secretName |
16 changes: 16 additions & 0 deletions
16
apps/contextapi/overlays/development/deployment-resources-patch.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: contextapi | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - name: node # Name of the container to patch | ||
| resources: | ||
| requests: | ||
| cpu: "100m" | ||
| memory: "100Mi" | ||
| limits: | ||
| cpu: "200m" | ||
| memory: "200Mi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: contextapi | ||
| spec: | ||
| minReplicas: 1 | ||
| maxReplicas: 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
|
|
||
| bases: | ||
| - ../../base | ||
|
|
||
| resources: | ||
| - contextapi-config.yaml | ||
| - contextapi-ingress.yml | ||
|
|
||
| patchesStrategicMerge: | ||
| - hpa-patch.yaml | ||
| - deployment-resources-patch.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: contextapi-config | ||
| # NO SECRETS SHOULD BE STORED IN CONFIGMAPS [See the docs](/README.md)) | ||
| data: | ||
| ZONE: 'dev_sbx' | ||
|
|
||
| # Redis | ||
| REDIS_URL: 'redis-master.data' | ||
| REDIS_USER: '' | ||
| LOCAL_REDIS: 'false' | ||
|
|
||
| # Postgres | ||
| LIST_DB_NAME: 'list_db' | ||
| DB_CLIENT: 'pg' | ||
| DB_HOST: 'cxs-pg-pgbouncer.data' | ||
| DB_USER: 'cxs-pg' | ||
| DB_PORT: '5432' | ||
| DB_NAME: 'ssp' | ||
| DB_SSL: 'false' | ||
|
|
||
| # Neo4j | ||
| NEO4J_USER: 'neo4j' | ||
| NEO4J_URI: 'neo4j://neo4j.data:7687' | ||
| NEO4J_DATABASE: 'contextsuite' | ||
|
|
||
| # Solr | ||
| SOLR_PORT: '8983' | ||
| SOLR_PATH: '/solr/quicklookup' | ||
| SOLR_CORE: 'quicklookup' | ||
| SOLR_COLLECTION: 'quicklookup' | ||
| SOLR_HOST: 'solr.data' | ||
| SOLR_PROTOCALL: 'http' | ||
|
|
||
| # Clickhouse | ||
| # CLICKHOUSE_CONNECTION: 'http://10.180.122.46:8123' | ||
| CLICKHOUSE_CONNECTION: 'http://10.180.122.32:8123' | ||
| CLICKHOUSE_USER: 'default' | ||
|
|
||
| GRAPHQL_SERVER_PORT: '4001' | ||
| GRAPHQL_SERVER_PATH: '/context' | ||
| WKT_FOLDER: '/cdn/wkt_cache' | ||
|
|
||
| # Sentry | ||
| SENTRY_ENVIRONMENT: 'contextsuite-prod' | ||
| NEXT_PUBLIC_SENTRY_DSN: 'https://97964f08ea76422f830fba0618967fc4@o982223.ingest.sentry.io/5937160' | ||
| SENTRY_DSN: 'https://97964f08ea76422f830fba0618967fc4@o982223.ingest.sentry.io/5937160' | ||
| HASH_SECRET: 'context-suite' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: Ingress | ||
| metadata: | ||
| name: contextapi # Name can remain contextapi as it's namespaced by overlay | ||
| annotations: | ||
| cert-manager.io/cluster-issuer: letsencrypt-prod | ||
| spec: | ||
| ingressClassName: nginx | ||
| rules: | ||
| - host: staging.app.contextsuite.com # Updated host | ||
| http: | ||
| paths: | ||
| - backend: | ||
| service: | ||
| name: contextapi | ||
| port: | ||
| number: 4001 | ||
| path: /stats | ||
| pathType: Prefix | ||
| - backend: | ||
| service: | ||
| name: contextapi | ||
| port: | ||
| number: 4001 | ||
| path: /context | ||
| pathType: Prefix | ||
| - backend: | ||
| service: | ||
| name: contextapi | ||
| port: | ||
| number: 4001 | ||
| path: /graph | ||
| pathType: Prefix | ||
| tls: | ||
| - hosts: | ||
| - staging.app.contextsuite.com # Updated host for TLS | ||
| secretName: contextapi-staging-tls # Updated secretName |
16 changes: 16 additions & 0 deletions
16
apps/contextapi/overlays/staging/deployment-resources-patch.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: contextapi | ||
| spec: | ||
| template: | ||
| spec: | ||
| containers: | ||
| - name: node # Name of the container to patch | ||
| resources: | ||
| requests: | ||
| cpu: "150m" | ||
| memory: "150Mi" | ||
| limits: | ||
| cpu: "300m" | ||
| memory: "300Mi" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: contextapi | ||
| spec: | ||
| minReplicas: 1 | ||
| maxReplicas: 2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This selector is wrong, should be:
app.kubernetes.io/name: rke2-ingress-nginx