Restoring wordpress and mysql data to kubernetes volume Restoring wordpress and mysql data to kubernetes volume kubernetes kubernetes

Restoring wordpress and mysql data to kubernetes volume


How is this possible to do or am I thinking something wrong?

It might be better to move configuration mindset from working directly on base container instances to configuring container images/manifests. You have several approaches there, just some pointers:

  • Create own Dockerfile based on images you referenced and bundle configuration files inside them. This is viable approach if configuration is more or less static and can be handled with env vars or infrequent builds of docker images, but require docker registry handling to work with k8s. In this approach you would add all changed files to build context of docker and then COPY them to appropriate places.

  • Create ConfigMaps and mount them on container filesystem as config files where change is required. This way you can still use base images you reference directly but changes are limited to kubernetes manifests instead of rebuilding docker images. Approach in this case would be to identify all changed files on container, then create kubernetes ConfigMaps out of them and finally mount appropriately. I don't know which exactly things you are changing but here is example of how you can place nginx config in ConfigMap:

    kind: ConfigMapapiVersion: v1metadata:  name: cm-nginx-exampledata:  nginx.conf: |     server {        listen 80;        ...        # actual config here        ...      }

    and then mount it in container in appropriate place like so:

    ...containers: - name: nginx-example   image: nginx   ports:   - containerPort: 80   volumeMounts:     - mountPath: /etc/nginx/conf.d       name: nginx-conf volumes: - name: nginx-conf   configMap:     name: cm-nginx-example     items:     - key: nginx.conf       path: nginx.conf...
  • Mount persistent volumes (subpaths) on places where you need configs and keep configuration on persistent volumes.

Personally, I'd probably opt for ConfigMaps since you can easily share/edit those with k8s deployments and configuration details are not lost as some mystical 'extensive work' but can be reviewed, tweaked and stored to some code versioning system for version tracking...