<p>I am currently deploying my Laravel application to a kubernetes cluster. I use the same docker image for the actual deployment and a migration job which is deployed via Gitlab using Helm.</p>

<p>The Problem:
Running the migration job failes, because pdo_mysql module is not enabled (missing in php -m)</p>

<p>Things to know:
Running same container with the same command locally <code>docker run registry.gitlab.com/../master:TAG /bin/sh -c "php artisan:migrate"</code> - works fine</p>

<p>Application container in the cluster is also working, so pdo_mysql is present.</p>

<p>Scheduler using supervisord to run <code>php some:command</code> (which needs pdo_mysql) works too.</p>

<p>.env file is the same for all containers</p>

<p>Deployment file (you can ignore the helm variables)</p>

<pre><code>    {{- if .Values.application.migrateCommand -}}
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ template "trackableappname" . }}-db-migrate
  labels:
    app: {{ template "appname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-delete-policy": before-hook-creation
    "helm.sh/hook-weight": "0"
spec:
  template:
    metadata:
      labels:
        app: {{ template "appname" . }}
        release: {{ .Release.Name }}
    spec:
      restartPolicy: Never
      imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        command: ["/bin/sh"]
        args: ["-c", "{{ .Values.application.migrateCommand }}"]
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        {{- if .Values.application.secretName }}
        envFrom:
        - secretRef:
            name: {{ .Values.application.secretName }}
        {{- end }}
{{- end -}}
</code></pre>

<blockquote>
  <p>Update: helm install . --dry-run --debug</p>
</blockquote>

<pre><code>    ---
# Source: portal/templates/db-migrate-hook.yaml
apiVersion: batch/v1
    kind: Job
    metadata:
      name: cranky-seahorse-db-migrate
      labels:
        app: cranky-seahorse
        chart: "portal-0.3.0"
        release: cranky-seahorse
        heritage: Tiller
      annotations:
        "helm.sh/hook": pre-upgrade
        "helm.sh/hook-delete-policy": before-hook-creation
        "helm.sh/hook-weight": "0"
    spec:
      template:
        metadata:
          labels:
            app: cranky-seahorse
            release: cranky-seahorse
        spec:
          restartPolicy: Never
          imagePullSecrets:
              - name: gitlab-registry

          containers:
          - name: portal
            image: "gitlab.example.com/group/project:stable"
            command: ["/bin/sh"]
            args: ["-c", "sh migrate.sh"]
            imagePullPolicy: Always
---
</code></pre>

mrvnklm
<p>The cause of the problem can be wrong <code>php.ini</code> in <code>/var/www/html</code> that was being loaded instead of the right one (<code>exetension_dir</code> was being set wrongly) so please check it.</p>

<p>You can run:</p>

<pre><code>RUN echo "extension=pdo_mysql" &gt;&gt; /usr/local/etc/php/php.ini \
 &amp;&amp; service apache2 restart
</code></pre>

<p>This will enable extension code into the <code>php.ini</code> and restart apache2 so the new config gets loaded.</p>

<p>What I found also is <a href="https://github.com/docker-library/php/issues/62#issuecomment-467455626" rel="nofollow noreferrer">github</a> topic about it. You can also try this solution.
I hope it will helps you.</p>
