Modprobe not installed on docker kubernetes container in GKE

Viewed 70

I'm trying to run gcsfuse inside my docker container to access my Google Cloud Storage so my program inside the docker can access it. I'm using Google Kuberenetes Engine. My problem is when i run whereis modprobe I get no results, meaning there is no modprobe installed. I've seen this post and this one but they are futile. I've allready ran sudo apt install update && sudo apt install upgrade to upgrade my kernels and also tried simply sudo apt-get install modprobe which results in package not found. I've eddited my deployment.yaml file to include these (I'm deploying throught github actions):

spec:
...
        securityContext:
            privileged: true
            capabilities:
              add:
                - SYS_ADMIN
                - SYS_MODULE
        env:
          - name: STARTUP_SCRIPT
            value: |
              #! /bin/bash
              modprobe fuse

But these didn't change anything at all. I've seen in a post that i must add something like lib/modules but i allready have a lib file inside my container that my program uses, is there a workaround for that? Am i installing gcsfuse wrong? (Installing gcsfuse was hard normal practices didn't work but in the end we made it work)

Here is my gcsfuse installation:

RUN apt-get update -y && apt-get dist-upgrade -y && apt-get -y install lsb-release curl gnupg && apt -y install lsb-core

ENV GCSFUSE_REPO gcsfuse-stretch


RUN apt-get update -y && apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl gnupg
RUN echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | tee /etc/apt/sources.list.d/gcsfuse.list
RUN echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

# Install gcsfuse and google cloud sdk
RUN apt-get update -y  && apt-get install -y gcsfuse google-cloud-sdk \
    && apt-get autoremove -y \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

This is a continuation of another error I had whilst trying to run gcsfuse, I realised i don't have modprobe and asked this question. Ubuntu image 22.10

Edit: This questions says I must add stuff to a yaml file but I'm not sure which yaml file I must add those to. Since im using github actions I have deployment.yaml, kustomization.yaml and service.yaml

1 Answers

When you provide the following as you job yaml file, it will provide the correct privileges for the job you are creating rather then deployments.yaml file :

apiVersion: batch/v1
kind: Job
metadata:
  # Unique key of the Job instance
  name: job-40
spec:
  template:
    metadata:
      name: job-40
    spec:
      containers:
      - name: nginx-1
        image: gcr.io/videoo2/github.com/...
        command: ["/bin/sleep"]
        args: ["1000"]
        securityContext:
          privileged: true
          capabilities:
            add:
              - SYS_ADMIN
      # Do not restart containers after they exit
      restartPolicy: Never
  # of retries before marking as failed.
  backoffLimit: 0
Related