diff --git a/.gitignore b/.gitignore index 4e2da4c0..6edaceaa 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ package-lock.json .env docker-push.sh docker-compose.yml +output +env.txt + diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 00000000..a44d646b --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,49 @@ +# Kubernetes deployment + +## TLDR; and do not care way +``` +make +sed -i s/localhost/myshinydomain.tld/g env.txt +make prepare +make deployment +``` + +# Understanding way +If you would like to deploy Mirotalk to kubernetes +this set of files can help you in that task + +Bellow is explanation of files in this folder which will form one output file in `output` folder +## ../.env.template and your file env.txt that you should prepare +Configuration file that is for now used to configure deployment +you should copy `../.env.template` to current directory as `env.txt` and edit values inside to your liking +``` +cp ../.env.template env.txt +``` +Change values (if nothing else **HOST** variable must be changed so your ingress would recognize it and work as) +``` +sed -i s/localhost/myshinydomain.tld/g env.txt +``` + +## p2p-deployment.yaml +Main deployment file where you change image file if you would like to use yours if not official one (`image`: tag) + +## p2p-cert.yaml +This file represent definition of certificate (request) when using [Cert Manager](cert-manager.io) to generate letsencrypt or private certificates for your domain will be pulled out from `env.txt` +## p2p-ingress.yaml +This is generic ingress object in kubernetes that is responsible to route external traffic to mirotalk deployed application and if used in conjuction with p2p-cert.yaml (default) will provide TLS enabled access to your mirotalk instance +## p2p-service.yaml +Service required for ingress to be able to know how to access deployment +## Makefile +Helper file that allows running it to configure application how you would like + +after creating and changing configuration file (`env.txt`) run these two tasks, prepare will create deployment file +and deployment will create configMap from prepared `env.txt` file. + +Please run after reading all this: + +``` +make +# edit env.txt or use sed as in TLDR section :) +make prepare +make deployment +``` diff --git a/kubernetes/p2p-cert.yaml b/kubernetes/p2p-cert.yaml new file mode 100644 index 00000000..8afea9b7 --- /dev/null +++ b/kubernetes/p2p-cert.yaml @@ -0,0 +1,15 @@ +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: __DOMAIN_NAME_DASHED__-tls +spec: + duration: 2880h # 180d + renewBefore: 360h # 15d + commonName: __DOMAIN_NAME__ + dnsNames: + - __DOMAIN_NAME__ + issuerRef: + kind: ClusterIssuer + name: letsencrypt + secretName: __DOMAIN_NAME_DASHED__-tls + diff --git a/kubernetes/p2p-deployment.yaml b/kubernetes/p2p-deployment.yaml new file mode 100644 index 00000000..e5e5a1e7 --- /dev/null +++ b/kubernetes/p2p-deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: p2p + name: p2p +spec: + replicas: 1 + selector: + matchLabels: + app: p2p + strategy: {} + template: + metadata: + labels: + app: p2p + spec: + containers: + - image: mirotalk/p2p:latest + name: mirotalk + ports: + - containerPort: 3000 + volumeMounts: + - name: p2p-env + mountPath: /src/.env + subPath: .env + resources: {} + volumes: + - name: p2p-env + configMap: + name: p2p + defaultMode: 0644 + restartPolicy: Always +status: {} diff --git a/kubernetes/p2p-ingress.yaml b/kubernetes/p2p-ingress.yaml new file mode 100644 index 00000000..416d5d1d --- /dev/null +++ b/kubernetes/p2p-ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: List +metadata: + resourceVersion: "" +items: +- apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + name: p2p-ingress + spec: + rules: + - host: __DOMAIN_NAME__ + http: + paths: + - backend: + service: + name: p2p + port: + number: 3000 + path: / + pathType: Prefix + tls: + - hosts: + - __DOMAIN_NAME__ + secretName: __DOMAIN_NAME_DASHED__-tls + status: diff --git a/kubernetes/p2p-service.yaml b/kubernetes/p2p-service.yaml new file mode 100644 index 00000000..fa8d7685 --- /dev/null +++ b/kubernetes/p2p-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: p2p + name: p2p +spec: + ports: + - name: "3000" + port: 3000 + targetPort: 3000 + selector: + app: p2p +status: + loadBalancer: {}