LoginSignup
7
5

More than 5 years have passed since last update.

KubernetesのConfigMapを使ってWordpressのphp.iniを書き換える

Posted at

ローカル環境でWordpressをkubernetes(Docker for Mac)を使って開発しています。
php.iniをimage側で書き換えたものを使って対応していたんですが良い方法を見つけたのでメモ

ConfigMapを使って設定を書き換える

必要な部分だけ抜粋。


apiVersion: v1
kind: ConfigMap
metadata:
  name: wordpress-php-config
data:
  wordpress-custom.ini: |-
    upload_max_filesize = 50M
    post_max_size = 50M

↑コレでmountできるディレクトリを作成され、wordpress-custom.iniが作られる。
実際の設定ファイルからもConfigMapを作成できる。


apiVersion: apps/v1
kind: Deployment
metadata:
  ...
spec:
  ...
  template:
    spec:
      containers:
        - image: wordpress:5.0.3-php7.1-apache
          ...
          volumeMounts:
            ...
            - name: php-config
              mountPath: /usr/local/etc/php/conf.d/wordpress-custom.ini
              subPath: wordpress-custom.ini

      volumes:
        ...
        - name: php-config
          configMap:
            name: wordpress-php-config
            items:
              - key: wordpress-custom.ini
                path: wordpress-custom.ini

itemsを指定してconfigMapからiniファイルだけを参照できるようにする。
subPathを指定しないでphp-configをMountするとdirectoryとしてマウントされる。

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5