<p>I have deployed MySql and PhpMyAdmin in Kubernetes cluster. I want to log in to PMA with the username and password and connect to Mysql. I kind of got stuck. I have external IP for PMA which should connect to my database.
Here is my deployment script:</p>

<p>For mysql:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    name: mysqldb
  name: mysqldb
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        name: mysqldb
    spec:
      containers:
      - env:
        - name: DB_NAME
          value: metrics
        - name: DB_USER
          value: metrics
        - name: DB_PASS
          value: ****
        image: mysql:5.7
        name: mysqldb
        ports:
        - containerPort: 3306
        resources: {}
        volumeMounts:
        - mountPath: /var/lib/mysql
          name: data-volume
          subPath: data
      restartPolicy: Always
      volumes:
      - name: data-volume
        persistentVolumeClaim:
          claimName: data-volume
status: {}
</code></pre>

<p>For PMA:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: myadmin
  labels:
    name: myadmin
spec:
  containers:
    - name: phpmyadmin
      image: phpmyadmin/phpmyadmin
      env:
        - name: PMA_HOST
          value: mysqldb
        - name: DB_NAME
          value: metrics
        - name: DB_USER
          value: *****
        - name: DB_PASS
          value: *****
      ports:
        - containerPort: 80
          name: myadmin
</code></pre>

<p>Am I doing something wrong.</p>

<p>Is it even possible to deploy Php, Mysql, PMA, React and Nginx all in Kubernetes?
Kind of struggling to figure-out how all things are connected and can't find any meaningful resources related to this topic. My app works fine in local machine with docker-compose and trying to convert this file to Kompose resources.</p>

<p>Here is my docker-compose file: </p>

<pre><code>version: '3'
services:
    web:
        image: nginx:alpine
        volumes:
            - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
            - "./etc/ssl:/etc/ssl"
            - "./web:/var/www/html"
            - "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
        ports:
            - "8000:80"
            - "3000:443"
        environment:
            - NGINX_HOST=${NGINX_HOST}
        command: /bin/sh -c "envsubst '$$NGINX_HOST' &lt; /etc/nginx/conf.d/default.template &gt; /etc/nginx/conf.d/default.conf &amp;&amp; nginx -g 'daemon off;'"
        restart: always
        depends_on:
            - php
            - mysqldb
    app:
      build: ./app
      environment:
        - NODE_ENV=$NODE_ENV
      ports:
          - "5000:5000"
      volumes:
        - ./app:/usr/src/web
        # Use a data volume to store all `node_modules` to prevent the directory
        # being removed when `./app` is mounted into the docker instance
        - /usr/src/web/node_modules
      #uncomment to run a local prod build
      #command: yarn build-start-local-prod
    php:
        image: nanoninja/php-fpm:${PHP_VERSION}
        restart: always
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
        volumes:
            - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
            - "./web:/var/www/html"
    composer:
        image: "composer"
        volumes:
            - "./web/app:/app"
        command: install
    myadmin:
        image: phpmyadmin/phpmyadmin
        container_name: phpmyadmin
        ports:
            - "8080:80"
        environment:
            - PMA_ARBITRARY=1
            - PMA_HOST=${MYSQL_HOST}
        restart: always
        depends_on:
            - mysqldb
    mysqldb:
        image: mysql:5.7
        container_name: ${MYSQL_HOST}
        restart: always
        env_file:
            - ".env"
        environment:
            - MYSQL_DATABASE=${MYSQL_DATABASE}
            - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
            - MYSQL_USER=${MYSQL_USER}
            - MYSQL_PASSWORD=${MYSQL_PASSWORD}
        ports:
            - "8989:3306"
        volumes:
            - "data-volume:/var/lib/mysql"
volumes:
  data-volume:
</code></pre>

<p>I would appreciate if you can help. Thanks!</p>

surajnew55
<p>The way to do it is:</p>

<ol>
<li>Stateful set with PHP My Admin</li>
<li>Service pointing to stateful set</li>
<li>Ingress pointing to the service</li>
<li>your MySQL Stateful set</li>
</ol>
