Skip to content

Commit

Permalink
Merge pull request #113 from JohnStrunk/api-pkg
Browse files Browse the repository at this point in the history
Add manifest for summarize-api service
  • Loading branch information
mergify[bot] authored Jun 13, 2024
2 parents 5117c68 + 289e67e commit 647841a
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"kubernetes": {
"fileMatch": [
"^jira-summarizer\\.yaml$",
"^jira-estimator\\.yaml$"
"^jira-estimator\\.yaml$",
"^summarize-api\\.yaml$"
]
},
"packageRules": [
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ibm-generative-ai = "*"
backoff-utils = "*"
flask = "*"
flask-jwt-extended = "*"
gunicorn = "*"

[dev-packages]
ipykernel = "*"
Expand Down
11 changes: 10 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions summarize-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: summarize-api
labels:
app: summarize-api
spec:
host: jira-summarizer.apps.platform-sts.pcbk.p1.openshiftapps.com
to:
kind: Service
name: summarize-api
weight: 100
port:
targetPort: 8000
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None

---
apiVersion: v1
kind: Service
metadata:
name: summarize-api
spec:
selector:
app: summarize-api
ports:
- protocol: TCP
port: 8000
targetPort: 8000

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: summarize-api
labels:
app: summarize-api
spec:
replicas: 1
selector:
matchLabels:
app: summarize-api
strategy:
type: Recreate
template:
metadata:
labels:
app: summarize-api
spec:
containers:
- name: estimator
image: ghcr.io/johnstrunk/jira-summarizer:1.2.1@sha256:505b205a45f0eb24d82fa5c02dc105af6d075362cb2694d82dc5face1d0a54ed
command:
- "/app/.venv/bin/gunicorn"
args:
- "--bind=0.0.0.0:8000"
- "--access-logfile=-"
- "summarize_api:create_app()"
envFrom:
- secretRef:
name: jira-summarizer-secret
optional: false
ports:
- containerPort: 8000
resources:
requests:
memory: "64Mi"
cpu: "10m"
limits:
memory: "512Mi"
cpu: "1000m"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
securityContext:
runAsNonRoot: true
terminationGracePeriodSeconds: 10
5 changes: 5 additions & 0 deletions summarize_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

"""Summarize a JIRA issue"""

import datetime
import os
import sys
from datetime import UTC
from sys import argv

from atlassian import Jira # type: ignore
Expand Down Expand Up @@ -41,6 +43,9 @@ def summarize_issue():
if key is None:
return {"error": 'Missing required parameter "key"'}, 400

when = datetime.datetime.now(UTC) - datetime.timedelta(hours=1)
issue_cache.remove_older_than(when)

issue = issue_cache.get_issue(client, key)
return {
"key": key,
Expand Down

0 comments on commit 647841a

Please sign in to comment.