├── .helmignore ├── Chart.yaml ├── LICENSE ├── README.md ├── README.md.gotmpl ├── templates ├── NOTES.txt ├── _helpers.tpl ├── hpa.yaml ├── ingress.yaml ├── lb-networkpolicy.yaml ├── plex-unicornlb-deployment.yaml ├── secrets.yaml ├── service.yaml ├── serviceaccount.yaml ├── storage.yaml ├── trancoder-controller.yaml └── transcoder-set.yaml └── values.yaml /.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: unicorn-plex 3 | description: A Helm chart for deploying UnicornTranscoder on Kubernetes with the ability to automatically scale the transcoders as CPU load increases. 4 | home: https://github.com/Unicorn-K8s/UnicornTrancoder-chart 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | version: 0.1.0 18 | 19 | # This is the version number of the application being deployed. This version number should be 20 | # incremented each time you make changes to the application. 21 | appVersion: 0.1.0 22 | 23 | dependencies: 24 | - name: MetaC 25 | version: latest 26 | repository: https://github.com/AmitKumarDas/metac/tree/master/helm/metac 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Unicorn Transcoder on K8s 2 | ========================= 3 | A Helm chart for deploying UnicornTranscoder on Kubernetes with the ability to automatically scale the transcoders as CPU load increases. 4 | 5 | Current chart version is `0.1.0` 6 | 7 | Source code can be found [here](https://github.com/Unicorn-K8s/UnicornTrancoder-chart) 8 | 9 | ## Chart Requirements 10 | 11 | | Repository | Name | Version | 12 | |------------|------|---------| 13 | | https://github.com/AmitKumarDas/metac/tree/master/helm/metac | MetaC | latest | 14 | 15 | ## Chart Values 16 | 17 | | Key | Type | Default | Description | 18 | |-----|------|---------|-------------| 19 | | XPlexToken | string | `nil` | X-Plex-Token for your server See: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ for guide to find it after creating the server | 20 | | affinity.unicornLoadbalancer | object | `{}` | | 21 | | affinity.unicornTranscoder | object | `{}` | | 22 | | claimToken | string | `nil` | Generated token for automatically adding a server under your Plex account See: https://plex.tv/claim to generate one Note: Token is only valid for 4 minutes | 23 | | data.plexConfig.accessMode | string | `"ReadWriteOnce"` | | 24 | | data.plexConfig.claimName | string | `"plex-config-pvc"` | Name of already existing PVC used to store the configuration data for plex If claimName is defined then the storage class and size are ignored | 25 | | data.plexConfig.size | string | `"60Gi"` | Size of the created PVC If claimName is defined then this is ignored | 26 | | data.plexDB.accessMode | string | `"ReadWriteOnce"` | | 27 | | data.plexDB.claimName | string | `"plex-db-pvc"` | Name of already existing PVC used as long term storage for the Plex SQLite Database If claimName is defined then the storage class and size are ignored | 28 | | data.plexDB.size | string | `"10Gi"` | Size of the created PVC If claimName is defined then this is ignored | 29 | | data.plexMedia.accessMode | string | `"ReadWriteOnce"` | | 30 | | data.plexMedia.claimName | string | `"tv-movies-pvc"` | Name of already existing PVC that holds all of the media for Plex If claimName is defined then the storage class and size are ignored | 31 | | data.plexMedia.size | string | `"100Gi"` | Size of the created PVC If claimName is defined then this is ignored | 32 | | data.transcoding.claimName | string | `nil` | Name of already existing PVC to be used by the trancoders to use while transcoding media If claimName is defined then the storage class and size are ignored Claim must be fore a ReadWriteMany PVC | 33 | | data.transcoding.size | string | `"120Gi"` | Size of the created PVC If claimName is defined then this is ignored | 34 | | data.transcoding.storageClass | string | `"hostpath"` | Name of Storage Class to use to create the transcoding PVC | 35 | | imagePullSecrets | list | `[]` | | 36 | | ingress.annotations | object | `{"cert-manager.io/cluster-issuer":"letsencrypt-prod","kubernetes.io/ingress.class":"nginx","kubernetes.io/tls-acme":"true","nginx.ingress.kubernetes.io/configuration-snippet":"more_set_input_headers \"Referer: localhost\" ;\nmore_set_input_headers \"Origin: localhost\" ;\n","nginx.ingress.kubernetes.io/proxy-buffering":"off","nginx.ingress.kubernetes.io/proxy-http-version":"1.1","nginx.ingress.kubernetes.io/proxy-redirect-from":"http://localhost$request_uri","nginx.ingress.kubernetes.io/proxy-redirect-to":"$scheme://plex.mydomain.tld$request_uri","nginx.ingress.kubernetes.io/upstream-vhost":"localhost"}` | Any annotations to add to the Plex Ingress | 37 | | ingress.enabled | bool | `true` | Use Kubernetes Ingress to access plex | 38 | | ingress.host | string | `"plex.jeansburger.net"` | Domain name to use for ingress to plex | 39 | | ingress.tls.host | string | `"plex.jeansburger.net"` | Domain name to use on the TLS Certifcate | 40 | | ingress.tls.secretName | string | `"plex-tls"` | Name of secret to hold TLS Certifcate | 41 | | nodeSelector.unicornLoadbalancer | object | `{}` | | 42 | | nodeSelector.unicornTranscoder | object | `{}` | | 43 | | plex.pullPolicy | string | `"IfNotPresent"` | Image pull policy | 44 | | plex.repository | string | `"plexinc/pms-docker"` | Repository hosting the Plex Media Server image Currently only Official PlexInc image is supported | 45 | | plex.tag | string | `"1.19.1.2645-ccb6eb67e"` | Plex Sever Version Should be set to the current version supported by the UnicornTranscoder Project | 46 | | plexAdvertiseIPs | list | `[]` | List of IPs or FQDNs with ports to be set in the Advertise IPs section of your server | 47 | | plexDBBackup.pullPolicy | string | `"IfNotPresent"` | Image pull policy | 48 | | plexDBBackup.repository | string | `"donicrosby/unicorn-plex-sqlite-streamer"` | Repository hosting Unicorn Plex SQLite Streamer image | 49 | | plexDBBackup.tag | string | `"0.1.1"` | SQLite Streamer image tag | 50 | | plexGID | int | `100` | (int) GID to be set for the Plex Server and UnicornTranscoder for accessing media | 51 | | plexHostname | string | `"Unicorn-Plex-K8s"` | Frendly name for your Plex Server | 52 | | plexUID | int | `1000` | (int) UID to be set for the Plex Server and UnicornTranscoder for accessing media | 53 | | podSecurityContext | object | `{}` | | 54 | | resources.requests.cpu | int | `2` | Number of CPU cores to allocate for the Plex Media Server | 55 | | resources.requests.memory | string | `"2Gi"` | Amount of Memory to allocate for the Plex Media Server | 56 | | resources.unicornLoadbalancer.requests.cpu | string | `"500m"` | Amount of CPU cores to allocate for the Unicorn LoadBalancer | 57 | | resources.unicornLoadbalancer.requests.memory | string | `"500Mi"` | Amount of memory to allocate for the Unicorn Loadbalancer | 58 | | resources.unicornTranscoder.requests.cpu | int | `4` | Amount of CPU cores to allocate for the Unicorn Transcoder | 59 | | resources.unicornTranscoder.requests.memory | string | `"4Gi"` | Amount of memory to allocate for the Unicorn Transcoder | 60 | | securityContext | object | `{}` | | 61 | | service.advertiseWithService | bool | `false` | Add the LoadBalancer IP and port to the Advertise IPs List | 62 | | service.annotations | object | `{"metallb.universe.tf/allow-shared-ip":"unicorn-plex"}` | Any annotations to be added to the LoadBalancer | 63 | | service.loadbalancerIP | string | `"172.16.4.5"` | IP to be used by the loadbalancer (Recommended to be hardcoded) | 64 | | service.port | int | `3001` | Port to be used for Ingress of the LoadBalancer | 65 | | service.type | string | `"LoadBalancer"` | Service type to be used to expose the UnicornLoadbalancer (and Plex) Currently only LoadBalancer is supported | 66 | | serviceAccount.create | bool | `false` | | 67 | | serviceAccount.name | string | `nil` | | 68 | | timezone | string | `"Etc/UTC"` | Timezone to be set for the server See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for list | 69 | | tolerations.unicornLoadbalancer | list | `[]` | | 70 | | tolerations.unicornTranscoder | list | `[]` | | 71 | | transcoding.hpa | bool | `true` | (bool) Determine if chart should deploy a Horizontal Pod Autoscaler for the UnicornTranscoders | 72 | | transcoding.hpaCPUPercent | int | `50` | (int) Percentage of requested CPUs over all UnicornTranscoder Pods for the to be utilized before a new UnicornTranscoder pod is created | 73 | | transcoding.maxReplicas | int | `16` | (int) Maximum number of replicas to be created by the HPA Note: This is ignored if transcoding.hpa is set to false | 74 | | transcoding.port | int | `443` | (int) Port to be used by the created transcoding services | 75 | | transcoding.replicas | int | `4` | (int) Number of replicas to be created by the Transcoder StatefulSet | 76 | | transcoding.transcodeDomain | string | `"plex.mydomain.tld"` | | 77 | | unicornLoadbalancer.pullPolicy | string | `"IfNotPresent"` | Image pull policy | 78 | | unicornLoadbalancer.repository | string | `"donicrosby/unicorn-loadbalancer"` | Repository hosting UnicornLoadbalancer image | 79 | | unicornLoadbalancer.tag | string | `"2.4.3"` | UnicornLoadbalancer version Should be inline with most recent version of UnicornLoadbalancer version | 80 | | unicornTranscoder.pullPolicy | string | `"IfNotPresent"` | Image pull policy | 81 | | unicornTranscoder.repository | string | `"donicrosby/unicorn-transcoder"` | Repository hosting UnicornTranscoder image | 82 | | unicornTranscoder.tag | string | `"2.4.2"` | UnicornTranscoder version | 83 | 84 | ## Deploying this chart 85 | 86 | ### Prerequisites 87 | In order to use this chart you must have at least the following installed on your cluster: 88 | + MetaC (A fork of Google Metacontroller Project) found [here](https://github.com/AmitKumarDas/metac/tree/master/helm/metac) 89 | + Favorite flavor of Ingress controller installed (This project currently uses Ingress Nginx) 90 | + Have CertBot or another ACME Protocol operator to generate TLS certificates 91 | + MetalLB if this a baremetal installation the current chart for it can be found [here](https://github.com/helm/charts/tree/master/stable/metallb) 92 | + Have a plex claim token for the account you are adding the server to (Get one from https://plex.tv/claim) 93 | 94 | ### Installation 95 | + Go into the values.yaml and using the Values section above an update to your configuration (be sure to update the ingress.annotations proxy-redirect-to value to your domain) 96 | + Verify that the plex server/loadbalancer pod is running 97 | + Verify you can access your Plex Server externally from the domain you used for Ingress 98 | + Follow the guide [here](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/) in order find you X-Plex-Token update your values.yaml to use the new X-Plex-Token 99 | + Perform a helm update with your new values.yaml in order to deploy the X-Plex-Token secret for your Transcoders (You may need to wipe them out in order get the token to be updated) 100 | + Verify you can play a video from the Plex server 101 | 102 | If you have any issues please use open an issue so one of the chart maintainers can help you debug it 103 | 104 | ### External/Extra Configuration 105 | #### Reverse Proxy Setup/Configuration 106 | If you have a reverse proxy on your router (or your router is set to port forward 80/443 to one) you need to accept and proxy these domains to your Plex K8s Cluster: 107 | + plex.yourdomain.tld 108 | + *project-name*-transcoder-*number*.yourtranscodedomain.tld 109 | 110 | If your plex domain is the same as your transcode domain you can use the following regex: 111 | (?:.+\.)?plex.yourdomain.tld 112 | -------------------------------------------------------------------------------- /README.md.gotmpl: -------------------------------------------------------------------------------- 1 | Unicorn Transcoder on K8s 2 | ========================= 3 | {{ template "chart.description" . }} 4 | 5 | {{ template "chart.versionLine" . }} 6 | 7 | {{ template "chart.sourceLinkLine" . }} 8 | 9 | {{ template "chart.requirementsSection" . }} 10 | 11 | {{ template "chart.valuesSection" . }} 12 | 13 | ## Deploying this chart 14 | 15 | ### Prerequisites 16 | In order to use this chart you must have at least the following installed on your cluster: 17 | + MetaC (A fork of Google Metacontroller Project) found [here](https://github.com/AmitKumarDas/metac/tree/master/helm/metac) 18 | + Favorite flavor of Ingress controller installed (This project currently uses Ingress Nginx) 19 | + Have CertBot or another ACME Protocol operator to generate TLS certificates 20 | + MetalLB if this a baremetal installation the current chart for it can be found [here](https://github.com/helm/charts/tree/master/stable/metallb) 21 | + Have a plex claim token for the account you are adding the server to (Get one from https://plex.tv/claim) 22 | 23 | ### Installation 24 | + Go into the values.yaml and using the Values section above an update to your configuration (be sure to update the ingress.annotations proxy-redirect-to value to your domain) 25 | + Verify that the plex server/loadbalancer pod is running 26 | + Verify you can access your Plex Server externally from the domain you used for Ingress 27 | + Follow the guide [here](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/) in order find you X-Plex-Token update your values.yaml to use the new X-Plex-Token 28 | + Perform a helm update with your new values.yaml in order to deploy the X-Plex-Token secret for your Transcoders (You may need to wipe them out in order get the token to be updated) 29 | + Verify you can play a video from the Plex server 30 | 31 | If you have any issues please use open an issue so one of the chart maintainers can help you debug it 32 | 33 | ### External/Extra Configuration 34 | #### Reverse Proxy Setup/Configuration 35 | If you have a reverse proxy on your router (or your router is set to port forward 80/443 to one) you need to accept and proxy these domains to your Plex K8s Cluster: 36 | + plex.yourdomain.tld 37 | + *project-name*-transcoder-*number*.yourtranscodedomain.tld 38 | 39 | If your plex domain is the same as your transcode domain you can use the following regex: 40 | (?:.+\.)?plex.yourdomain.tld 41 | -------------------------------------------------------------------------------- /templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | 1. Get the application URL by running these commands: 2 | {{- if .Values.ingress.enabled }} 3 | {{- range $host := .Values.ingress.hosts }} 4 | {{- range .paths }} 5 | http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} 6 | {{- end }} 7 | {{- end }} 8 | {{- else if contains "NodePort" .Values.service.type }} 9 | export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "unicorn-plex.fullname" . }}) 10 | export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") 11 | echo http://$NODE_IP:$NODE_PORT 12 | {{- else if contains "LoadBalancer" .Values.service.type }} 13 | NOTE: It may take a few minutes for the LoadBalancer IP to be available. 14 | You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "unicorn-plex.fullname" . }}' 15 | export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "unicorn-plex.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") 16 | echo http://$SERVICE_IP:{{ .Values.service.port }} 17 | {{- else if contains "ClusterIP" .Values.service.type }} 18 | export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "unicorn-plex.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") 19 | echo "Visit http://127.0.0.1:8080 to use your application" 20 | kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 21 | {{- end }} 22 | -------------------------------------------------------------------------------- /templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "unicorn-plex.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "unicorn-plex.fullname" -}} 15 | {{- $name := default .Chart.Name .Values.nameOverride -}} 16 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 17 | {{- end -}} 18 | 19 | {{/* 20 | Create chart name and version as used by the chart label. 21 | */}} 22 | {{- define "unicorn-plex.chart" -}} 23 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 24 | {{- end -}} 25 | 26 | {{/* 27 | Common labels 28 | */}} 29 | {{- define "unicorn-plex.labels" -}} 30 | helm.sh/chart: {{ include "unicorn-plex.chart" . }} 31 | {{ include "unicorn-plex.selectorLabels" . }} 32 | {{- if .Chart.AppVersion }} 33 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 34 | {{- end }} 35 | app.kubernetes.io/managed-by: {{ .Release.Service }} 36 | {{- end -}} 37 | 38 | {{/* 39 | Selector labels 40 | */}} 41 | {{- define "unicorn-plex.selectorLabels" -}} 42 | app.kubernetes.io/name: {{ include "unicorn-plex.name" . }} 43 | app.kubernetes.io/instance: {{ .Release.Name }} 44 | {{- end -}} 45 | 46 | {{/* 47 | Create the name of the service account to use 48 | */}} 49 | {{- define "unicorn-plex.serviceAccountName" -}} 50 | {{- if .Values.serviceAccount.create -}} 51 | {{ default (include "unicorn-plex.fullname" .) .Values.serviceAccount.name }} 52 | {{- else -}} 53 | {{ default "default" .Values.serviceAccount.name }} 54 | {{- end -}} 55 | {{- end -}} 56 | 57 | {{- define "unicorn-plex.lb-url" -}} 58 | {{- if .Values.ingress.host -}} 59 | {{- if (.Values.ingress.tls.host) -}} 60 | {{- if eq ( .Values.transcoding.port | int64 ) 443 -}} 61 | {{- printf "https://%s/" .Values.ingress.tls.host -}} 62 | {{- else -}} 63 | {{- printf "https://%s:%s/" .Values.ingress.tls.host ( .Values.service.port | toString ) -}} 64 | {{- end -}} 65 | {{- else -}} 66 | {{- if eq ( .Values.transcoding.port | int64 ) 80 -}} 67 | {{- printf "http://%s/" .Values.ingress.host -}} 68 | {{- else -}} 69 | {{- printf "http://%s:%s/" .Values.ingress.host ( .Values.service.port | toString ) -}} 70 | {{- end -}} 71 | {{- end -}} 72 | {{- else -}} 73 | {{- printf "http://%s:%s/" .Values.service.loadbalancerIP ( .Values.service.port | toString ) -}} 74 | {{- end -}} 75 | {{- end -}} 76 | 77 | {{- define "unicorn-plex.transcoder-url" -}} 78 | {{- if .Values.ingress.tls.host -}} 79 | {{- if eq ( .Values.transcoding.port | int64 ) 443 -}} 80 | {{- printf "https://$(SERVER_HOST).%s" .Values.transcoding.transcodeDomain -}} 81 | {{- else -}} 82 | {{- printf "https://$(SERVER_HOST).%s:%s" .Values.transcoding.transcodeDomain ( .Values.transcoding.port | toString ) -}} 83 | {{- end -}} 84 | {{- else -}} 85 | {{- if eq ( .Values.transcoding.port | int64 ) 80 -}} 86 | {{- printf "http://$(SERVER_HOST).%s" .Values.transcoding.transcodeDomain -}} 87 | {{- else -}} 88 | {{- printf "http://$(SERVER_HOST).%s:%s" .Values.transcoding.transcodeDomain ( .Values.transcoding.port | toString ) -}} 89 | {{- end -}} 90 | {{- end -}} 91 | {{- end -}} 92 | 93 | {{/* 94 | UnicornTranscoder Loadbalancer Labels 95 | */}} 96 | {{- define "unicorn-plex.loadbalancerSelectorLabels" -}} 97 | {{ include "unicorn-plex.selectorLabels" . }} 98 | unicorn-trancoder: loadbalancer 99 | {{- end -}} 100 | 101 | {{/* 102 | UnicornTranscoder Trancoder Labels 103 | */}} 104 | {{- define "unicorn-plex.transcoderSelectorLabels" -}} 105 | {{ include "unicorn-plex.selectorLabels" . }} 106 | unicorn-trancoder: transcoder 107 | {{- end -}} 108 | 109 | {{/* 110 | UnicornTranscoder Trancoder Labels 111 | */}} 112 | {{- define "unicorn-plex.transcoderControllerSelectorLabels" -}} 113 | {{ include "unicorn-plex.selectorLabels" . }} 114 | unicorn-trancoder: transcoder-controller 115 | {{- end -}} 116 | 117 | {{- define "helm-toolkit.utils.joinListWithComma" -}} 118 | {{- $local := dict "first" true -}} 119 | {{- range $k, $v := . -}}{{- if not $local.first -}},{{- end -}}{{- $v -}}{{- $_ := set $local "first" false -}}{{- end -}} 120 | {{- end -}} 121 | 122 | 123 | {{- define "unicorn-plex.plex-advertise-ip" -}} 124 | {{- $lbIP := "" }} 125 | {{- if .Values.service.advertiseWithService -}} 126 | {{- $lbIP := join "" ( list "http://" .Values.service.loadbalancerIP ":" ( .Values.service.localPort | default .Values.service.port ) ) -}} 127 | {{- end -}} 128 | {{- $advertiseIPs := ( join "," .Values.plexAdvertiseIPs ) -}} 129 | {{- printf ( join "," ( without ( list $lbIP $advertiseIPs ) "" ) | quote ) -}} 130 | {{- end -}} 131 | -------------------------------------------------------------------------------- /templates/hpa.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.transcoding.hpa }} 2 | apiVersion: autoscaling/v1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include "unicorn-plex.fullname" . }} 6 | labels: 7 | {{- include "unicorn-plex.labels" . | nindent 4 }} 8 | spec: 9 | scaleTargetRef: 10 | apiVersion: apps/v1 11 | kind: StatefulSet 12 | name: {{ include "unicorn-plex.name" . }}-transcoder 13 | minReplicas: {{ .Values.transcoding.replicas }} 14 | maxReplicas: {{ .Values.transcoding.maxReplicas }} 15 | targetCPUUtilizationPercentage: {{ .Values.transcoding.hpaCPUPercent }} 16 | {{- end }} 17 | -------------------------------------------------------------------------------- /templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | {{- $fullName := include "unicorn-plex.fullname" . -}} 3 | {{- $svcPort := .Values.service.port -}} 4 | {{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} 5 | apiVersion: networking.k8s.io/v1beta1 6 | {{- else -}} 7 | apiVersion: extensions/v1beta1 8 | {{- end }} 9 | kind: Ingress 10 | metadata: 11 | name: {{ include "unicorn-plex.fullname" . }} 12 | labels: 13 | {{- include "unicorn-plex.labels" . | nindent 4 }} 14 | {{- with .Values.ingress.annotations }} 15 | annotations: 16 | {{- toYaml . | nindent 4 }} 17 | {{- end }} 18 | spec: 19 | {{- if .Values.ingress.tls }} 20 | tls: 21 | - hosts: 22 | - {{ .Values.ingress.tls.host | quote }} 23 | secretName: {{ .Values.ingress.tls.secretName }} 24 | {{- end }} 25 | rules: 26 | - host: {{ .Values.ingress.host | quote }} 27 | http: 28 | paths: 29 | - path: / 30 | backend: 31 | serviceName: {{ include "unicorn-plex.fullname" . }} 32 | servicePort: {{ .Values.service.port }} 33 | {{- end }} 34 | -------------------------------------------------------------------------------- /templates/lb-networkpolicy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: networking.k8s.io/v1 3 | kind: NetworkPolicy 4 | metadata: 5 | name: {{ include "unicorn-plex.fullname" . }}-pms-allow-egress 6 | labels: 7 | {{- include "unicorn-plex.labels" . | nindent 4 }} 8 | spec: 9 | podSelector: 10 | matchLabels: 11 | {{- include "unicorn-plex.loadbalancerSelectorLabels" . | nindent 6 }} 12 | policyTypes: 13 | - Egress 14 | egress: 15 | - {} 16 | -------------------------------------------------------------------------------- /templates/plex-unicornlb-deployment.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: {{ include "unicorn-plex.fullname" . }}-pms 6 | labels: 7 | {{- include "unicorn-plex.labels" . | nindent 4 }} 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | {{- include "unicorn-plex.loadbalancerSelectorLabels" . | nindent 6 }} 13 | template: 14 | metadata: 15 | labels: 16 | {{- include "unicorn-plex.loadbalancerSelectorLabels" . | nindent 8 }} 17 | spec: 18 | volumes: 19 | - name: plex-bin 20 | emptyDir: {} 21 | - name: plex-db 22 | emptyDir: 23 | medium: "Memory" 24 | - name: plex-config 25 | persistentVolumeClaim: 26 | {{- if .Values.data.plexConfig.claimName }} 27 | claimName: {{ .Values.data.plexConfig.claimName }} 28 | {{- else }} 29 | claimName: {{ include "unicorn-plex.fullname" . }}-config 30 | {{- end }} 31 | - name: plex-data 32 | persistentVolumeClaim: 33 | {{- if .Values.data.plexMedia.claimName }} 34 | claimName: {{ .Values.data.plexMedia.claimName }} 35 | {{- else }} 36 | claimName: {{ include "unicorn-plex.fullname" . }}-data 37 | {{- end }} 38 | - name: plex-db-backup 39 | persistentVolumeClaim: 40 | {{- if .Values.data.plexDB.claimName }} 41 | claimName: {{ .Values.data.plexDB.claimName }} 42 | {{- else }} 43 | claimName: {{ include "unicorn-plex.fullname" . }}-db-backup 44 | {{- end }} 45 | {{- if .Values.ingress.tls.secretName }} 46 | - name: plex-tls 47 | secret: 48 | secretName: {{ .Values.ingress.tls.secretName }} 49 | {{- end }} 50 | initContainers: 51 | - name: plex-init 52 | image: "{{ .Values.plex.repository }}:{{ .Values.plex.tag }}" 53 | imagePullPolicy: {{ .Values.plex.pullPolicy | quote }} 54 | env: 55 | {{- if .Values.plexUID }} 56 | - name: PLEX_UID 57 | value: {{ .Values.plexUID | quote }} 58 | {{- end }} 59 | {{- if .Values.plexGID }} 60 | - name: PLEX_GID 61 | value: {{ .Values.plexGID | quote }} 62 | {{- end }} 63 | - name: POD_IP 64 | valueFrom: 65 | fieldRef: 66 | fieldPath: status.podIP 67 | volumeMounts: 68 | - name: "plex-bin" 69 | mountPath: "/plex-bin" 70 | - name: "plex-config" 71 | mountPath: "/plex-config" 72 | - name: "plex-db-backup" 73 | mountPath: "/db-backup" 74 | - name: "plex-db" 75 | mountPath: "/db-storage" 76 | {{- if .Values.ingress.tls.secretName }} 77 | - name: "plex-tls" 78 | mountPath: "/plex-tls" 79 | {{- end }} 80 | command: ['bash', '-c', 'cp -r /usr/lib/plexmediaserver/* /plex-bin; cp -r /db-backup/* /db-storage; chown ${PLEX_UID}:${PLEX_GID} /db-storage/*; {{- if .Values.ingress.tls.secretName }}openssl pkcs12 -export -out /plex-config/{{ .Values.ingress.tls.secretName }}.pfx -inkey /plex-tls/tls.key -in /plex-tls/tls.crt -passout pass: ;{{- end }} exit $?'] 81 | # hostAliases: 82 | # - ip: "$(POD_IP)" 83 | # hostnames: 84 | # - {{ .Values.ingress.host }} 85 | hostNetwork: true 86 | containers: 87 | - name: pms 88 | {{- if .Values.securityContext }} 89 | securityContext: 90 | {{- toYaml .Values.securityContext | nindent 12 }} 91 | {{- end }} 92 | image: "{{ .Values.plex.repository }}:{{ .Values.plex.tag }}" 93 | imagePullPolicy: {{ .Values.plex.pullPolicy | quote }} 94 | env: 95 | - name: TZ 96 | value: {{ .Values.timezone | quote }} 97 | - name: PLEX_CLAIM 98 | valueFrom: 99 | secretKeyRef: 100 | name: {{ include "unicorn-plex.fullname" . }}-claimtoken 101 | key: claimToken 102 | - name: ADVERTISE_IP 103 | value: {{ include "unicorn-plex.plex-advertise-ip" . }} 104 | - name: LB_URL 105 | value: {{ include "unicorn-plex.lb-url" . | quote }} 106 | - name: POD_IP 107 | valueFrom: 108 | fieldRef: 109 | fieldPath: status.podIP 110 | - name: POD_NAME 111 | valueFrom: 112 | fieldRef: 113 | fieldPath: metadata.name 114 | {{- if .Values.plexUID }} 115 | - name: PLEX_UID 116 | value: {{ .Values.plexUID | quote }} 117 | {{- end }} 118 | {{- if .Values.plexGID }} 119 | - name: PLEX_GID 120 | value: {{ .Values.plexGID | quote }} 121 | {{- end }} 122 | volumeMounts: 123 | - name: plex-bin 124 | mountPath: /usr/lib/plexmediaserver 125 | - name: plex-config 126 | mountPath: /config 127 | - name: plex-data 128 | mountPath: /data 129 | - name: plex-db 130 | mountPath: /config/Library/Application Support/Plex Media Server/Plug-in Support/Databases 131 | ports: 132 | - name: plex-web 133 | containerPort: 32400 134 | protocol: TCP 135 | - name: dnla-server 136 | containerPort: 1900 137 | protocol: UDP 138 | - name: plex-companion 139 | containerPort: 3005 140 | protocol: TCP 141 | - name: plex-discovery 142 | containerPort: 5353 143 | protocol: UDP 144 | - name: plex-roku 145 | containerPort: 8324 146 | protocol: TCP 147 | - name: plex-gdm1 148 | containerPort: 32410 149 | protocol: UDP 150 | - name: plex-gdm2 151 | containerPort: 32412 152 | protocol: UDP 153 | - name: plex-gdm3 154 | containerPort: 32413 155 | protocol: UDP 156 | - name: plex-gdm4 157 | containerPort: 32414 158 | protocol: UDP 159 | - name: dnla-server2 160 | containerPort: 32469 161 | protocol: TCP 162 | # readinessProbe: 163 | # httpGet: 164 | # path: /identity 165 | # port: plex-web 166 | # initialDelaySeconds: 15 167 | # timeoutSeconds: 5 168 | # livenessProbe: 169 | # httpGet: 170 | # path: /identity 171 | # port: plex-web 172 | # initialDelaySeconds: 10 173 | # timeoutSeconds: 10 174 | resources: 175 | {{- toYaml .Values.resources.plex | nindent 12 }} 176 | - name: plex-db-backup 177 | image: "{{ .Values.plexDBBackup.repository }}:{{ .Values.plexDBBackup.tag }}" 178 | imagePullPolicy: {{ .Values.plexDBBackup.pullPolicy | quote }} 179 | env: 180 | - name: PLEX_DB_PATH 181 | value: "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases" 182 | - name: DB_BACKUP_PATH 183 | value: "/db-backup" 184 | volumeMounts: 185 | - name: plex-db 186 | mountPath: /config/Library/Application Support/Plex Media Server/Plug-in Support/Databases 187 | - name: plex-db-backup 188 | mountPath: /db-backup 189 | - name: unicorn-loadbalancer 190 | image: "{{ .Values.unicornLoadbalancer.repository }}:{{ .Values.unicornLoadbalancer.tag }}" 191 | imagePullPolicy: {{ .Values.unicornLoadbalancer.pullPolicy | quote }} 192 | env: 193 | - name: SERVER_HOST 194 | valueFrom: 195 | fieldRef: 196 | fieldPath: status.podIP 197 | - name: SERVER_PORT 198 | value: {{ .Values.service.port | quote }} 199 | - name: SERVER_PUBLIC 200 | value: {{ include "unicorn-plex.lb-url" . | quote }} 201 | - name: PLEX_HOST 202 | valueFrom: 203 | fieldRef: 204 | fieldPath: status.podIP 205 | - name: PLEX_PORT 206 | value: "32400" 207 | - name: PLEX_PATH_SESSIONS 208 | value: /config/Library/Application Support/Plex Media Server/Cache/Transcode/Sessions 209 | - name: DATABASE_SQLITE_PATH 210 | value: /config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db 211 | - name: LB_URL 212 | value: {{ include "unicorn-plex.lb-url" . | quote }} 213 | - name: DEBUG 214 | value: "*" 215 | volumeMounts: 216 | - name: plex-bin 217 | mountPath: /usr/lib/plexmediaserver 218 | - name: plex-config 219 | mountPath: /config 220 | - name: plex-data 221 | mountPath: /data 222 | ports: 223 | - name: lb-port 224 | containerPort: {{ .Values.service.port }} 225 | protocol: TCP 226 | # readinessProbe: 227 | # httpGet: 228 | # path: /api/stats 229 | # port: lb-port 230 | # initialDelaySeconds: 15 231 | # timeoutSeconds: 5 232 | # livenessProbe: 233 | # httpGet: 234 | # path: /api/stats 235 | # port: lb-port 236 | # initialDelaySeconds: 10 237 | # timeoutSeconds: 10 238 | resources: 239 | {{- toYaml .Values.resources.unicornLoadbalancer | nindent 12 }} 240 | {{- with .Values.nodeSelector.unicornLoadbalancer }} 241 | nodeSelector: 242 | {{- toYaml . | nindent 8 }} 243 | {{- end }} 244 | {{- with .Values.affinity.unicornLoadbalancer }} 245 | affinity: 246 | {{- toYaml . | nindent 8 }} 247 | {{- end }} 248 | {{- with .Values.tolerations.unicornLoadbalancer }} 249 | tolerations: 250 | {{- toYaml . | nindent 8 }} 251 | {{- end }} 252 | -------------------------------------------------------------------------------- /templates/secrets.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Secret 4 | metadata: 5 | name: {{ include "unicorn-plex.fullname" . }}-claimtoken 6 | labels: 7 | {{- include "unicorn-plex.labels" . | nindent 4 }} 8 | type: Opaque 9 | stringData: 10 | claimToken: "{{ .Values.claimToken }}" 11 | --- 12 | apiVersion: v1 13 | kind: Secret 14 | metadata: 15 | name: {{ include "unicorn-plex.fullname" . }}-x-plex-token 16 | labels: 17 | {{- include "unicorn-plex.labels" . | nindent 4 }} 18 | type: Opaque 19 | stringData: 20 | X-Plex-Token: "{{ .Values.XPlexToken }}" 21 | -------------------------------------------------------------------------------- /templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "unicorn-plex.fullname" . }} 5 | labels: 6 | {{- include "unicorn-plex.labels" . | nindent 4 }} 7 | {{- with .Values.service.annotations }} 8 | annotations: 9 | {{- toYaml . | nindent 4 }} 10 | {{- end }} 11 | spec: 12 | type: {{ .Values.service.type }} 13 | ports: 14 | - name: lb-port 15 | port: {{ .Values.service.port }} 16 | targetPort: lb-port 17 | protocol: TCP 18 | - name: plex-companion 19 | port: 3005 20 | targetPort: plex-companion 21 | protocol: TCP 22 | - name: plex-roku 23 | port: 8324 24 | targetPort: plex-roku 25 | protocol: TCP 26 | - name: dnla-server2 27 | port: 32469 28 | targetPort: dnla-server2 29 | protocol: TCP 30 | selector: 31 | unicorn-trancoder: loadbalancer 32 | --- 33 | apiVersion: v1 34 | kind: Service 35 | metadata: 36 | name: {{ include "unicorn-plex.fullname" . }}-udp 37 | labels: 38 | {{- include "unicorn-plex.labels" . | nindent 4 }} 39 | {{- with .Values.service.annotations }} 40 | annotations: 41 | {{- toYaml . | nindent 4 }} 42 | {{- end }} 43 | spec: 44 | type: {{ .Values.service.type }} 45 | ports: 46 | - name: dnla-server 47 | port: 1900 48 | targetPort: dnla-server 49 | protocol: UDP 50 | - name: plex-discovery 51 | port: 5353 52 | targetPort: plex-discovery 53 | protocol: UDP 54 | - name: plex-gdm1 55 | port: 32410 56 | targetPort: plex-gdm1 57 | protocol: UDP 58 | - name: plex-gdm2 59 | port: 32412 60 | targetPort: plex-gdm2 61 | protocol: UDP 62 | - name: plex-gdm3 63 | port: 32413 64 | targetPort: plex-gdm3 65 | protocol: UDP 66 | - name: plex-gdm4 67 | port: 32414 68 | targetPort: plex-gdm4 69 | protocol: UDP 70 | selector: 71 | unicorn-trancoder: loadbalancer 72 | -------------------------------------------------------------------------------- /templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "unicorn-plex.serviceAccountName" . }} 6 | labels: 7 | {{ include "unicorn-plex.labels" . | nindent 4 }} 8 | {{- end -}} 9 | -------------------------------------------------------------------------------- /templates/storage.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | {{- if not (.Values.data.plexConfig.claimName) }} 3 | apiVersion: v1 4 | kind: PersistentVolumeClaim 5 | metadata: 6 | name: {{ include "unicorn-plex.fullname" . }}-config 7 | labels: 8 | {{- include "unicorn-plex.loadbalancerSelectorLabels" . | nindent 4 }} 9 | spec: 10 | accessModes: 11 | - {{ .Values.data.plexConfig.accessMode | quote }} 12 | resources: 13 | requests: 14 | storage: {{ .Values.data.plexConfig.size | quote }} 15 | {{- if .Values.data.plexConfig.storageClass }} 16 | storageClassName: {{ .Values.data.plexConfig.storageClass | quote }} 17 | {{- end }} 18 | --- 19 | {{- end}} 20 | {{- if not (.Values.data.plexDB.claimName) }} 21 | apiVersion: v1 22 | kind: PersistentVolumeClaim 23 | metadata: 24 | name: {{ include "unicorn-plex.fullname" . }}-db 25 | labels: 26 | {{- include "unicorn-plex.loadbalancerSelectorLabels" . | nindent 4 }} 27 | spec: 28 | accessModes: 29 | - {{ .Values.data.plexDB.accessMode | quote }} 30 | resources: 31 | requests: 32 | storage: {{ .Values.data.plexDB.size | quote }} 33 | {{- if .Values.data.plexDB.storageClass }} 34 | storageClassName: {{ .Values.data.plexDB.storageClass | quote }} 35 | {{- end }} 36 | --- 37 | {{- end }} 38 | {{- if not (.Values.data.plexMedia.claimName) }} 39 | apiVersion: v1 40 | kind: PersistentVolumeClaim 41 | metadata: 42 | name: {{ include "unicorn-plex.fullname" . }}-data 43 | labels: 44 | {{- include "unicorn-plex.loadbalancerSelectorLabels" . | nindent 4 }} 45 | spec: 46 | accessModes: 47 | - {{ .Values.data.plexMedia.accessMode | quote }} 48 | resources: 49 | requests: 50 | storage: {{ .Values.data.plexMedia.size | quote }} 51 | {{- if .Values.data.plexMedia.storageClass }} 52 | storageClassName: {{ .Values.data.plexMedia.storageClass | quote }} 53 | {{- end }} 54 | --- 55 | {{- end }} 56 | {{- if not (.Values.data.transcoding.claimName) }} 57 | apiVersion: v1 58 | kind: PersistentVolumeClaim 59 | metadata: 60 | name: {{ include "unicorn-plex.fullname" . }}-transcode 61 | labels: 62 | {{- include "unicorn-plex.transcoderSelectorLabels" . | nindent 4 }} 63 | spec: 64 | accessModes: 65 | - "ReadWriteMany" 66 | resources: 67 | requests: 68 | storage: {{ .Values.data.transcoding.size | quote }} 69 | {{- if .Values.data.transcoding.storageClass }} 70 | storageClassName: {{ .Values.data.transcoding.storageClass | quote }} 71 | {{- end }} 72 | --- 73 | {{- end }} 74 | -------------------------------------------------------------------------------- /templates/trancoder-controller.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: metac.openebs.io/v1alpha1 2 | kind: DecoratorController 3 | metadata: 4 | name: ingress-per-transcoder 5 | labels: 6 | {{- include "unicorn-plex.labels" . | nindent 4 }} 7 | spec: 8 | resources: 9 | - apiVersion: apps/v1 10 | resource: statefulsets 11 | annotationSelector: 12 | matchExpressions: 13 | - {key: transcoder-pod-name-label, operator: Exists} 14 | - {key: transcoder-pod-port, operator: Exists} 15 | - {key: transcode-domain, operator: Exists} 16 | attachments: 17 | - apiVersion: v1 18 | resource: services 19 | - apiVersion: "extensions/v1beta1" 20 | resource: ingresses 21 | hooks: 22 | sync: 23 | webhook: 24 | url: http://transcoder-controller.{{ .Release.Namespace }}.svc.cluster.local/sync-transcoder-ingress 25 | finalize: 26 | webhook: 27 | url: http://transcoder-controller.{{ .Release.Namespace }}.svc.cluster.local/finalize-transcoder-ingress 28 | --- 29 | apiVersion: metac.openebs.io/v1alpha1 30 | kind: DecoratorController 31 | metadata: 32 | name: transcoder-name-label 33 | labels: 34 | {{- include "unicorn-plex.labels" . | nindent 4 }} 35 | spec: 36 | resources: 37 | - apiVersion: v1 38 | resource: pods 39 | labelSelector: 40 | matchExpressions: 41 | - {key: transcoder-name, operator: DoesNotExist} 42 | annotationSelector: 43 | matchExpressions: 44 | - {key: transcoder-name-label, operator: Exists} 45 | hooks: 46 | sync: 47 | webhook: 48 | url: http://transcoder-controller.{{ .Release.Namespace }}.svc.cluster.local/sync-transcoder-labels 49 | --- 50 | apiVersion: apps/v1 51 | kind: Deployment 52 | metadata: 53 | name: transcoder-controller 54 | labels: 55 | {{- include "unicorn-plex.labels" . | nindent 4 }} 56 | spec: 57 | replicas: 1 58 | selector: 59 | matchLabels: 60 | {{- include "unicorn-plex.transcoderControllerSelectorLabels" . | nindent 6 }} 61 | template: 62 | metadata: 63 | labels: 64 | {{- include "unicorn-plex.transcoderControllerSelectorLabels" . | nindent 8 }} 65 | spec: 66 | containers: 67 | - name: hooks 68 | image: donicrosby/unicorn-plex-transcode-controller:latest 69 | imagePullPolicy: Always 70 | --- 71 | apiVersion: v1 72 | kind: Service 73 | metadata: 74 | name: transcoder-controller 75 | labels: 76 | {{- include "unicorn-plex.labels" . | nindent 4 }} 77 | spec: 78 | selector: 79 | {{- include "unicorn-plex.transcoderControllerSelectorLabels" . | nindent 8 }} 80 | ports: 81 | - port: 80 82 | targetPort: 80 83 | -------------------------------------------------------------------------------- /templates/transcoder-set.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: {{ include "unicorn-plex.name" . }}-transcoder 5 | annotations: 6 | transcoder-pod-name-label: transcoder-name 7 | transcoder-pod-port: "{{ .Values.transcoding.port }}:32400" 8 | transcode-domain: {{ .Values.transcoding.transcodeDomain }} 9 | labels: 10 | {{- include "unicorn-plex.labels" . | nindent 4 }} 11 | spec: 12 | replicas: {{ .Values.transcoding.replicas }} 13 | selector: 14 | matchLabels: 15 | {{- include "unicorn-plex.transcoderSelectorLabels" . | nindent 6 }} 16 | serviceName: "unicorn-transcoder" 17 | template: 18 | metadata: 19 | labels: 20 | {{- include "unicorn-plex.transcoderSelectorLabels" . | nindent 8 }} 21 | annotations: 22 | transcoder-name-label: transcoder-name 23 | spec: 24 | {{- with .Values.imagePullSecrets }} 25 | imagePullSecrets: 26 | {{- toYaml . | nindent 8 }} 27 | {{- end }} 28 | securityContext: 29 | {{- toYaml .Values.podSecurityContext | nindent 8 }} 30 | volumes: 31 | - name: plex-data 32 | persistentVolumeClaim: 33 | {{- if .Values.data.plexMedia.claimName }} 34 | claimName: {{ .Values.data.plexMedia.claimName }} 35 | {{- else }} 36 | claimName: {{ include "unicorn-plex.fullname" . }}-data 37 | {{- end }} 38 | - name: plex-transcode 39 | persistentVolumeClaim: 40 | {{- if .Values.data.transcoding.claimName }} 41 | claimName: {{ .Values.data.transcoding.claimName }} 42 | {{- else }} 43 | claimName: {{ include "unicorn-plex.fullname" . }}-transcode 44 | {{- end }} 45 | containers: 46 | - name: unicorn-transcoder 47 | securityContext: 48 | {{- toYaml .Values.securityContext | nindent 12 }} 49 | image: "{{ .Values.unicornTranscoder.repository}}:{{ .Values.unicornTranscoder.tag }}" 50 | imagePullPolicy: {{ .Values.unicornTranscoder.pullPolicy }} 51 | env: 52 | - name: SERVER_PORT 53 | value: "32400" 54 | - name: SERVER_HOST 55 | valueFrom: 56 | fieldRef: 57 | fieldPath: metadata.name 58 | - name: LOADBALANCER_ADDRESS 59 | value: {{ include "unicorn-plex.lb-url" . | trimSuffix "/" | quote }} 60 | - name: INSTANCE_ADDRESS 61 | value: {{ include "unicorn-plex.transcoder-url" . }} 62 | - name: PLEX_TOKEN 63 | valueFrom: 64 | secretKeyRef: 65 | name: {{ include "unicorn-plex.fullname" . }}-x-plex-token 66 | key: X-Plex-Token 67 | - name: DEBUG 68 | value: "Unicorn*" 69 | - name: TRANSCODER_DEBUG 70 | value: "true" 71 | ports: 72 | - name: transcode 73 | containerPort: 3000 74 | protocol: TCP 75 | volumeMounts: 76 | - name: plex-transcode 77 | mountPath: /opt/UnicornTranscoder/cache 78 | - name: plex-data 79 | mountPath: /data 80 | # livenessProbe: 81 | # httpGet: 82 | # path: /api/sessions 83 | # port: transcode 84 | # initialDelaySeconds: 10 85 | # timeoutSeconds: 10 86 | # readinessProbe: 87 | # httpGet: 88 | # path: /api/sessions 89 | # port: transcode 90 | # initialDelaySeconds: 10 91 | # timeoutSeconds: 10 92 | resources: 93 | {{- toYaml .Values.resources.unicornTranscoder | nindent 12 }} 94 | {{- with .Values.nodeSelector.unicornTranscoder }} 95 | nodeSelector: 96 | {{- toYaml . | nindent 8 }} 97 | {{- end }} 98 | {{- with .Values.affinity.unicornTranscoder }} 99 | affinity: 100 | {{- toYaml . | nindent 8 }} 101 | {{- end }} 102 | {{- with .Values.tolerations.unicornTranscoder }} 103 | tolerations: 104 | {{- toYaml . | nindent 8 }} 105 | {{- end }} 106 | -------------------------------------------------------------------------------- /values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for unicorn-plex. 2 | 3 | plex: 4 | # plex.repository -- Repository hosting the Plex Media Server image 5 | # Currently only Official PlexInc image is supported 6 | repository: plexinc/pms-docker 7 | # plex.tag -- Plex Sever Version 8 | # Should be set to the current version supported by the UnicornTranscoder Project 9 | tag: 1.19.1.2645-ccb6eb67e 10 | # plex.pullPolicy -- Image pull policy 11 | pullPolicy: IfNotPresent 12 | 13 | plexDBBackup: 14 | # plexDBBackup.repository -- Repository hosting Unicorn Plex SQLite Streamer image 15 | repository: donicrosby/unicorn-plex-sqlite-streamer 16 | # plexDBBackup.tag -- SQLite Streamer image tag 17 | tag: 0.1.1 18 | # plexDBBackup.pullPolicy -- Image pull policy 19 | pullPolicy: IfNotPresent 20 | 21 | unicornLoadbalancer: 22 | # unicornLoadbalancer.repository -- Repository hosting UnicornLoadbalancer image 23 | repository: donicrosby/unicorn-loadbalancer 24 | # unicornLoadbalancer.tag -- UnicornLoadbalancer version 25 | # Should be inline with most recent version of UnicornLoadbalancer version 26 | tag: 2.4.3 27 | # unicornLoadbalancer.pullPolicy -- Image pull policy 28 | pullPolicy: IfNotPresent 29 | 30 | unicornTranscoder: 31 | # unicornTranscoder.repository -- Repository hosting UnicornTranscoder image 32 | repository: donicrosby/unicorn-transcoder 33 | # unicornTranscoder.tag -- UnicornTranscoder version 34 | tag: 2.4.2 35 | # unicornTranscoder.pullPolicy -- Image pull policy 36 | pullPolicy: IfNotPresent 37 | 38 | # Plex Environment Config 39 | 40 | # timezone -- Timezone to be set for the server 41 | # See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for list 42 | timezone: Etc/UTC 43 | # XPlexToken -- X-Plex-Token for your server 44 | # See: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ 45 | # for guide to find it after creating the server 46 | XPlexToken: 47 | # claimToken -- Generated token for automatically adding a server under your Plex account 48 | # See: https://plex.tv/claim to generate one 49 | # Note: Token is only valid for 4 minutes 50 | claimToken: 51 | # plexHostname -- Frendly name for your Plex Server 52 | plexHostname: Unicorn-Plex-K8s 53 | # plexAdvertiseIPs -- List of IPs or FQDNs with ports to be set in the Advertise IPs section of your server 54 | plexAdvertiseIPs: [] 55 | # - https://plex.mydomain.tld:443 56 | # - http://plex.mydomain.tld:80 57 | # plexUID -- (int) UID to be set for the Plex Server and UnicornTranscoder for accessing media 58 | plexUID: 1000 59 | # plexGID -- (int) GID to be set for the Plex Server and UnicornTranscoder for accessing media 60 | plexGID: 100 61 | 62 | # Transcoding Pods Configuration 63 | transcoding: 64 | # transcoding.hpa -- (bool) Determine if chart should deploy a Horizontal Pod Autoscaler for the UnicornTranscoders 65 | hpa: true 66 | # transcoding.hpaCPUPercent -- (int) Percentage of requested CPUs over all UnicornTranscoder Pods for the to be utilized before a new UnicornTranscoder pod is created 67 | hpaCPUPercent: 50 68 | # transcoding.replicas -- (int) Number of replicas to be created by the Transcoder StatefulSet 69 | replicas: 4 70 | # transcoding.maxReplicas -- (int) Maximum number of replicas to be created by the HPA 71 | # Note: This is ignored if transcoding.hpa is set to false 72 | maxReplicas: 16 73 | # transcoding.port -- (int) Port to be used by the created transcoding services 74 | port: 443 75 | # transcode.transcodeDomain -- Domain to be used as the base for the FQDN of the transcoders 76 | # EX: unicorn-transcoder-0.plex.mydomain.tld 77 | transcodeDomain: plex.mydomain.tld 78 | 79 | data: 80 | # Plex Configuration 81 | plexConfig: 82 | # data.plexConfig.claimName -- Name of already existing PVC used to store the configuration data for plex 83 | # If claimName is defined then the storage class and size are ignored 84 | claimName: plex-config-pvc 85 | # data.plexConfig.storageClass -- Name of Storage Class to use to create the configuration PVC 86 | # storageClass: nfs-client 87 | # data.plexConfig.accessMode -- Access mode of the existing or to be created PVC 88 | accessMode: ReadWriteOnce 89 | # data.plexConfig.size -- Size of the created PVC 90 | # If claimName is defined then this is ignored 91 | size: 60Gi 92 | 93 | plexDB: 94 | # data.plexDB.claimName -- Name of already existing PVC used as long term storage for the Plex SQLite Database 95 | # If claimName is defined then the storage class and size are ignored 96 | claimName: plex-db-pvc 97 | # data.plexDB.storageClass -- Name of Storage Class to use to create the database PVC 98 | # storageClass: nfs-client 99 | # data.plexDB.accessMode -- Access mode of the existing or to be created PVC 100 | accessMode: ReadWriteOnce 101 | # data.plexDB.size -- Size of the created PVC 102 | # If claimName is defined then this is ignored 103 | size: 10Gi 104 | 105 | plexMedia: 106 | # data.plexMedia.claimName -- Name of already existing PVC that holds all of the media for Plex 107 | # If claimName is defined then the storage class and size are ignored 108 | claimName: tv-movies-pvc 109 | # data.plexMedia.storageClass -- Name of Storage Class to use to create the media PVC 110 | # storageClass: nfs-client 111 | # data.plexMedia.accessMode -- Access mode of the existing or to be created PVC 112 | accessMode: ReadWriteOnce 113 | # data.plexMedia.size -- Size of the created PVC 114 | # If claimName is defined then this is ignored 115 | size: 100Gi 116 | 117 | transcoding: 118 | # data.transcoding.claimName -- Name of already existing PVC to be used by the trancoders to use while transcoding media 119 | # If claimName is defined then the storage class and size are ignored 120 | # Claim must be fore a ReadWriteMany PVC 121 | claimName: 122 | # data.transcoding.storageClass -- Name of Storage Class to use to create the transcoding PVC 123 | storageClass: hostpath 124 | # data.transcoding.size -- Size of the created PVC 125 | # If claimName is defined then this is ignored 126 | size: 120Gi 127 | 128 | imagePullSecrets: [] 129 | ## nameOverride: "" 130 | ## fullnameOverride: "" 131 | 132 | serviceAccount: 133 | # Specifies whether a service account should be created 134 | create: false 135 | # The name of the service account to use. 136 | # If not set and create is true, a name is generated using the fullname template 137 | name: 138 | 139 | podSecurityContext: {} 140 | # fsGroup: 2000 141 | 142 | securityContext: {} 143 | # capabilities: 144 | # drop: 145 | # - ALL 146 | # readOnlyRootFilesystem: true 147 | # runAsNonRoot: true 148 | # runAsUser: 1000 149 | 150 | service: 151 | # service.type -- Service type to be used to expose the UnicornLoadbalancer (and Plex) 152 | # Currently only LoadBalancer is supported 153 | type: LoadBalancer 154 | # service.loadbalancerIP -- IP to be used by the loadbalancer (Recommended to be hardcoded) 155 | loadbalancerIP: 172.16.4.5 156 | # service.port -- Port to be used for Ingress of the LoadBalancer 157 | port: 3001 158 | # service.annotations -- Any annotations to be added to the LoadBalancer 159 | annotations: 160 | # For baremetal installs use MetalLB annotation and have the Ingress and Service IP under same IP space 161 | metallb.universe.tf/allow-shared-ip: unicorn-plex 162 | # service.advertiseWithService -- Add the LoadBalancer IP and port to the Advertise IPs List 163 | advertiseWithService: false 164 | 165 | ingress: 166 | # ingress.enabled -- Use Kubernetes Ingress to access plex 167 | enabled: true 168 | # ingress.annotations -- Any annotations to add to the Plex Ingress 169 | annotations: 170 | kubernetes.io/ingress.class: nginx 171 | kubernetes.io/tls-acme: "true" 172 | cert-manager.io/cluster-issuer: letsencrypt-prod 173 | nginx.ingress.kubernetes.io/proxy-http-version: "1.1" 174 | nginx.ingress.kubernetes.io/proxy-buffering: "off" 175 | nginx.ingress.kubernetes.io/upstream-vhost: "localhost" 176 | nginx.ingress.kubernetes.io/proxy-redirect-from: "http://localhost$request_uri" 177 | nginx.ingress.kubernetes.io/proxy-redirect-to: "$scheme://plex.mydomain.tld$request_uri" 178 | nginx.ingress.kubernetes.io/configuration-snippet: | 179 | more_set_input_headers "Referer: localhost" ; 180 | more_set_input_headers "Origin: localhost" ; 181 | 182 | # ingress.host -- Domain name to use for ingress to plex 183 | host: plex.jeansburger.net 184 | tls: 185 | # ingress.tls.host -- Domain name to use on the TLS Certifcate 186 | host: plex.jeansburger.net 187 | # ingress.tls.secretName -- Name of secret to hold TLS Certifcate 188 | secretName: plex-tls 189 | # secretName: 190 | # - secretName: chart-example-tls 191 | # hosts: 192 | # - chart-example.local 193 | 194 | resources: 195 | requests: 196 | # resources.requests.cpu -- Number of CPU cores to allocate for the Plex Media Server 197 | cpu: 2 198 | # resources.requests.memory -- Amount of Memory to allocate for the Plex Media Server 199 | memory: 2Gi 200 | unicornLoadbalancer: 201 | requests: 202 | # resources.unicornLoadbalancer.requests.cpu -- Amount of CPU cores to allocate for the Unicorn LoadBalancer 203 | cpu: 500m 204 | # resources.unicornLoadbalancer.requests.memory -- Amount of memory to allocate for the Unicorn Loadbalancer 205 | memory: 500Mi 206 | unicornTranscoder: 207 | requests: 208 | # resources.unicornTranscoder.requests.cpu -- Amount of CPU cores to allocate for the Unicorn Transcoder 209 | cpu: 4 210 | # resources.unicornTranscoder.requests.memory -- Amount of memory to allocate for the Unicorn Transcoder 211 | memory: 4Gi 212 | # We usually recommend not to specify default resources and to leave this as a conscious 213 | # choice for the user. This also increases chances charts run on environments with little 214 | # resources, such as Minikube. If you do want to specify resources, uncomment the following 215 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 216 | # limits: 217 | # cpu: 100m 218 | # memory: 128Mi 219 | # requests: 220 | # cpu: 100m 221 | # memory: 128Mi 222 | 223 | nodeSelector: 224 | unicornLoadbalancer: {} 225 | unicornTranscoder: {} 226 | 227 | tolerations: 228 | unicornLoadbalancer: [] 229 | unicornTranscoder: [] 230 | 231 | affinity: 232 | unicornLoadbalancer: {} 233 | unicornTranscoder: {} 234 | --------------------------------------------------------------------------------