From 0137bb19534e75d39cec732bff2f9fffc1533990 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Mon, 12 Feb 2024 09:24:03 -0600 Subject: [PATCH 01/10] make it a cronjob --- active/cronjob.yaml | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/active/cronjob.yaml b/active/cronjob.yaml index cf3ce8f..2c40f8e 100644 --- a/active/cronjob.yaml +++ b/active/cronjob.yaml @@ -1,22 +1,27 @@ -apiVersion: batch/v1 -kind: Job +apiVersion: batch/v1beta1 +kind: CronJob metadata: - name: timestamp-job + name: timestamp-cronjob spec: - template: - metadata: - name: timestamp-job + schedule: "*/1 * * * *" + jobTemplate: spec: - containers: - - name: timestamp-container - image: busybox - command: ["sh", "-c", "while true; do date >> /logs/runs.log; sleep 60; done"] - volumeMounts: - - name: data - mountPath: /logs - subPath: logs - restartPolicy: Never - volumes: - - name: data - persistentVolumeClaim: - claimName: data + template: + metadata: + labels: + app: timestamp-job + spec: + containers: + - name: timestamp-container + image: busybox + command: ["sh", "-c", "date >> /logs/runs.log"] + volumeMounts: + - name: logs-volume + mountPath: /logs + subPath: logs + restartPolicy: OnFailure + volumes: + - name: logs-volume + persistentVolumeClaim: + claimName: data + subPath: logs From 4a2a16808153b16d3b431a47d9db73d83c29c88c Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Mon, 12 Feb 2024 09:25:33 -0600 Subject: [PATCH 02/10] update version --- active/cronjob.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active/cronjob.yaml b/active/cronjob.yaml index 2c40f8e..9cad697 100644 --- a/active/cronjob.yaml +++ b/active/cronjob.yaml @@ -1,4 +1,4 @@ -apiVersion: batch/v1beta1 +apiVersion: batch/v1 kind: CronJob metadata: name: timestamp-cronjob From 87ad20d35523f304c473ddac5778227f23fe0822 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 19:47:14 -0600 Subject: [PATCH 03/10] weather helm --- active/weather/Chart.yaml | 4 ++++ active/weather/charts/.gitkeep | 0 active/weather/templates/cronjob.yaml | 27 +++++++++++++++++++++++++++ active/weather/values.yaml | 10 ++++++++++ 4 files changed, 41 insertions(+) create mode 100644 active/weather/Chart.yaml create mode 100644 active/weather/charts/.gitkeep create mode 100644 active/weather/templates/cronjob.yaml create mode 100644 active/weather/values.yaml diff --git a/active/weather/Chart.yaml b/active/weather/Chart.yaml new file mode 100644 index 0000000..d2e9262 --- /dev/null +++ b/active/weather/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: weather-cronjob-chart +description: A Helm chart for deploying a cron job to fetch weather information +version: 0.1.0 diff --git a/active/weather/charts/.gitkeep b/active/weather/charts/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/active/weather/templates/cronjob.yaml b/active/weather/templates/cronjob.yaml new file mode 100644 index 0000000..5f873a7 --- /dev/null +++ b/active/weather/templates/cronjob.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ .Release.Name }}-weather-cronjob +spec: + schedule: "{{ .Values.schedule }}" + jobTemplate: + spec: + template: + metadata: + labels: + app: weather-job + spec: + containers: + - name: weather-container + image: {{ .Values.container.image }} + command: ["sh", "-c", "{{ .Values.container.command }}"] + volumeMounts: + - name: logs-volume + mountPath: /logs + subPath: logs + restartPolicy: {{ .Values.restartPolicy }} + volumes: + - name: logs-volume + persistentVolumeClaim: + claimName: {{ .Values.volume.claimName }} + subPath: logs diff --git a/active/weather/values.yaml b/active/weather/values.yaml new file mode 100644 index 0000000..9d36df1 --- /dev/null +++ b/active/weather/values.yaml @@ -0,0 +1,10 @@ +schedule: "*/1 * * * *" + +container: + image: busybox + command: "curl 'wttr.in/peoria,il?format=3' >> /logs/weather.log" + +restartPolicy: OnFailure + +volume: + claimName: data From 6d5aa8d4415bb9fc7c83a2796f4367954ccfdd98 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 19:49:50 -0600 Subject: [PATCH 04/10] weather nohelm --- active/weather_report.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 active/weather_report.yaml diff --git a/active/weather_report.yaml b/active/weather_report.yaml new file mode 100644 index 0000000..74dae80 --- /dev/null +++ b/active/weather_report.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: weather-cronjob +spec: + schedule: "*/1 * * * *" + jobTemplate: + spec: + template: + metadata: + labels: + app: weather-job + spec: + containers: + - name: weather-container + image: busybox + command: ["sh", "-c", "curl 'wttr.in/peoria,il?format=3' >> /logs/weather.log"] + volumeMounts: + - name: logs-volume + mountPath: /logs + subPath: logs + restartPolicy: OnFailure + volumes: + - name: logs-volume + persistentVolumeClaim: + claimName: data + subPath: logs From 4c8b0e1d63eb34a140a6df7c8bc59e0cfe964e70 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 19:52:49 -0600 Subject: [PATCH 05/10] no subPath --- active/cronjob.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/active/cronjob.yaml b/active/cronjob.yaml index 9cad697..63b2648 100644 --- a/active/cronjob.yaml +++ b/active/cronjob.yaml @@ -18,7 +18,6 @@ spec: volumeMounts: - name: logs-volume mountPath: /logs - subPath: logs restartPolicy: OnFailure volumes: - name: logs-volume From f66e72444dc8fe1be84390c3d52b17e7c55fd6f1 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 19:54:27 -0600 Subject: [PATCH 06/10] no subPath --- active/weather_report.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/active/weather_report.yaml b/active/weather_report.yaml index 74dae80..c316a7f 100644 --- a/active/weather_report.yaml +++ b/active/weather_report.yaml @@ -18,10 +18,8 @@ spec: volumeMounts: - name: logs-volume mountPath: /logs - subPath: logs restartPolicy: OnFailure volumes: - name: logs-volume persistentVolumeClaim: claimName: data - subPath: logs From 50a9bc1c51e7bb2d1a5b0449a28bb4accf3a735e Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 19:59:13 -0600 Subject: [PATCH 07/10] no subPath --- active/cronjob.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/active/cronjob.yaml b/active/cronjob.yaml index 63b2648..e14efde 100644 --- a/active/cronjob.yaml +++ b/active/cronjob.yaml @@ -23,4 +23,3 @@ spec: - name: logs-volume persistentVolumeClaim: claimName: data - subPath: logs From def05dc7df64c194b09b938e79e749897b560eca Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 20:03:39 -0600 Subject: [PATCH 08/10] use curlimages --- active/weather_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active/weather_report.yaml b/active/weather_report.yaml index c316a7f..44b945f 100644 --- a/active/weather_report.yaml +++ b/active/weather_report.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - name: weather-container - image: busybox + image: curlimages/curl command: ["sh", "-c", "curl 'wttr.in/peoria,il?format=3' >> /logs/weather.log"] volumeMounts: - name: logs-volume From bae554d2d5fd520cf01f91c9ea3f7486e5afe2ed Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 13 Feb 2024 20:09:53 -0600 Subject: [PATCH 09/10] change log path --- active/weather_report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/active/weather_report.yaml b/active/weather_report.yaml index 44b945f..83c1a5c 100644 --- a/active/weather_report.yaml +++ b/active/weather_report.yaml @@ -14,7 +14,7 @@ spec: containers: - name: weather-container image: curlimages/curl - command: ["sh", "-c", "curl 'wttr.in/peoria,il?format=3' >> /logs/weather.log"] + command: ["sh", "-c", "curl 'wttr.in/peoria,il?format=3' >> /logs/wttr.log"] volumeMounts: - name: logs-volume mountPath: /logs From 4f2d1c322e85eb4c51b861411b78f1d4b11d03c0 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Sat, 22 Nov 2025 22:10:09 -0600 Subject: [PATCH 10/10] wip --- .gitignore | 8 ++++++++ active/weather_report.yaml | 2 +- mysealedsecret.yaml | 15 +++++++++++++++ people.yml | 10 ++++++++++ people/handler.py | 18 ++++++++++++++++++ people/requirements.txt | 30 ++++++++++++++++++++++++++++++ pvc-inpsector.yaml | 16 +++++++++++++++- python-function.yml | 9 +++++++++ python-function/handler.py | 8 ++++++++ python-function/requirements.txt | 0 startup.sh | 22 ++++++++++++++++++++++ 11 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 mysealedsecret.yaml create mode 100644 people.yml create mode 100644 people/handler.py create mode 100644 people/requirements.txt create mode 100644 python-function.yml create mode 100644 python-function/handler.py create mode 100644 python-function/requirements.txt create mode 100644 startup.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f5c2367 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +template +build +.secrets +mysecret.json +mysecret.yaml +mysealedsecret.json +.env +.mysealedsecret.json2235032335 diff --git a/active/weather_report.yaml b/active/weather_report.yaml index 83c1a5c..a1df687 100644 --- a/active/weather_report.yaml +++ b/active/weather_report.yaml @@ -14,7 +14,7 @@ spec: containers: - name: weather-container image: curlimages/curl - command: ["sh", "-c", "curl 'wttr.in/peoria,il?format=3' >> /logs/wttr.log"] + command: ["sh", "-c", "date >> /logs/wttr.log && curl 'wttr.in/peoria,il?format=3' >> /logs/wttr.log && echo ''"] volumeMounts: - name: logs-volume mountPath: /logs diff --git a/mysealedsecret.yaml b/mysealedsecret.yaml new file mode 100644 index 0000000..ab48c56 --- /dev/null +++ b/mysealedsecret.yaml @@ -0,0 +1,15 @@ +apiVersion: bitnami.com/v1alpha1 +kind: SealedSecret +metadata: + creationTimestamp: null + name: mysecret + namespace: minecraft +spec: + encryptedData: + foo: AgCBsDB9HP0nqFPgLIEMug9Zgp7kQ4O5lfKZy0MaB1chPCzV0vSdg13ZRjv5NbsjFbb2G8tUt0O81JL/5l7sRnaJIZQJS4Ro7/4ij3K5Av8hq754gQJDGQQP0DLq/bRwdhimayw6ZNnsCxUnrTqJRRch7rGo0zWQjIcUy1fs53p9fIUZxEPdoBTIgP6sLfcKuROVQt1+IPO351WNx3CIrB4BuSkWGlPs/wx1yddC5bWl7X85AsrqwFQvU6qamOrqCvKCrJVVCAk323Z9+ziY8BkYZXhWjayMyl35weTKZjLs4p6lnpreTpjriWdSblkRmcA1G9aNCOp2axtuUG//HdEg4N1vioENcig5r+lp6ySXxODEdHX/ROfg8GqPSmMqyzX/GjI3b1Cz2nsyMfWcWC1w2D3aLL7B5gI939qN6oUm3Ip2OSOUJBLeVaZVhw+ozM7qmtIj/HGTtepjebdvHgvWHP8zAQB+crftWLu53qT7CWrM7QLdMIvsMI7mTAfTOfF536yYi6/i945ixhaLWShsWyNfvedq6DZ8azZyKTbmva34oADoxrpaR/tpvA9SSUz2yM0R+7WqWaDFWxUqqqijuocyeKjpj+AFr5rxLZVtx2gJ01vg2axGv3hieT/xM9h9LqdCxxq1nhv9ue66FRsuAD9gT1QYpH2I8GAAaKNBYTxHFW6eDke1z03/2BHkPoSsTug= + template: + metadata: + creationTimestamp: null + name: mysecret + namespace: default + type: Opaque diff --git a/people.yml b/people.yml new file mode 100644 index 0000000..4093979 --- /dev/null +++ b/people.yml @@ -0,0 +1,10 @@ +version: 1.0 +provider: + name: openfaas + gateway: http://127.0.0.1:8080 +functions: + people: + lang: python + handler: ./people + image: people:latest + diff --git a/people/handler.py b/people/handler.py new file mode 100644 index 0000000..6281bd7 --- /dev/null +++ b/people/handler.py @@ -0,0 +1,18 @@ +def detect_person(url): + return "Hello, World!" + + +def handle(req): + """handle a request to the function + Args: + req (str): request body + """ + + if not req: + raise Exception("Empty request") + + if isinstance(req, str): + req = req.encode("utf-8") + url = req + + return detect_person(url) diff --git a/people/requirements.txt b/people/requirements.txt new file mode 100644 index 0000000..cb50cf8 --- /dev/null +++ b/people/requirements.txt @@ -0,0 +1,30 @@ +# pip install -r requirements.txt + +# base ---------------------------------------- +Cython +matplotlib>=3.2.2 +numpy>=1.18.5 +opencv-python>=4.1.2 +Pillow +PyYAML>=5.3.1 +scipy>=1.4.1 +tensorboard>=2.2 +torch>=1.7.0 +torchvision>=0.8.1 +tqdm>=4.41.0 + +# logging ------------------------------------- +# wandb + +# plotting ------------------------------------ +seaborn>=0.11.0 +pandas + +# export -------------------------------------- +# coremltools>=4.1 +# onnx>=1.8.1 +# scikit-learn==0.19.2 # for coreml quantization + +# extras -------------------------------------- +thop # FLOPS computation +pycocotools>=2.0 # COCO mAP diff --git a/pvc-inpsector.yaml b/pvc-inpsector.yaml index 87065aa..51f3654 100644 --- a/pvc-inpsector.yaml +++ b/pvc-inpsector.yaml @@ -5,14 +5,28 @@ metadata: namespace: minecraft spec: containers: - - image: busybox + - image: docker.io/curlimages/curl name: pvc-inspector command: ["sleep", "3600"] + env: + - name: FOO + valueFrom: + secretKeyRef: + name: mysecret + key: foo volumeMounts: - mountPath: /data name: data # subPath: minecraft + # + # + - name: sealed-secret + mountPath: /secret + readOnly: true volumes: - name: data persistentVolumeClaim: claimName: data + - name: sealed-secret + secret: + secretName: mysecret diff --git a/python-function.yml b/python-function.yml new file mode 100644 index 0000000..4f50666 --- /dev/null +++ b/python-function.yml @@ -0,0 +1,9 @@ +version: 1.0 +provider: + name: openfaas + gateway: http://127.0.0.1:8080 +functions: + python-function: + lang: python + handler: ./python-function + image: waylonwalker/python-function:latest diff --git a/python-function/handler.py b/python-function/handler.py new file mode 100644 index 0000000..8487d01 --- /dev/null +++ b/python-function/handler.py @@ -0,0 +1,8 @@ +def handle(req): + """handle a request to the function + Args: + req (str): request body + """ + # print("Hello! You said: " + req) + + return {"message": req} diff --git a/python-function/requirements.txt b/python-function/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..1567fa3 --- /dev/null +++ b/startup.sh @@ -0,0 +1,22 @@ +kind create cluster --name minecraft +helm repo add argo https://argoproj.github.io/argo-helm +helm repo update +helm install argo argo/argo-cd --namespace argocd --create-namespace +kubectl port-forward service/argo-argocd-server -n argocd 8080:443 +argocd admin initial-password -n argocd +argocd login localhost:8080 +argocd app list +argocd app create minecraft --repo https://github.com/waylonwalker/minecraft-servers --path active --dest-server https://kubernetes.default.svc --dest-namespace minecraft +argocd app list +argocd app sync minecraft +argocd app list +argocd app set minecraft --sync-policy automated --auto-prune +argocd app list +argocd app get minecraft + +# --- +helm repo update \ + && helm upgrade openfaas \ + --install openfaas/openfaas \ + --namespace openfaas \ + --create-namespace