Compare commits
No commits in common. "9a5a237cb3d23fcc4ad99bf5fb2cfdb0780c5bd2" and "6f376a2d0f255b6a8fe74a627ff24d2424870a73" have entirely different histories.
9a5a237cb3
...
6f376a2d0f
10 changed files with 14 additions and 159 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,2 @@
|
|||
sqlite-data
|
||||
private/*
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
> [!IMPORTANT]
|
||||
> This project has been moved to https://git.wayl.one/waylon/learn-helm
|
||||
|
||||
0
get_helm.sh
Normal file → Executable file
0
get_helm.sh
Normal file → Executable file
5
justfile
5
justfile
|
|
@ -20,9 +20,8 @@ sealed-secretes-backup:
|
|||
kubectl get secret -n kube-system -l sealedsecrets.bitnami.com/sealed-secrets-key -o yaml > private/sealed-secrets-key.yaml
|
||||
|
||||
seal-openweathermap-api-key:
|
||||
kubectl create secret generic openweathermap-api-key --from-literal=openweathermap-api-key=${OPENWEATHERMAP_API_KEY} --dry-run=client -o yaml > private/openweathermap-api-key.yaml
|
||||
kubeseal --namespace temperature-cronjob-helm --format=yaml < private/openweathermap-api-key.yaml > temperature-cronjob/templates/sealed-openweathermap-api-key.yaml
|
||||
kubeseal --namespace temperature-cronjob-manifest --format=yaml < private/openweathermap-api-key.yaml > temperature-cronjob-manifest/sealed-openweathermap-api-key.yaml
|
||||
kubectl create secret generic mysecret --from-literal=openweathermap-api-key=${OPENWEATHERMAP_API_KEY} --dry-run=client -o yaml > private/openweathermap-api-key.yaml
|
||||
kubeseal --format=yaml < private/openweathermap-api-key.yaml > temperature-cronjob/templates/openweathermap-api-key.yaml
|
||||
|
||||
argo-install:
|
||||
kubectl create namespace argocd
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: temperature-cronjob-manifest
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: temperature-fetcher
|
||||
namespace: temperature-cronjob-manifest
|
||||
data:
|
||||
temperature_fetcher.py: |
|
||||
# temperature_fetcher.py
|
||||
import datetime
|
||||
import os
|
||||
import requests
|
||||
import sqlite3
|
||||
|
||||
print("hey im running")
|
||||
|
||||
city = os.getenv("CITY")
|
||||
api_key = os.getenv("API_KEY")
|
||||
mount_path = os.getenv("MOUNT_PATH", "/data/manifest")
|
||||
|
||||
try:
|
||||
response = requests.get(
|
||||
f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=imperial"
|
||||
)
|
||||
response.raise_for_status()
|
||||
temp = response.json()["main"]["temp"]
|
||||
|
||||
db_path = f"{mount_path}/temperature.db"
|
||||
conn = sqlite3.connect(db_path)
|
||||
c = conn.cursor()
|
||||
c.execute(
|
||||
"CREATE TABLE IF NOT EXISTS temperatures (timestamp TEXT, temperature REAL)"
|
||||
)
|
||||
c.execute(
|
||||
"INSERT INTO temperatures VALUES (?, ?)",
|
||||
(datetime.datetime.now().isoformat(), temp),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
print(
|
||||
f"Successfully stored temperature {temp}°C for {city} at {datetime.datetime.now()}"
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: temperature-cronjob
|
||||
namespace: temperature-cronjob-manifest
|
||||
spec:
|
||||
schedule: "*/1 * * * *"
|
||||
startingDeadlineSeconds: 200 # Deadline for starting the job
|
||||
concurrencyPolicy: Forbid # Prevents concurrent runs
|
||||
successfulJobsHistoryLimit: 3 # Keeps last successful job
|
||||
failedJobsHistoryLimit: 3 # Keeps last failed job
|
||||
jobTemplate:
|
||||
spec:
|
||||
activeDeadlineSeconds: 180 # Limits how long a job can be active
|
||||
ttlSecondsAfterFinished: 100 # Cleans up finished jobs after 100 seconds
|
||||
backoffLimit: 0 # Number of retries before considering the job failed
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: temperature-fetcher
|
||||
terminationMessagePath: "/sqlite-data/termination.log"
|
||||
image: "python:3.9-slim"
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/bin/bash", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "Installing dependencies" && \
|
||||
pip install requests && \
|
||||
echo "Fetching temperature" && \
|
||||
python /scripts/temperature_fetcher.py
|
||||
resources:
|
||||
requests:
|
||||
cpu: "25m"
|
||||
memory: "8Mi"
|
||||
limits:
|
||||
cpu: "50m"
|
||||
memory: "16Mi"
|
||||
env:
|
||||
- name: CITY
|
||||
value: "Dunlap, US"
|
||||
- name: MOUNT_PATH
|
||||
value: "/data"
|
||||
- name: API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openweathermap-api-key
|
||||
key: openweathermap-api-key
|
||||
volumeMounts:
|
||||
- name: sqlite-data
|
||||
mountPath: "/data"
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
restartPolicy: Never
|
||||
volumes:
|
||||
- name: sqlite-data
|
||||
hostPath:
|
||||
path: "/sqlite-data"
|
||||
type: Directory
|
||||
- name: script-volume
|
||||
configMap:
|
||||
name: release-name-script
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
apiVersion: bitnami.com/v1alpha1
|
||||
kind: SealedSecret
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: openweathermap-api-key
|
||||
namespace: temperature-cronjob-manifest
|
||||
spec:
|
||||
encryptedData:
|
||||
openweathermap-api-key: AgAniTh8zqhUvb/IQ2nYH/0OCu+ke9GfcYuOE9lSTmKYWQvwecw9F5phjs0wkLDSGyLQfUWLAOT4rKg6e7nqAOHQEnFdp5tI5vbWtcgV2sZbaB+h40WGdLSa4tC0EfXtEpvM1/ugECd8YFOrOmgL7zUNNFsT7MUWyHAxv8p2Na0bKZ68fsEr8urhnEg6F980U7jeb2cQ4sgWsODs2EYTwzTdsNanZCTFADbDPpmcY6rc5kkGSK65lhCV7wZozS2i6DG2TRMAttxynZidAy1sdRRqmI/T85hVWB+/U9SpL/T07uR49zJIPSer/1yWmznVvJRgQYcu64PlpxwXIW5UkLkDc4ksCJTolwLBFCR0BdEMK/+MUfbnJs6W/CqwNGm7Z7URNIxRU169OJJeDLa4lrBd1wopaXWTosbTyX0kdit9dxb3uRZ/0EYYNB85i8rJdpU+gCXxERvZ74Z0l/qZSYgiPmTnrCbzKlmOOqXwmQ2VtdDny1YJ2B51Nq790MA+vrWaT+3hS2JirCGtnZYvEnAsZxrqhhPPG8pfe3CMbUfhroFhoNQabVj+0Zjkfhb8qJwGRady7B4k2i08YFgdFiTjuFl3ZBvchv/L4qWQY4uPCywCn4SB+bVueObw2ajxO4xD1wtdNUg76rLV3juBncXJLsDyfM8C+gVTXhshNLbEq+EC4KaSmXYv6LZp2RqSVUe+tYJqUAiyUhYdRNiYU1RcCvrvQ0l+8S2Kl66fPztI7A==
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: openweathermap-api-key
|
||||
namespace: temperature-cronjob-manifest
|
||||
|
|
@ -13,28 +13,28 @@ spec:
|
|||
spec:
|
||||
activeDeadlineSeconds: 180 # Limits how long a job can be active
|
||||
ttlSecondsAfterFinished: 100 # Cleans up finished jobs after 100 seconds
|
||||
backoffLimit: 0 # Number of retries before considering the job failed
|
||||
backoffLimit: 3 # Number of retries before considering the job failed
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: temperature-fetcher
|
||||
terminationMessagePath: "/sqlite-data/termination.log"
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
command: ["/bin/bash", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "Installing dependencies" && \
|
||||
echo "Running temperature_fetcher.py" && \
|
||||
pip install requests && \
|
||||
echo "Fetching temperature" && \
|
||||
python /scripts/temperature_fetcher.py
|
||||
python /scripts/temperature_fetcher.py && \
|
||||
sleep 300
|
||||
resources:
|
||||
requests:
|
||||
cpu: "25m"
|
||||
memory: "8Mi"
|
||||
cpu: "100m"
|
||||
memory: "128Mi"
|
||||
limits:
|
||||
cpu: "50m"
|
||||
memory: "16Mi"
|
||||
cpu: "200m"
|
||||
memory: "256Mi"
|
||||
env:
|
||||
- name: CITY
|
||||
value: "{{ .Values.city }}"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ apiVersion: bitnami.com/v1alpha1
|
|||
kind: SealedSecret
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: openweathermap-api-key
|
||||
name: mysecret
|
||||
namespace: default
|
||||
spec:
|
||||
encryptedData:
|
||||
openweathermap-api-key: AgBm3myqlnLC3peWUOG9/vl5zzqwzTvyOXXAp54XQ9S3iQjC7GO+Bo5an9KVRqWQVQ9JY8DjGAp/7CYrKdgplOLG63bBGVTS1QdmH72xYSbEF0Je9pJwZ8+dD9q/rhoZzTgUqSvF/CFCtBI9dr2aE25jmxGc9TV/VnzhscX12o/6+kxz9p5hEhZ7QTHbdWEaVjjbo4YQ1aXyb0XD9Z/xxG3Hwf3N97sE9z39IvoF/aAGEKrCGMZYtI0T0fuUwCqji8JgjJ9SguPq4GzRRpUeJGnB+LSZFB95k1lAj6yhUP95DIwUGRon7ksQ/AXcJMFrsaQQ7kcxwUuTlbvoc7Vc84SQi6ZPv0yDypyr6pUE+8MrzvTzchXgsofCUC7FWDIqzH5bGc3CJ1OEP21FxW87NtvTr9xgap5/bOqLYs9U8wv02bL1yqVGLfWBoy+QLIY5viVUgj+kVzLftQlkimSMbfNNUtCJjpYYrLNoknU+fyGqsQnksXQSFlfwJZTOKFIcXwQ+exAkja8KpBYzehJulvU8A1UZZ0ylqniLTgxEMpOJ7Vu1MsBuBddZn4qHModbM1dCRC6GJEVQAaFYrZWonb9nhqLX9xei2LE2j/amaw6D7oZQ0b0+4cMsGC/mtRMgWMC5VorQH8qRPXtSitztOQv1mejvnpJWv0mUvmWiNsynaALMbA89OorMNPc5xn5HogTpygp69lb03n7UGwBBIvkQHGD336Uwh07L4iZ5lOe4sA==
|
||||
openweathermap-api-key: AgCFICyiqMaxx5vf4D06GuuB/xoC8SJJ43KD5+ipsF7stwzDN7BWQexnPAgPvCMiRq+w+oRRbR/IBIYPk4Ng3kdTwYjkCf1rUFogaHdACs9dS1mhaW9ipwd2rO7ImJVVJUZgkAmEv/F6JBz+cR4w6RUsU8OcDBLqPMehe8JG/YrXPu2hJt38lzl8Hry/j7ydgm5nq7fxuHGbY66FKyVrtW/zzKQhZHYojDvS0Qez/OsWFz7I8o/287qoQjcxPr8giniIo3EPxfT5XjAB5HymJUD9DgUSgjvqAKDLRGrSuomoXi42OWywzi3heq2LgsJFm6BeMU9tilTXDN6AjiN+47OTY4FX8twUiRci+wPRTWp5eSy1utoQf/VW6PRisFVt0z2D7ZBEFLMYrJuAqQhSrEDxvLQqVF5h4h6tXHAlSsinLp0jXYdcM0v6MGzMUSaQOxWjNrBeTdM6TIh7YWdpoC1msHxh+N939ru0Q0Nt/d2sy8oRqVsXh6JxIP/QTpyR5d5qNk10nOj2LojA4sfnJZTALEFFYp1gfYNmbU3O4QW0Qye0PnZ6nnhJ+ox6dCN8yuL+Ci8hMxPMzvVYeZ5Am8wZ7feeFeWpClMdW2sm3koGj4+M60BMs9SOfDuBAK22t2sD6ShP3xRI7MEbsOzMkJNizVqira55YQWUn6aLBMOW90ghD5J7QW77ih3r4oq60OGUX3yc9hlJnvgBblYL1KRVtPgawUelK3Q3EoKAok6YjA==
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: openweathermap-api-key
|
||||
name: mysecret
|
||||
namespace: default
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
apiVersion: bitnami.com/v1alpha1
|
||||
kind: SealedSecret
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: openweathermap-api-key
|
||||
namespace: temperature-cronjob-helm
|
||||
spec:
|
||||
encryptedData:
|
||||
openweathermap-api-key: AgABEOpp8H1O51kQsDZnCW1rjTYeDNCwJMn/TMC/UMQi8WfngR2lHRevbTQ3sRgcGvBghsH2kfcrU6unO9XjprIOJ6DG7HQ3uKuKGrkG18eQHQtb0GY4nw9LO8scp8dBYYxyjLhHWVXnTof7HYKSDq2LLKZ5XstNh+th2D5UyI1flCJxKBJqqHVX7L0FNdKamGqhMr4FJ9dJ0ATFuOhwkjGHq6POe5WO6/pJR9zYlkvy4ViEJ3M+YbUlnEcPD62FloV5uQ9+BhhLYIxV9dPSH3XF4eW5vZF+enFRWSJuU55JIac858DRqNgVnuJCrilcoIeOch3kzFdJCo7Pqr+VMtcsjmdDtXIDR5EYOB1aZIFZn+HTxjoiMDJpr/Yrm2HXNSukIBES1im7Rb6icJoFicG7uirVvcv8NtlF9y3Mnv+3n4yYQ8xXTXX8yfTyOVws3/JVOuDJNbuvwBHvZLnCndIooCRYYDLaVybGeDcLUj3pScTSvAtJqmfEmXS7PzlhumajhZaHUnJ9gAUObEolI9RI62CgctE4HbIFcragbeLbgAhjkKLB4fY+oNDeYW2uqI1pla5GE0yMgfPg63ykKI70pxnneQFUCbpLpw4ZVqzaMt1Rz1FnUN6nG0+IxZtmcUT1/PC1f/MexQzRIT7Y03zU+qBIdEGogktm0u3heGKFfBPaWFV/6nshN8jGzliOgXd4erwb264QH7WPg+UeH4+YQhT+JKrNVg6Dfy3SSpM87Q==
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: openweathermap-api-key
|
||||
namespace: temperature-cronjob-helm
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# values.yaml
|
||||
image:
|
||||
repository: python
|
||||
tag: "3.9-slim"
|
||||
tag: "fails-to-pull"
|
||||
pullPolicy: IfNotPresent
|
||||
schedule: "*/1 * * * *" # Every minute
|
||||
city: "Dunlap, US"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue