diff --git a/photoview/deployment.yaml b/photoview/deployment.yaml new file mode 100644 index 0000000..98673c8 --- /dev/null +++ b/photoview/deployment.yaml @@ -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: {} + diff --git a/photoview/docker-compose.yml b/photoview/docker-compose.yml index 8ef3262..9d36d61 100644 --- a/photoview/docker-compose.yml +++ b/photoview/docker-compose.yml @@ -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= 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: diff --git a/photoview/job.yaml b/photoview/job.yaml new file mode 100644 index 0000000..3168538 --- /dev/null +++ b/photoview/job.yaml @@ -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 diff --git a/photoview/justfile b/photoview/justfile new file mode 100644 index 0000000..c48d360 --- /dev/null +++ b/photoview/justfile @@ -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 diff --git a/photoview/make_job.py b/photoview/make_job.py new file mode 100644 index 0000000..15908ae --- /dev/null +++ b/photoview/make_job.py @@ -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) diff --git a/photoview/photoview-k8s.png b/photoview/photoview-k8s.png new file mode 100644 index 0000000..a0ecbf8 Binary files /dev/null and b/photoview/photoview-k8s.png differ