https://rancher.com/ logo
Title
b

busy-judge-4614

03/28/2023, 11:09 AM
Hi, is there a way to access the mounted Longhorn storage? Can I for instance add a directory?
a

aloof-hair-13897

03/28/2023, 12:16 PM
You could access the volume in the
/var/lib/kubelet/pods/8230ce89-2723-432d-8a3c-35431ea7342c/volumes/kubernetes.io~csi/media-store/mount
but just curious about why do you want to do this?
b

busy-judge-4614

03/28/2023, 12:18 PM
Thanks James. I needed to create a couple of directories and add a config file. Is there a better way I should do thi? I’m beginner
r

refined-analyst-8898

03/28/2023, 1:00 PM
Is it a container app or Kubevirt VM using the LongHorn storage? Generally, the pattern is to compose the image for your container or VM from source and redeploy, not customize the running image. This is the basis for the name "Rancher." The analogy is wrangling cattle, which are replaceable, not pets, which are irreplaceable. A little morbid, but you get the idea. 😜 Figure out how to compose your container or VM image from source, then you can easily modify the image and redeploy it many, many times. If you're composing a container image, you can use
docker build
, and if you're building VM images you can use
packer build
. In fact, you can use Packer to build container images too. It's versatile like that.
b

busy-judge-4614

03/28/2023, 1:49 PM
thanks for the info. Its a container I am pulling from github. I’m rather new and just learning at this stage but I take when you say and it makes sense!
r

refined-analyst-8898

03/28/2023, 2:38 PM
If you found the source of the image in GitHub then you're half-way to your destination. You probably have a
Dockerfile
that you can customize then run
docker build -t myContainerImage .
in the same directory. If you're using #rancher-desktop with the same container runtime as Docker, then you I believe you can deploy your new image immediately in the K3s Kubernetes cluster running in #rancher-desktop, e.g.
kubectl run --stdin --tty --rm myContainerImage --image=<http://docker.io/library/myContainerImage|docker.io/library/myContainerImage> --restart=Never -- sh
, or a more useful container command than
sh
.
On my computer, there are two container runtimes available: containerd and Moby. The runtime I've selected in Rancher Desktop determines which build command I need to run to use the container image in K3s running in Rancher Desktop. containerd needs
nerdctl build
, and Moby needs
docker build
.
I forgot to mention you need to append
--image-pull-policy=Never
to your
run
command to prevent K3s from trying to download the image from Docker Hub. That will force it to try to load the image from your local build cache. Here are the instructions: https://docs.rancherdesktop.io/tutorials/working-with-images/
b

busy-judge-4614

03/30/2023, 3:56 PM
### media.sonarr.values.yml
replicaCount: 1

image:
  repository: linuxserver/sonarr
  tag: arm32v7-latest # ARM image
  pullPolicy: IfNotPresent

env:
  - name: PUID
    value: "1000"
  - name: PGID
    value: "1000"

service:
  type: ClusterIP
  port: 80

volumes:
  - name: media-ssd
    persistentVolumeClaim:
      claimName: "media-ssd" # PersistentVolumeClaim created earlier

volumeMounts:
  - name: media-ssd
    mountPath: "/config"
    subPath: "configs/sonarr" # Path /mnt/ssd/media/configs/sonarr where sonarr writes the configuration
  - name: media-ssd
    mountPath: "/downloads/transmission"
    subPath: "downloads/transmission" # Path /mnt/ssd/media/downloads/transmission where sonarr picks up downloaded episodes
  - name: media-ssd
    mountPath: "/tv"
    subPath: "library/tv" # Path /mnt/ssd/media/library/tv where sonarr moves and renames the episodes
So those are the directories I require. But they don’t seem to be setup when I install the package with helm. I get an error likie:-
Name:             sonarr-cc6764857-rlftx
Namespace:        media
Priority:         0
Service Account:  default
Node:             k4/192.168.1.223
Start Time:       Thu, 30 Mar 2023 17:22:55 +0100
Labels:           app=sonarr
                  pod-template-hash=cc6764857
                  release=sonarr
Annotations:      <none>
Status:           Pending
IP:               
IPs:              <none>
Controlled By:    ReplicaSet/sonarr-cc6764857
Containers:
  sonarr:
    Container ID:   
    Image:          linuxserver/sonarr:latest
    Image ID:       
    Port:           8989/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:     500m
      memory:  256Mi
    Requests:
      cpu:     100m
      memory:  128Mi
    Environment:
      PUID:  1000
      PGID:  1000
    Mounts:
      /config from media-store (rw,path="configs/sonarr")
      /downloads/transmission from media-store (rw,path="downloads/transmission")
      /tv from media-store (rw,path="library/tv")
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-k67nq (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  media-store:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  media-store
    ReadOnly:   false
  kube-api-access-k67nq:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   Burstable
Node-Selectors:              <none>
Tolerations:                 <http://node.kubernetes.io/not-ready:NoExecute|node.kubernetes.io/not-ready:NoExecute> op=Exists for 300s
                             <http://node.kubernetes.io/unreachable:NoExecute|node.kubernetes.io/unreachable:NoExecute> op=Exists for 300s
Events:
  Type     Reason              Age   From                     Message
  ----     ------              ----  ----                     -------
  Normal   Scheduled           99s   default-scheduler        Successfully assigned media/sonarr-cc6764857-rlftx to k4
  Warning  FailedMount         99s   kubelet                  Unable to attach or mount volumes: unmounted volumes=[kube-api-access-k67nq media-store], unattached volumes=[kube-api-access-k67nq media-store]: error processing PVC media/media-store: failed to fetch PVC from API server: persistentvolumeclaims "media-store" is forbidden: User "system:node:k4" cannot get resource "persistentvolumeclaims" in API group "" in the namespace "media": no relationship found between node 'k4' and this object
  Warning  FailedAttachVolume  99s   attachdetach-controller  Multi-Attach error for volume "media-store" Volume is already used by pod(s) transm-transmission-openvpn-8674c9b55c-j2scq, jackett-67fccb78c8-jjdq6
17:24@kubernetes:~$
I am attempting to deploy like:
helm install sonarr bananaspliff/sonarr \
--values media.sonarr.values.yaml \ --namespace media