<p>My docker-compose file consisting of tomcat7 server and mysql database</p>

<pre><code>
version: '3'
services:
      mysql:
        image: suji165475/vignesh:latest
        ports:
          - "3066:3066"

      tomcat:
        image: suji165475/vignesh:tomcatserver
        container_name: tomcat7hope
        ports:
          - "8080:8080"

</code></pre>

<p>I built the images using docker files</p>

<pre><code>FROM mysql
ENV MYSQL_ROOT_PASSWORD=root
ADD init.sql /docker-entrypoint-initdb.d
</code></pre>

<pre><code>FROM picoded/tomcat7
COPY data-core-0.0.1-SNAPSHOT.war /usr/local/tomcat/webapps/data-core-0.0.1-SNAPSHOT.war

</code></pre>

<p>how to run this on kubernetes clusture?? I already tried kompose convert and my war file wont start in tomcats application manager.But the war file starts succesfully using docker-compose up.</p>

<p>Why am I facing this issue only in kubernetes and not when directly running docker-compose up.Please help me by letting me know what changes I should make  to the kubernetes yaml files.</p>

<p>mysql-deployment.yaml</p>

<pre><code> apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.18.0 (06a2e56)
  creationTimestamp: null
  labels:
    io.kompose.service: mysql
  name: mysql
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: mysql
    spec:
      containers:
      - image: suji165475/vignesh:latest
        name: mysql
        ports:
        - containerPort: 3066
        resources: {}
      restartPolicy: Always
status: {}
</code></pre>

<p>tomcat-deployment.yaml</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.18.0 (06a2e56)
  creationTimestamp: null
  labels:
    io.kompose.service: tomcat
  name: tomcat
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: tomcat
    spec:
      containers:
      - image: suji165475/vignesh:tomcatserver
        name: tomcat7hope
        ports:
        - containerPort: 8080
        resources: {}
      restartPolicy: Always
status: {}
</code></pre>

<p>mysql-service.yaml</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.18.0 (06a2e56)
  creationTimestamp: null
  labels:
    io.kompose.service: mysql
  name: mysql
spec:
  ports:
  - name: "3066"
    port: 3066
    targetPort: 3066
  selector:
    io.kompose.service: mysql
status:
  loadBalancer: {}
</code></pre>

<p>tomcat-service.yaml</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.18.0 (06a2e56)
  creationTimestamp: null
  labels:
    io.kompose.service: tomcat
  name: tomcat
spec:
  ports:
  - name: "8080"
    port: 8080
    targetPort: 8080
  selector:
    io.kompose.service: tomcat
status:
  loadBalancer: {}
</code></pre>

<p>Let me make it clear, you can't "run docker-compose" on Kubernetes. If you wanted to do that, you should not be using Kubernetes.</p>

<p>With that said, using <code>kompose</code> is not such a great idea. Docker compose yaml files are all different and <code>kompose</code> simply makes a guess as to what the associated Kubernetes manifests would look like. If your application is very simple and you are lucky, <code>kompose</code> might give you your manifests ready to be deployed, but that is not usually the case.</p>

<p>There could be a few reasons why this is not working for you:</p>

<ul>
<li>your <code>tomcat</code> application is not correctly referencing your <code>mysql</code> service</li>
<li>your <code>mysql</code> deployment is missing some variables or mounted volumes/files</li>
</ul>

<p>Your <code>tomcat</code> app can refer to your <code>mysql</code> db through <code>mysql:3066</code> and you might need to add some environment variables in your <code>tomcat</code> deployment such as db name, db username and db password for authentication. Here are your edited <code>tomcat</code> manifests:</p>

<p><em>deployment.yaml</em></p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: tomcat
  namespace: default
  labels:
    app: tomcat
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tomcat
  template:
    metadata:
      labels:
        app: tomcat
    spec:
      containers:
      - image: suji165475/vignesh:tomcatserver
        name: tomcat7hope
        ports:
        - containerPort: 8080
</code></pre>

<p><em>service.yaml</em></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: tomcat
  namespace: default
  labels:
    app: tomcat
spec:
  ports:
  - name: "8080"
    port: 8080
    targetPort: 8080
  selector:
    app: tomcat
</code></pre>

<p>Your <code>mysql</code> deployment might require a <code>PersistentVolumeClaim</code> or <code>emptyDir</code> in order to keep your data. Take a look at attached volumes and confirm that you are not missing any volume mounts or environment variables that are needed. Here are your edited <code>mysql</code> manifests:</p>

<p><em>deployment.yaml</em></p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mysql
  namespace: default
  labels:
    app: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - image: suji165475/vignesh:latest
        name: mysql
        ports:
        - containerPort: 3066
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: root
</code></pre>

<p><em>service.yaml</em></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: default
  labels:
    app: mysql
spec:
  ports:
  - name: "3066"
    port: 3066
    targetPort: 3066
  selector:
    app: mysql
</code></pre>
