k8 kompose photoview
This commit is contained in:
parent
b3219b2b95
commit
2fb1980e28
6 changed files with 350 additions and 26 deletions
255
photoview/deployment.yaml
Normal file
255
photoview/deployment.yaml
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.service.expose: photoview.wayl.one
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview
|
||||
name: photoview
|
||||
namespace: photoview
|
||||
spec:
|
||||
ports:
|
||||
- name: "80"
|
||||
port: 80
|
||||
targetPort: 80
|
||||
selector:
|
||||
io.kompose.service: photoview
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview-db
|
||||
name: photoview-db
|
||||
namespace: photoview
|
||||
spec:
|
||||
ports:
|
||||
- name: "3306"
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
selector:
|
||||
io.kompose.service: photoview-db
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: photoview
|
||||
namespace: photoview
|
||||
spec: {}
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.service.expose: photoview.wayl.one
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview
|
||||
name: photoview
|
||||
namespace: photoview
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
io.kompose.service: photoview
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.service.expose: photoview.wayl.one
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.network/proxy: "true"
|
||||
io.kompose.service: photoview
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: PHOTOVIEW_DATABASE_DRIVER
|
||||
value: mysql
|
||||
- name: PHOTOVIEW_LISTEN_IP
|
||||
value: photoview
|
||||
- name: PHOTOVIEW_LISTEN_PORT
|
||||
value: "80"
|
||||
- name: PHOTOVIEW_MEDIA_CACHE
|
||||
value: /app/cache
|
||||
- name: PHOTOVIEW_MYSQL_URL
|
||||
value: photoview:photosecret@tcp(photoview-db)/photoview
|
||||
- name: TZ
|
||||
value: America/Chicago
|
||||
image: viktorstrate/photoview:2
|
||||
name: photoview
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
volumeMounts:
|
||||
- mountPath: /app/cache
|
||||
name: photoview-cache
|
||||
- mountPath: /photos
|
||||
name: photoview
|
||||
restartPolicy: Always
|
||||
volumes:
|
||||
- name: photoview-cache
|
||||
persistentVolumeClaim:
|
||||
claimName: photoview-cache
|
||||
- name: photoview
|
||||
persistentVolumeClaim:
|
||||
claimName: photoview
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.service.expose: photoview.wayl.one
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview
|
||||
name: photoview
|
||||
namespace: photoview
|
||||
spec:
|
||||
rules:
|
||||
- host: photoview.wayl.one
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: photoview
|
||||
port:
|
||||
number: 80
|
||||
path: /
|
||||
pathType: Prefix
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview-cache
|
||||
name: photoview-cache
|
||||
namespace: photoview
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 100Mi
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview
|
||||
name: photoview
|
||||
namespace: photoview
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 100Mi
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview-db
|
||||
name: photoview-db
|
||||
namespace: photoview
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
io.kompose.service: photoview-db
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: kompose convert -o deployment.yaml -n photoview
|
||||
kompose.version: 1.31.2 (a92241f79)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.network/proxy: "true"
|
||||
io.kompose.service: photoview-db
|
||||
spec:
|
||||
containers:
|
||||
- env:
|
||||
- name: MYSQL_DATABASE
|
||||
value: photoview
|
||||
- name: MYSQL_PASSWORD
|
||||
value: photosecret
|
||||
- name: MYSQL_RANDOM_ROOT_PASSWORD
|
||||
value: photoview
|
||||
- name: MYSQL_USER
|
||||
value: photoview
|
||||
image: mariadb:10.5
|
||||
name: photoview-db
|
||||
ports:
|
||||
- containerPort: 3306
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/mysql
|
||||
name: photoview-db-data
|
||||
restartPolicy: Always
|
||||
volumes:
|
||||
- name: photoview-db-data
|
||||
persistentVolumeClaim:
|
||||
claimName: photoview-db-data
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: photoview-db-data
|
||||
name: photoview-db-data
|
||||
namespace: photoview
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 100Mi
|
||||
status: {}
|
||||
|
||||
|
|
@ -4,30 +4,29 @@ services:
|
|||
photoview-db:
|
||||
image: mariadb:10.5
|
||||
container_name: photoview-db
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
networks:
|
||||
- proxy
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- db_data:/var/lib/mysql
|
||||
- photoview-db-data:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_DATABASE=${PHOTOVIEW_MYSQL_DATABASE}
|
||||
- MYSQL_USER=${PHOTOVIEW_MYSQL_USER}
|
||||
- MYSQL_RANDOM_ROOT_PASSWORD=${PHOTOVIEW_MYSQL_RANDOM_ROOT_PASSWORD}
|
||||
- MYSQL_PASSWORD=${PHOTOVIEW_MYSQL_PASSWORD}
|
||||
- MYSQL_DATABASE=photoview
|
||||
- MYSQL_USER=photoview
|
||||
- MYSQL_RANDOM_ROOT_PASSWORD=photoview
|
||||
- MYSQL_PASSWORD=photosecret
|
||||
ports:
|
||||
- 3306
|
||||
|
||||
photoview:
|
||||
image: viktorstrate/photoview:2
|
||||
container_name: photoview
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
networks:
|
||||
- proxy
|
||||
# ports:
|
||||
# - "8101:80"
|
||||
ports:
|
||||
- 80
|
||||
depends_on:
|
||||
- photoview-db
|
||||
|
||||
|
|
@ -37,6 +36,7 @@ services:
|
|||
- PHOTOVIEW_LISTEN_IP=photoview
|
||||
- PHOTOVIEW_LISTEN_PORT=80
|
||||
- PHOTOVIEW_MEDIA_CACHE=/app/cache
|
||||
- TZ=America/Chicago
|
||||
|
||||
# Optional: If you are using Samba/CIFS-Share and experience problems with "directory not found"
|
||||
# Enable the following Godebug
|
||||
|
|
@ -48,32 +48,22 @@ services:
|
|||
# - MAPBOX_TOKEN=<YOUR TOKEN HERE>
|
||||
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- api_cache:/app/cache
|
||||
- photoview-cache:/app/cache
|
||||
|
||||
# Change This: to the directory where your photos are located on your server.
|
||||
# If the photos are located at `/home/user/photos`, then change this value
|
||||
# to the following: `/home/user/photos:/photos:ro`.
|
||||
# You can mount multiple paths, if your photos are spread across multiple directories.
|
||||
- /tank/syncthing/config:/photos:ro
|
||||
- photoview:/photos
|
||||
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.photoview.entrypoints=http"
|
||||
- "traefik.http.routers.photoview.rule=Host(`photoview.${URL}`)"
|
||||
- "traefik.http.middlewares.photoview-https-redirect.redirectscheme.scheme=https"
|
||||
- "traefik.http.routers.photoview.middlewares=photoview-https-redirect"
|
||||
- "traefik.http.routers.photoview-secure.entrypoints=https"
|
||||
- "traefik.http.routers.photoview-secure.rule=Host(`photoview.${URL}`)"
|
||||
- "traefik.http.routers.photoview-secure.tls=true"
|
||||
- "traefik.http.routers.photoview-secure.service=photoview"
|
||||
- "traefik.http.services.photoview.loadbalancer.server.port=80"
|
||||
- "traefik.docker.network=proxy"
|
||||
kompose.service.expose: photoview.wayl.one
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
api_cache:
|
||||
photoview-db-data:
|
||||
photoview-cache:
|
||||
photoview:
|
||||
|
|
|
|||
14
photoview/job.yaml
Normal file
14
photoview/job.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: myjob
|
||||
spec:
|
||||
ttlSecondsAfterFinished: 100
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: myjobcontainer
|
||||
image: busybox
|
||||
command: ["ls", "/"]
|
||||
restartPolicy: Never
|
||||
backoffLimit: 1
|
||||
31
photoview/justfile
Normal file
31
photoview/justfile
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
default: cred convert deploy viz
|
||||
update: convert patch
|
||||
|
||||
create-ns:
|
||||
kubectl create ns photoview
|
||||
cred:
|
||||
kubectl get secret -n default regcred --output=yaml -o yaml | sed 's/namespace: default/namespace: photoview/' | kubectl apply -n photoview -f - && echo deployed secret || echo secret exists
|
||||
convert:
|
||||
kompose convert -o deployment.yaml -n photoview
|
||||
deploy:
|
||||
kubectl apply -f deployment.yaml
|
||||
delete:
|
||||
kubectl delete all --all -n photoview --timeout=0s
|
||||
viz:
|
||||
k8sviz -n photoview --kubeconfig $KUBECONFIG -t png -o photoview-k8s.png
|
||||
restart:
|
||||
kubectl rollout restart -n photoview deployment/photoview
|
||||
|
||||
patch:
|
||||
kubectl patch -f deployment.yaml
|
||||
describe:
|
||||
kubectl get deployment -n photoview
|
||||
kubectl get rs -n photoview
|
||||
kubectl get pod -n photoview
|
||||
kubectl get svc -n photoview
|
||||
kubectl get ing -n photoview
|
||||
|
||||
describe-pod:
|
||||
kubectl describe pod -n photoview
|
||||
logs:
|
||||
kubectl logs --all-containers -l io.kompose.service=photoview-wayl-one -n photoview -f
|
||||
34
photoview/make_job.py
Normal file
34
photoview/make_job.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from kubernetes import client, config
|
||||
|
||||
# Load the default kubeconfig
|
||||
config.load_kube_config()
|
||||
|
||||
# Define the API client for batch jobs
|
||||
api_instance = client.BatchV1Api()
|
||||
|
||||
# Create a new job object
|
||||
job = client.V1Job(
|
||||
api_version="batch/v1",
|
||||
kind="Job",
|
||||
metadata=client.V1ObjectMeta(name="myjob"),
|
||||
spec=client.V1JobSpec(
|
||||
ttl_seconds_after_finished=100,
|
||||
template=client.V1PodTemplateSpec(
|
||||
metadata=client.V1ObjectMeta(labels={"app": "myjob"}),
|
||||
spec=client.V1PodSpec(
|
||||
containers=[
|
||||
client.V1Container(
|
||||
name="myjobcontainer",
|
||||
image="busybox",
|
||||
command=["ls", "/"],
|
||||
),
|
||||
],
|
||||
restart_policy="Never",
|
||||
),
|
||||
),
|
||||
backoff_limit=1,
|
||||
),
|
||||
)
|
||||
|
||||
# Call the Kubernetes API to create the job
|
||||
api_instance.create_namespaced_job(namespace="default", body=job)
|
||||
BIN
photoview/photoview-k8s.png
Normal file
BIN
photoview/photoview-k8s.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 122 KiB |
Loading…
Add table
Add a link
Reference in a new issue