apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: sshd
  name: sshd
spec:
  type: NodePort
  ports:
    - name: "30022"
      port: 30022
      nodePort: 30022
      targetPort: 2222
  selector:
    io.kompose.service: sshd
status:
  loadBalancer: {}

---
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: nginx
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: nginx
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.network/www-default: "true"
        io.kompose.service: nginx
    spec:
      containers:
        - args:
            - -c
            - |
                rm -rf /usr/share/nginx/html && ln -s /sites /usr/share/nginx/html && chmod 777 /sites
                sed -i "/.*# GENERATED.*/d" /etc/nginx/conf.d/default.conf
                sed -i "/.*root   \/usr\/share\/nginx\/html;.*/a    autoindex on; # GENERATED\n    autoindex_exact_size off; # GENERATED\n    autoindex_localtime on; # GENERATED\n    error_page 404 \/index.html; # GENERATED\n" /etc/nginx/conf.d/default.conf
                nginx -g "daemon off;"
          command:
            - sh
          env:
            - name: NGINX_HOST
              value: 0.0.0.0
            - name: NGINX_PORT
              value: "80"
          image: nginx:stable-alpine
          name: nginx
          ports:
            - containerPort: 80
          resources: {}
          volumeMounts:
            - mountPath: /sites
              name: sites
      restartPolicy: Always
      volumes:
        - name: sites
          persistentVolumeClaim:
            claimName: sites
status: {}

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: sites
  name: sites
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}

---
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: sshd
  name: sshd
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: sshd
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.network/www-default: "true"
        io.kompose.service: sshd
    spec:
      containers:
        - env:
            - name: PASSWORD_ACCESS
              value: "true"
            - name: USER_NAME
              value: ${SSH_USER}
            - name: USER_PASSWORD
              value: ${SSH_PASSWORD}
            - name: PUBLIC_KEY_FILE
              value: /root/.ssh/authorized_keys
          image: linuxserver/openssh-server
          name: sshd
          ports:
            - containerPort: 2222
          resources: {}
          volumeMounts:
          - mountPath: /sites
            name: sites
          - name: authorized_keys
            mountPath: /root/.ssh/
      restartPolicy: Always
      volumes:
        - name: sites
          persistentVolumeClaim:
            claimName: sites
        - name: authorized_keys
          configMap:
            name: authorized_keys
status: {}

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: authorized_keys
data:
  authorized_keys: |
    ${PUBLIC_KEY_FILE}