apiVersion: apps/v1
kind: Deployment
metadata:
  name: plex
spec:
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: plex
  replicas: 1
  template:
    metadata:
      labels:
        app: plex
    spec:
      imagePullSecrets:
        - name: regcred
      containers:
        - name: plex-proxy
          image: alpine/socat
          args:
            - "tcp-listen:80,fork,reuseaddr"
            - "tcp-connect:192.168.1.11:32400"
          resources:
            requests:
              cpu: 50m
              memory: 126Mi
            limits:
              cpu: 100m
              memory: 256Mi
          ports:
            - containerPort: 80
              name: plex-port

---
apiVersion: v1
kind: Service
metadata:
  name: plex
  labels:
    app: plex
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: plex-port
      protocol: TCP
  selector:
    app: plex
---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: plex-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    kubernetes.io/tls-acme: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - plex.junv.me
    secretName: plex-tls
  rules:
  - host: plex.junv.me
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: plex
            port:
              number: 80
