current position:Home>If the folder of pod in k8s is mounted with data volume (persistent), the pod cannot be started. How to solve it?

If the folder of pod in k8s is mounted with data volume (persistent), the pod cannot be started. How to solve it?

2022-02-02 20:16:21 CSDN Q & A

background :
Cloud platform k8s Upper Department gitlab Code warehouse services , The folder where the code is stored needs to be persistent .
But once the directory where the code is stored is mounted on a persistent volume , be pod Can't start , And report an error :“changing ownership operation not permitted”. If you don't mount this directory , It can start normally .
Enter the container to view permissions , It is found that there is a permission problem with this folder , So we used "initContainers" To try to solve , But it failed : If in initContainers Using commands in , May be an error :“Back-off restarting failed container”; If the order does not apply , You have no permission to modify , Error or “changing ownership operation not permitted”.

Attached below is my deployment Of yaml:

kind: Deploymentmetadata:  name: gitlab  namespace: sga  labels:    name: gitlabspec:  replicas: 1  selector:    matchLabels:      name: gitlab  template:    metadata:      name: gitlab      creationTimestamp: null      labels:        name: gitlab    spec:      volumes:        - name: data          persistentVolumeClaim:            claimName: gitlab      initContainers:        - args:          - -c          - chmod 755 /home/git/data && chown 1000:1000 /home/git/data          command:          - /bin/sh          name: init-gitlab          image: 'centos'          resources: {}          volumeMounts:            - name: data              mountPath: /home/git/data          imagePullPolicy: IfNotPresent          securityContext:            privileged: true            procMount: Default      containers:        - name: gitlab          image: 'samegitlab:11.8.1'          ports:            - name: http              containerPort: 80              protocol: TCP            - name: ssh              containerPort: 22              protocol: TCP          env:            - name: TZ              value: Asia/Kolkata            - name: GITLAB_TIMEZONE              value: Beijing            - name: GITLAB_SECRETS_DB_KEY_BASE              value: long-and-random-alpha-numeric-string            - name: GITLAB_SECRETS_SECRET_KEY_BASE              value: long-and-random-alpha-numeric-string            - name: GITLAB_SECRETS_OTP_KEY_BASE              value: long-and-random-alpha-numeric-string            - name: GITLAB_HTTPS              value: 'true'          resources:            limits:              cpu: '4'              memory: 8Gi            requests:              cpu: '2'              memory: 4Gi          volumeMounts:            - name: data              mountPath: /home/git/data

Please help us to see what the problem is ?

What I want to achieve is pod Be able to function , And be able to /home/git/data Directory persistent storage




Refer to the answer 1:

This is usually because your storage side directory permissions are not enough , You can check .




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022016190884.html

Random recommended