apiVersion: v1
kind: Service
metadata:
  name: vm-proxy
  namespace: home-apps
spec:
  ports:
  - port: 8000
    targetPort: 8000
  selector:
    app: vm-proxy
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: vm-proxy
spec:
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: vm-proxy
  replicas: 1
  template:
    metadata:
      labels:
        app: vm-proxy
    spec:
      containers:
      - name: vm-proxy
        image: alpine/socat
        args:
          - "tcp-listen:8000,fork,reuseaddr"
          - "tcp-connect:192.168.1.56:443"
        ports:
        - containerPort: 8000
        resources:
          limits:
            cpu: "0.2"
            memory: "256Mi"
          requests:
            cpu: "0.1"
            memory: "128Mi"
---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vm-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    kubernetes.io/tls-acme: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/auth-url: "https://pass.junv.cc/oauth2/auth"
    nginx.ingress.kubernetes.io/auth-signin: "https://pass.junv.cc/oauth2/start?rd=https://$host$escaped_request_uri"
spec:
  tls:
  - hosts:
    - vm.junv.me
    secretName: vm-tls
  rules:
  - host: vm.junv.me
    http:
      paths:
      - backend:
          service:
            name: vm-proxy
            port:
              number: 8000
        path: /
        pathType: Prefix
