---
# Let's Encrypt Cluster Issuer
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-production
spec:
  acme:
    email: "{YOUR EMAIL ADDRESS}"
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:
      name: letsencrypt-production-account-key
    solvers:
    - http01:
        ingress:
          class: nginx
---
apiVersion: v1
kind: Namespace
metadata:
  name: jhe

---
# Ingress with Let's Encrypt
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jhe-ingress
  namespace: jhe
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-production
    cert-manager.io/acme-challenge-type: http01
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - "{PUBLIC HOSTNAME OF YOUR JUPYTERHEALTH EXCHANGE APP}"
    secretName: jhe-tls
  rules:
  - host: "{PUBLIC HOSTNAME OF YOUR JUPYTERHEALTH EXCHANGE APP}"
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: jhe
            port:
              number: 8000
---
apiVersion: v1
kind: Service
metadata:
  name: jhe
  namespace: jhe
spec:
  type: ClusterIP
  selector:
    app: jhe
  ports:
    - port: 8000
      targetPort: 8000
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: jhe-config
  namespace: jhe
data:
  SITE_TITLE: "JupyterHealth Exchange"
  REGISTRATION_INVITE_CODE: "{SECRET INVITE CODE}"
  SITE_URL: "{PUBLIC HOSTNAME OF YOUR JUPYTERHEALTH EXCHANGE APP}"
  OIDC_CLIENT_AUTHORITY_PATH: "/o/"
  OIDC_CLIENT_REDIRECT_URI_PATH: "/auth/callback"
  OIDC_CLIENT_ID: ""
  CH_INVITATION_LINK_PREFIX: "https://play.google.com/store/apps/details?id=org.thecommonsproject.android.phr.dev&referrer=cloud_sharing="
  DB_NAME: ""
  DB_USER: ""
  DB_PASSWORD: ""
  DB_HOST: ""
  DB_PORT: "5432"
  OIDC_RSA_PRIVATE_KEY: |
    -----BEGIN RSA PRIVATE KEY-----
    ...
    -----END RSA PRIVATE KEY-----
  PATIENT_AUTHORIZATION_CODE_CHALLENGE: ""
  PATIENT_AUTHORIZATION_CODE_VERIFIER: ""
---
apiVersion : apps/v1
kind : Deployment
metadata :
  name : jhe
  namespace: jhe
spec :
  replicas : 1
  selector :
    matchLabels :
      app : jhe
  template :
    metadata :
      labels :
        app : jhe
    spec :
      containers :
      - name : jhe
        image : ryanlovett/jupyterhealth-exchange:e870031
        ports :
          - containerPort : 8000
        envFrom:
        - configMapRef:
            name: jhe-config
