ressu / kube-plex

Scalable Plex Media Server on Kubernetes -- dispatch transcode jobs as pods on your cluster!
Apache License 2.0
104 stars 23 forks source link

Clean install on kube v1.22.1, not seeing available server via gui #10

Closed karezza closed 3 years ago

karezza commented 3 years ago

Ingress didn't work so I created my own.

Am able to browse to the gui via my ingress pointing to 32400.

It doesn't see a server from the install, it does see my older docker install though and I can watch videos through it.

I'm not seeing any errors and being that this is my first run of this chart I'm not sure what to look for. Do you see something obvious missing? Are there some troubleshooting steps I can perform for you? Do I just need to add something to my ingress?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: plex
  namespace: plex
  annotations:
    #nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - plex.k-dev.mydomain.net
    secretName: plex
  rules:
  - host: plex.k-dev.mydomain.net
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: plex-kube-plex
            port:
              number: 32400
#!/bin/bash

#git clone https://github.com/ressu/kube-plex.git

PVC=plex
CLAIM_TOKEN=claim-D985oaSfakeaK9CPNBeA

helm install plex ./kube-plex/charts/kube-plex \
    --namespace plex \
    --set claimToken=$CLAIM_TOKEN \
    --set persistence.data.claimName=$PVC
NAME                                  READY   STATUS    RESTARTS   AGE
pod/plex-kube-plex-6d84f56f47-8mjsn   1/1     Running   0          22m

NAME                     TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                    AGE
service/plex-kube-plex   ClusterIP   10.110.90.165   <none>        32400/TCP,80/TCP,443/TCP   22m

NAME                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/plex-kube-plex   1/1     1            1           22m

NAME                                        DESIRED   CURRENT   READY   AGE
replicaset.apps/plex-kube-plex-6d84f56f47   1         1         1       22m
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 40-plex-first-run: executing... 
Creating pref shell
Attempting to obtain server token from claim token
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:07 --:--:--     0
Plex Media Server first run setup complete
[cont-init.d] 40-plex-first-run: exited 0.
[cont-init.d] 50-plex-update: executing... 
[cont-init.d] 50-plex-update: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Starting Plex Media Server.
$ k exec -it plex-kube-plex-6d84f56f47-cnp47 -- /bin/bash
Defaulted container "plex" out of: plex, kube-plex-init (init)
root@plex-kube-plex:/# ps ax
    PID TTY      STAT   TIME COMMAND
      1 ?        Ss     0:00 s6-svscan -t0 /var/run/s6/services
     24 ?        S      0:00 s6-supervise s6-fdholderd
    221 ?        S      0:00 s6-supervise plex
    223 ?        Ss     0:00 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver:/usr/lib/plexmediaserver/lib /usr/lib/plexmediaserver/Plex\ Media\ Server
    229 ?        Sl     0:02 /usr/lib/plexmediaserver/Plex Media Server
    243 ?        SNl    0:05 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 1.16.
    292 ?        Sl     0:00 /usr/lib/plexmediaserver/Plex DLNA Server
    293 ?        Sl     0:00 /usr/lib/plexmediaserver/Plex Tuner Service /usr/lib/plexmediaserver/Resources/Tuner/Private /usr/lib/plexmediaserver/Resources/Tuner/Shared 1.16.0.1226-7eb2c8f6f 32600 /waitmut
    521 ?        Sl     0:01 Plex Plug-in [com.plexapp.agents.opensubtitles] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server
    588 ?        Sl     0:01 Plex Plug-in [com.plexapp.agents.plexthememusic] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --serve
    623 ?        Sl     0:02 Plex Plug-in [com.plexapp.agents.plexmusic] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-ver
    626 ?        Sl     0:02 Plex Plug-in [com.plexapp.agents.themoviedb] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-ve
    631 ?        Sl     0:02 Plex Plug-in [com.plexapp.agents.thetvdb] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-versi
    697 ?        Sl     0:02 Plex Plug-in [com.plexapp.agents.imdb] /usr/lib/plexmediaserver/Resources/Plug-ins-7eb2c8f6f/Framework.bundle/Contents/Resources/Versions/2/Python/bootstrap.py --server-version 
   1054 pts/0    Ss     0:00 /bin/bash
   1063 pts/0    R+     0:00 ps ax
