Python Application not running in kubernetes pod with readonlyrootfilesystem

Viewed 126

I am trying to deploy my application is a kubernetes cluster where readonlyrootfilesystem is enabled. My application is getting deployed properly but when apache server tries to execute python3.6. It throws the following error continuously:

Current thread 0x00007f568a43ebc0 (most recent call first):
[Mon Jun 13 16:49:19.634769 2022] [core:notice] [pid 13:tid 140009663622080] AH00052: child pid 341 exit signal Aborted (6)
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

I read about this error, but couldn't find any solution yet. I am attaching my manifest files for reference

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  namespace: mynamespace
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
      name: main
    spec:
      containers:
      - env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        envFrom:
        - configMapRef:
            name: myapp
        image: myappimage
#        command: ["tail","-f","/dev/null"]
        imagePullPolicy: Always
        livenessProbe:
          initialDelaySeconds: 300
          periodSeconds: 180
          tcpSocket:
            port: 8080
        name: myapp
        ports:
        - containerPort: 8080
        readinessProbe:
          initialDelaySeconds: 180
          periodSeconds: 60
          tcpSocket:
            port: 8080
        resources:
          limits:
            cpu: 1
            memory: 2Gi
          requests:
            cpu: 1
            memory: 2Gi
        tty: true
        volumeMounts:
        - mountPath: /etc/apache2/conf-available
          name: var-lock
        - mountPath: /var/lock/apache2
          name: var-lock
        - mountPath: /var/log/apache2
          name: var-lock
        - mountPath: /mnt/log/apache2
          name: var-lock
        - mountPath: /var/run/apache2
          name: var-lock
        - mountPath: /tmp
          name: tmp
#        - mountPath: /usr/lib/python3.6
#          name: python
      securityContext:
        fsGroup: 1000
        runAsGroup: 1000
        runAsUser: 1000
      volumes:
      - emptyDir: {}
        name: var-lock
      - emptyDir: {}
        name: tmp
#      - emptyDir: {}
#        name: python

Please let me know if any other info is needed.

0 Answers
Related