changeset 33:b82432594778

skaffold config and other updates
author drewp@bigasterisk.com
date Sat, 21 Aug 2021 14:24:57 -0700
parents c23acc88324b
children c7b59377ab35
files .style.yapf Dockerfile deploy.yaml lookup.py requirements.txt run serv.n3 skaffold.yaml
diffstat 8 files changed, 69 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.style.yapf	Sat Aug 21 14:24:57 2021 -0700
@@ -0,0 +1,4 @@
+# overwritten by /home/drewp/bin/setup_home_venv
+[style]
+based_on_style = google
+column_limit = 130
--- a/Dockerfile	Sat Aug 21 14:24:09 2021 -0700
+++ b/Dockerfile	Sat Aug 21 14:24:57 2021 -0700
@@ -1,16 +1,14 @@
-FROM bang5:5000/base_x86
+FROM bang5:5000/base_basic
 
 WORKDIR /opt
 
-RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
-
 COPY requirements.txt ./
 
 RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -r requirements.txt
 
-COPY *.py run ./
+COPY *.py ./
 COPY static static/
 COPY template template/
 
 
-CMD [ "./run" ]
+CMD [ "python3", "lookup.py" ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy.yaml	Sat Aug 21 14:24:57 2021 -0700
@@ -0,0 +1,29 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: href
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: href
+  template:
+    metadata:
+      labels:
+        app: href
+    spec:
+      containers:
+        - name: href
+          image: bang5:5000/href_image
+          ports:
+          - containerPort: 10002
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: href
+spec:
+  ports:
+  - {port: 80, targetPort: 10002}
+  selector:
+    app: href
--- a/lookup.py	Sat Aug 21 14:24:09 2021 -0700
+++ b/lookup.py	Sat Aug 21 14:24:57 2021 -0700
@@ -10,6 +10,7 @@
 import datetime
 import json
 import logging
+import os
 import time
 import urllib.error
 import urllib.parse
@@ -25,8 +26,8 @@
 from link import Links, NotFound
 from pagetitle import PageTitle
 
-db = pymongo.Connection('mongodb.default.svc.cluster.local',
-                        tz_aware=True)['href']
+db = pymongo.MongoClient(os.environ['MONGODB_SERVICE_HOST'],
+                         tz_aware=True)['href']
 pageTitle = PageTitle(db)
 links = Links(db)
 renderer = Renderer(search_dirs=['template'], debug=bottle.DEBUG)
@@ -72,7 +73,7 @@
     those tags"""
     withTags = set(withTags)
     count = defaultdict(lambda: 0)  # tag : count
-    for doc in db['links'].find({'user': user}, fields=['extracted.tags']):
+    for doc in db['links'].find({'user': user}, projection=['extracted.tags']):
         docTags = set(doc.get('extracted', {}).get('tags', []))
         if withTags and not withTags.issubset(docTags):
             continue
@@ -243,4 +244,4 @@
 
 if __name__ == '__main__':
     logging.basicConfig(level=logging.INFO)
-    bottle.run(server='gunicorn', host='0.0.0.0', port=10002, workers=4)
+    bottle.run(server='gunicorn', host='0.0.0.0', port=10002, workers=1)
--- a/requirements.txt	Sat Aug 21 14:24:09 2021 -0700
+++ b/requirements.txt	Sat Aug 21 14:24:57 2021 -0700
@@ -1,14 +1,14 @@
-BeautifulSoup4
-CherryPy==3.2.2
-argparse==1.2.1
-bottle==0.11.6
-cssselect==0.7.1
-gunicorn==0.17.2
-http-parser==0.8.1
-pymongo==2.4.2
-pystache==0.5.3
-python-dateutil
+BeautifulSoup4==4.9.3
+CherryPy==18.6.1
+argparse==1.4.0
+bottle==0.12.19
+cssselect==1.1.0
+gunicorn==20.1.0
+http-parser==0.9.0
+pymongo==3.12.0
+pystache==0.5.4
+python-dateutil==2.8.2
 six
 pyjade==4.0.0
-lxml==4.5.2
-requests==2.24.0
\ No newline at end of file
+lxml==4.6.3
+requests==2.26.0
\ No newline at end of file
--- a/run	Sat Aug 21 14:24:09 2021 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-#!/bin/sh
-echo "nameserver 10.43.0.10" > /etc/resolv.conf
-exec python3 lookup.py
--- a/serv.n3	Sat Aug 21 14:24:09 2021 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-@prefix : <http://bigasterisk.com/ns/serv#> .
-@prefix auth: <http://bigasterisk.com/ns/serv/auth#> .
-@prefix serv: <http://bigasterisk.com/services/> .
-
-
-serv:href_image a :DockerImage;
-  :internalPort 10002;
-  :dockerFile "Dockerfile"
-.
-
-serv:href a :Service;
-  :image serv:href_image;
-  :path "/href/";
-  :openid auth:admin;
-  :serverHost "bang";
-  :port 10002
-.
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/skaffold.yaml	Sat Aug 21 14:24:57 2021 -0700
@@ -0,0 +1,16 @@
+apiVersion: skaffold/v2beta5
+kind: Config
+metadata:
+  name: href
+build:
+  tagPolicy:
+    dateTime:
+      format: "2006-01-02_15-04-05"
+      timezone: "Local"
+  artifacts:
+  - image: bang5:5000/href_image
+
+deploy:
+  kubectl:
+    manifests:
+    - deploy.yaml