$ k describe deployments.apps plex-kube-plex 
Name:               plex-kube-plex
Namespace:          plex
CreationTimestamp:  Sun, 12 Sep 2021 19:33:05 -0600
Labels:             app=kube-plex
                    app.kubernetes.io/managed-by=Helm
                    chart=kube-plex-0.3.0
                    heritage=Helm
                    release=plex
Annotations:        deployment.kubernetes.io/revision: 1
                    meta.helm.sh/release-name: plex
                    meta.helm.sh/release-namespace: plex
Selector:           app=kube-plex,release=plex
Replicas:           1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:       Recreate
MinReadySeconds:    0
Pod Template:
  Labels:           app=kube-plex
                    release=plex
  Annotations:      kube-plex/container-name: kube-plex-init
                    kube-plex/pms-addr: plex-kube-plex:32400
                    kube-plex/pms-container-name: plex
  Service Account:  plex-kube-plex
  Init Containers:
   kube-plex-init:
    Image:      ghcr.io/ressu/kube-plex:latest
    Port:       <none>
    Host Port:  <none>
    Command:
      cp
      /kube-plex
      /shared/kube-plex
    Environment:  <none>
    Mounts:
      /shared from shared (rw)
  Containers:
   plex:
    Image:       plexinc/pms-docker:1.16.0.1226-7eb2c8f6f
    Ports:       32400/TCP, 32400/TCP, 32443/TCP
    Host Ports:  0/TCP, 0/TCP, 0/TCP
    Liveness:    tcp-socket :32400 delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:   tcp-socket :32400 delay=0s timeout=1s period=10s #success=1 #failure=3
    Startup:     tcp-socket :32400 delay=0s timeout=1s period=5s #success=1 #failure=30
    Environment:
      TZ:             America/Denver
      PLEX_CLAIM:     claim-D985oaSfakeaK9CPNBeA
      POD_NAME:        (v1:metadata.name)
      POD_NAMESPACE:   (v1:metadata.namespace)
    Mounts:
      /config from config (rw)
      /data from data (rw)
      /shared from shared (rw)
      /transcode from transcode (rw)
  Volumes:
   data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  plex
    ReadOnly:   false
   config:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  plex-kube-plex-config
    ReadOnly:   false
   transcode:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
   shared:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  <unset>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   plex-kube-plex-6d84f56f47 (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  49m   deployment-controller  Scaled up replica set plex-kube-plex-6d84f56f47 to 1
ressu commented 3 years ago

I did run into similar issues when I was setting up my initial setup, which was caused by the claim token expiring before I managed to debug the final issues in my deployment. I double checked that the claim token is passed to the right variable in the container, so I don't immediately know what could have gone wrong with your setup there.

For the initial setup, I had to trick the setup thinking that I was connecting from the local network (ingress is seen as outside) and that finally started the installation process. This is all Plex though, so I don't really know all the internals on how the connecting parts work. Considering that this is a fresh installation, deleting the installation (and the configuration storage), getting a new claim token and trying again might be worth it.

For the ingress, do you have the error which was caused or did the ingress resource get created, but didn't relay traffic?

karezza commented 3 years ago

I believe the claim token worked as I got past the initial plex setup. However, it is very easy to retest with a new token. I can also test using a method to connect from localhost and not need the claim token.

I didn't get an Ingress error. The Ingress looks to be working perfectly connectingto 32400, there's just no plex server to connect to (other than my old pms setup which I am looking to retire).

I will helm uninstall and reinstall in a couple hours and report back.

On Mon, Sep 13, 2021, 3:00 PM Sami Haahtinen @.***> wrote:

I did run into similar issues when I was setting up my initial setup, which was caused by the claim token expiring before I managed to debug the final issues in my deployment. I double checked that the claim token is passed to the right variable in the container, so I don't immediately know what could have gone wrong with your setup there.

For the initial setup, I had to trick the setup thinking that I was connecting from the local network (ingress is seen as outside) and that finally started the installation process. This is all Plex though, so I don't really know all the internals on how the connecting parts work. Considering that this is a fresh installation, deleting the installation (and the configuration storage), getting a new claim token and trying again might be worth it.

For the ingress, do you have the error which was caused or did the ingress resource get created, but didn't relay traffic?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ressu/kube-plex/issues/10#issuecomment-918571344, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEHXQ7PL2AQDLP3J6X4BF23UBZQ5FANCNFSM5D4WRQBA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ressu commented 3 years ago

That to me sounds a lot like claim token issue. The ingress (since it's not a local connection) will log you into the web app, which will only list servers that were able to associate with your account. The association is done with the claim token, so it would make sense that the claim token wasn't properly used to associate the server to your account.

Let me know how it goes, I honestly can't remember the steps I did to connect to the instance as if it was local. But some amount of port-forward trickery was needed.

karezza commented 3 years ago

After updating the repo, there were some changes in values.yaml, I was quick with a new claim token and so far looks like everything is working. Need to finish the steps to allow the specified network. Will check back in after testing the setup.

karezza commented 3 years ago

After some investigation, now I have plex-kube-plex as an option but it has a red triangle with an exclamation point. When I click it I get a message "app.plex.tv" is unable to connect to "plex-kube-plex" securely. Investigating...

karezza commented 3 years ago

I recall the Ingress error now, it was around the beta extensions not being available, the apiVersion in the ingress needs to be updated to be apiVersion: networking.k8s.io/v1. I suspect the ingress is the issue for me now. I setup my own ingress but I probably need to use the hostname 'plex-kube-plex' instead of 'plex' as I am now. I probably could have set the hostname with the ingress option 'hosts', if I could have used the ingress option.

karezza commented 3 years ago

I had to run:

kubectl port-forward plex-kube-plex-6bf9969554-b8b26 32400:32400

And then browse to localhost:32400, then I was able to configure the server & now it shows up via my ingress.

I wonder if this may be a required step for everyone?

I just rechecked the documentation on the main page and see it says to connect to the dashboard via a port-forward or, the last option was an ingress. Maybe the ingress I made just wasn't exactly the same as the one that's made by the built in ingress...

ressu commented 3 years ago

Ok, sounds like on the second time around the token was properly applied, but the announce address was the problem. I'll take a look if I can improve the flow a bit, but it might be that the easy solution is to document the port forward solution as a workaround.

I'll also take a look at the ingress definition. Since it's really old, it will need updating to the most recent ingress setup. I might even import my own entries that I recently migrated to since I've never been a huge fan of helm. I'll reopen this issue so that I'll remember to address both of those in the code too.

karezza commented 3 years ago

I'm not sure yet if eliminating the ingress option in the documentation and only giving the localhost port forward technique is the right strategy until I have seen both work.

I was wondering though if a Troubleshooting section at the bottom might be a good idea. I was planning to go look at the helm standards website to see if there is a traditional place to put a troubleshooting section.

I suspect folks not getting their claim token in within 4 minutes will probably be very common and it would make sense to document:

I have these ideas to document, but can't really document them till I find out the answers. However, since I have run into them, unless they are bugs to be fixed, I suspect others may have the same questions. And, anything to free you from having to answer the same questions multiple times is probably a good idea.

karezza commented 3 years ago

I wonder if it might be possible to detect on the server that the claimtoken was expired and display a useful message to stdout that people might notice when debugging. Maybe an additional Init condition to check for and display a nice verbose message?

ressu commented 3 years ago

Disabling the ingress wouldn't change the initial setup in any way. The major difference between ingress and port forward is the origin of the traffic, not so much a change in how Plex works within the container. Ingress traffic is seen as traffic coming from outside of the local network, where as port forward will seem like it's coming from the same network (or even localhost, I can't remember for certain how it looks within the container). So having an ingress set up doesn't break the setup process.

For the claim token, I don't see an easy way to detect if it's expired since it's handled fully within the Plex process. Not to mention that the claim token is often left to the configuration for a long time, even after the Plex instance has used the token. We could introduce a sidecar that constantly reads the Plex configuration file and tries to see if the server has registered, but that seems like a lot of work to solve a onetime issue. If you can think of other ways how this could be solved, I'm open to suggestions since this seems like a common issue with many Plex users. Having some support for this in kube-plex would make adoption easier for kube-plex 😉

As for your troubleshooting ideas, you could start a wiki page for those and we can try to hash out common solutions for the problems there.

ressu commented 3 years ago

Closing this issue since the ingress definition has been updated and the documentation is being updated in #14