docker icon indicating copy to clipboard operation
docker copied to clipboard

deploy to kubernetes issue

Open DavidCamelo opened this issue 5 years ago • 11 comments

Hi, I have the following configuration to deploy phpmyadmin to kubernetes.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpmyadmin
  labels:
    app: phpmyadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpmyadmin
  template:
    metadata:
      labels:
        app: phpmyadmin
    spec:
      containers:
        - name: phpmyadmin
          image: phpmyadmin/phpmyadmin:5
          ports:
            - containerPort: 80
              protocol: TCP
          env:
            - name: PMA_HOST
              value: my-mysql
            - name: PMA_PORT
              value: "3306"
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-pass
                  key: password
            - name: PMA_USER
              value: admin
            - name: PMA_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-pass
                  key: admin-password
          resources:
            limits:
              cpu: 50m
              memory: 32Mi
          imagePullPolicy: Always
      restartPolicy: Always
  strategy:
    type: RollingUpdate
  revisionHistoryLimit: 1

When the pod goes up it doesn't start the apache, I have to run service apache2 start after this I check the phpmyadmin and see that it doesn't take the environment variables defined to connect to the database phpmyadmin Could you help me with this problem? thanks in advance!

DavidCamelo avatar Jul 01 '20 19:07 DavidCamelo

Hi @DavidCamelo

You need to have your instance on the same network that the database is onto to enable access via phpMyAdmin. I hope you will find some answers in my local config: https://github.com/wdesportes/phpmyadmin-local-setup/blob/a9ac9dc281bcfa3348e4c7ad10e00ef71cbcf546/docker-compose.yml#L161 :)

williamdes avatar Jul 01 '20 20:07 williamdes

Hi @williamdes

Yes, my database is on the same network, I even have wordpress deploys and java application deploys pointing to that database.

I also did a test only with docker pointing to an external database I have running on IP 54.68.2.230 and it works. docker run --name myadmin -d -e PMA_HOST=54.68.2.230 -p 8080:80 phpmyadmin/phpmyadmin:5 phpmyadmin_docker

I tried changing my deploy file and put only the PMA_HOST variable pointing to 54.68.2.230 but it still doesn't work

apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpmyadmin
  labels:
    app: phpmyadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpmyadmin
  template:
    metadata:
      labels:
        app: phpmyadmin
    spec:
      containers:
        - name: phpmyadmin
          image: phpmyadmin/phpmyadmin:5
          ports:
            - containerPort: 80
              protocol: TCP
          env:
            - name: PMA_HOST
              value: 54.68.2.230

DavidCamelo avatar Jul 01 '20 20:07 DavidCamelo

Unfortunately I did not have the chance to try out kubernetes, It will take me some free time before I can run it on my workstation

Here is another kubernetes issue, maybe fixed.: https://github.com/phpmyadmin/docker/issues/217

Could you open a StackOverflow (or other) question to have some better and faster help and if a bug is found in your config we could fix it afterwards ?

williamdes avatar Jul 01 '20 20:07 williamdes

Sure I will try asking on StackOverflow, I'll keep you posted.

DavidCamelo avatar Jul 01 '20 20:07 DavidCamelo

@williamdes FYI this is my thread in StackOverflow in case you want to follow https://stackoverflow.com/questions/62685906/deploy-phpmyadmin-to-kubernetes-issue

DavidCamelo avatar Jul 01 '20 22:07 DavidCamelo

Hello, I also have the same problem deploying phpmyadmin to a kubernetes container. The logs are pointing to the same issue as you linked here: https://github.com/phpmyadmin/docker/issues/217.

Here are the logs from my pod, managed by Openshift (openshift's heart is 100% kubernetes): `/docker-entrypoint.sh: line 5: /etc/phpmyadmin/config.secret.inc.php: Permission denied

touch: cannot touch '/etc/phpmyadmin/config.user.inc.php': Permission denied

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.130.17.39. Set the 'ServerName' directive globally to suppress this message

(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80

(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

AH00015: Unable to open logs ` This comes when I try to specify different environment variables

thloscar avatar Jul 28 '20 17:07 thloscar

From the output the ports do not seem to bind

williamdes avatar Jul 28 '20 18:07 williamdes

Hi @oscarloop, I was trying in different ways to make it work and I couldn't do it, so I'm using the bitnami phpmyadmin image https://hub.docker.com/r/bitnami/phpmyadmin

apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpmyadmin
  labels:
    app: phpmyadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpmyadmin
  template:
    metadata:
      labels:
        app: phpmyadmin
    spec:
      containers:
        - name: phpmyadmin
          image: bitnami/phpmyadmin:latest
          ports:
            - containerPort: 8080
              protocol: TCP
          env:
            - name: DATABASE_HOST
              value: mysql-service

DavidCamelo avatar Jul 29 '20 14:07 DavidCamelo

They seem to re-build everything https://github.com/bitnami/bitnami-docker-phpmyadmin/blob/master/5/debian-10/Dockerfile

@J0WI do you have some ideas about this issue ?

williamdes avatar Jul 29 '20 15:07 williamdes

@DavidCamelo can you share the complete log output? We can only see the copying now message in https://github.com/phpmyadmin/docker/issues/294#issue-649254194.

J0WI avatar Jul 29 '20 15:07 J0WI

@J0WI the log only shows the following, that's it.

phpMyAdmin not found in /var/www/html - copying now...
Complete! phpMyAdmin has been successfully copied to /var/www/html

DavidCamelo avatar Jul 29 '20 20:07 DavidCamelo

Hi @DavidCamelo Can you confirm it works on Kubernetes?

williamdes avatar Oct 07 '22 16:10 williamdes

hi @williamdes yes, It is working on Kubernetes. This is my yml that is working

apiVersion: apps/v1
kind: Deployment
metadata:
  name: phpmyadmin
  labels:
    app: phpmyadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: phpmyadmin
  template:
    metadata:
      labels:
        app: phpmyadmin
    spec:
      containers:
        - name: phpmyadmin
          image: phpmyadmin:latest
          ports:
            - name: phpmyadmin
              containerPort: 80
              protocol: TCP
          env:
            - name: PMA_HOST
              value: wordpress-mysql
          imagePullPolicy: Always
      restartPolicy: Always

DavidCamelo avatar Oct 07 '22 21:10 DavidCamelo