<p>I am facing some issues on I believe to be my .yaml file.
Docker-compose works fine and the containers ran as expected.
But after kompose convert on the file did not yield desired result on k8s, and I am getting com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure.</p>
<p>There are no existing container in docker containers and docker-compose down was used prior in kompose convert.</p>
<p>mysql pod work fine, and able to access.
spring is however unable to connect to it....</p>
<p>in docker-compose.yaml</p>
<pre><code>        version: '3'

services:

  mysql-docker-container:
    image: mysql:latest
    environment:
      - MYSQL_ROOT_PASSWORD=1
      - MYSQL_DATABASE=db_fromSpring
      - MYSQL_USER=springuser
      - MYSQL_PASSWORD=ThePassword
  
    networks:
      - backend
    ports: 
      - 3307:3306
    volumes:
      - /data/mysql

  spring-boot-jpa-app:
    command: mvn clean install -DskipTests
    image: bnsbns/spring-boot-jpa-image
 
    depends_on:
      - mysql-docker-container
      
    environment:
      - spring.datasource.url=jdbc:mysql://mysql-docker-container:3306/db_fromSpring
      - spring.datasource.username=springuser
      - spring.datasource.password=ThePassword
    networks:
      - backend

    ports:
      - &quot;8087:8080&quot;
    volumes:
      - /data/spring-boot-app
 
networks:
  backend:
</code></pre>
<p>Error:</p>
<pre><code>2021-09-15 04:37:47.542 ERROR 1 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
</code></pre>
<p>backend-network.yaml</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  creationTimestamp: null
  name: backend
spec:
  ingress:
  - from:
    - podSelector:
        matchLabels:
          io.kompose.network/backend: &quot;true&quot;
  podSelector:
    matchLabels:
      io.kompose.network/backend: &quot;true&quot;
</code></pre>
<p>mysql-docker-container-claim0-persistentvolumeclaim.yaml</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: mysql-docker-container-claim0
  name: mysql-docker-container-claim0
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}
</code></pre>
<p>mysql-docker-container-deployment.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: mysql-docker-container
  name: mysql-docker-container
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: mysql-docker-container
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
        kompose.version: 1.21.0 (992df58d8)
      creationTimestamp: null
      labels:
        io.kompose.network/backend: &quot;true&quot;
        io.kompose.service: mysql-docker-container
    spec:
      containers:
      - env:
        - name: MYSQL_DATABASE
          value: db_fromSpring
        - name: MYSQL_PASSWORD
          value: ThePassword
        - name: MYSQL_ROOT_PASSWORD
          value: &quot;1&quot;
        - name: MYSQL_USER
          value: springuser
        image: mysql:latest
        imagePullPolicy: &quot;&quot;
        name: mysql-docker-container
        ports:
        - containerPort: 3306
        resources: {}
        volumeMounts:
        - mountPath: /data/mysql
          name: mysql-docker-container-claim0
      restartPolicy: Always
      serviceAccountName: &quot;&quot;
      volumes:
      - name: mysql-docker-container-claim0
        persistentVolumeClaim:
          claimName: mysql-docker-container-claim0
status: {}
</code></pre>
<p>mysql-docker-container-service.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: mysql-docker-container
  name: mysql-docker-container
spec:
  ports:
  - name: &quot;3307&quot;
    port: 3307
    targetPort: 3306
  selector:
    io.kompose.service: mysql-docker-container
status:
  loadBalancer: {}
</code></pre>
<p>springboot-app-jpa-deployment.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: spring-boot-jpa-app
  name: spring-boot-jpa-app
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: spring-boot-jpa-app
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
        kompose.version: 1.21.0 (992df58d8)
      creationTimestamp: null
      labels:
        io.kompose.network/backend: &quot;true&quot;
        io.kompose.service: spring-boot-jpa-app
    spec:
      containers:
      - args:
        - mvn
        - clean
        - install
        - -DskipTests
        env:
        - name: spring.datasource.password
          value: ThePassword
        - name: spring.datasource.url
          value: jdbc:mysql://mysql-docker-container:3306/db_fromSpring
        - name: spring.datasource.username
          value: springuser
        image: bnsbns/spring-boot-jpa-image
        imagePullPolicy: &quot;&quot;
        name: spring-boot-jpa-app
        ports:
        - containerPort: 8080
        resources: {}
        volumeMounts:
        - mountPath: /data/spring-boot-app
          name: spring-boot-jpa-app-claim0
      restartPolicy: Always
      serviceAccountName: &quot;&quot;
      volumes:
      - name: spring-boot-jpa-app-claim0
        persistentVolumeClaim:
          claimName: spring-boot-jpa-app-claim0
status: {}
</code></pre>
<p>springboot-jpa-app-persistence-claim.yaml</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: spring-boot-jpa-app-claim0
  name: spring-boot-jpa-app-claim0
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {}
</code></pre>
<p>springboot-app-service.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: spring-boot-jpa-app
  name: spring-boot-jpa-app
spec:
  ports:
  - name: &quot;8087&quot;
    port: 8087
    targetPort: 8080
  selector:
    io.kompose.service: spring-boot-jpa-app
status:
  loadBalancer: {}
</code></pre>
<hr />
<p>solution as posted by gohm'c was that i had the incorrect port.</p>
<p>facing this issue next, do i need to specific a cluster/load?</p>
<p>$ kubectl expose deployment spring-boot-jpa-app --type=NodePort
Error from server (AlreadyExists): services &quot;spring-boot-jpa-app&quot; already exists</p>
<pre><code>minikube service spring-boot-jpa-app
|-----------|---------------------|-------------|--------------|
| NAMESPACE |        NAME         | TARGET PORT |     URL      |
|-----------|---------------------|-------------|--------------|
| default   | spring-boot-jpa-app |             | No node port |
|-----------|---------------------|-------------|--------------|
😿  service default/spring-boot-jpa-app has no node port
</code></pre>

invertedOwlCoding
<p>The <code>mysql-docker-container</code> service port is 3307, can you try:</p>
<pre><code>env:
...
- name: spring.datasource.url
  value: jdbc:mysql://mysql-docker-container:3307/db_fromSpring
</code></pre>
