<p>I am trying to deploy IBM MQ to my local MAC machine using an image hosted on docker hub repository. I am using docker edge version with Kubernetes support on it.</p>

<p>I am able to deploy the image successfully using kubernetes and also have the Queue Manager running fine inside the container. I am also able to ssh into the container and make sure all the MQ processes are running as expected. </p>

<p>But when I use port forwarding using the following kubectl command, it opens the port, but does not let me telnet to it using "IP or hostname" (even from the local machine). But when I use "localhost" to telnet it works fine. </p>

<p>While troubleshooting, I deployed the same image using docker commands instead of kubernetes and with docker deployment, the port forwarding works as expected. It lets me telnet using IP, hostname and localhost. </p>

<p>So, definitely its some issue with Kubernetes port forwarding. Can some one please let me know if I am missing anything here? Let me know if there is some additional information needed from my end.</p>

<p>I am new to kubernetes and docker, but pretty familiar with IBM MQ.</p>

<p><strong><em>Commands being used:</em></strong></p>

<p><strong>To create port forwarding rule using kubectl, checking netstat and connecting with telnet:</strong> </p>

<hr>

<pre><code>HOSTNAME:Test2 an0s5v4$ sudo kubectl port-forward private-reg 1414:1414 &amp;

[1] 3001


HOSTNAME:Test2 an0s5v4$ Forwarding from 127.0.0.1:1414 -&gt; 1414
Forwarding from [::1]:1414 -&gt; 1414

HOSTNAME:Test2 an0s5v4$ netstat -an |grep 1414
tcp6       0      0  ::1.1414               *.*                    LISTEN     
tcp4       0      0  127.0.0.1.1414         *.*                    LISTEN  

HOSTNAME:Test2 an0s5v4$ ps -ef|grep 1414
    0  3001   920   0 10:27AM ttys006    0:00.03 sudo kubectl port-forward private-reg 1414:1414

    0  3002  3001   0 10:27AM ttys006    0:00.18 kubectl port-forward private-reg 1414:1414
  502  3007   920   0 10:28AM ttys006    0:00.00 grep 1414
</code></pre>

<hr>

<pre><code>HOSTNAME:Test2 an0s5v4$ telnet IP 1414

Trying IP...

telnet: Unable to connect to remote host: Connection refused
</code></pre>

<hr>

<pre><code>HOSTNAME:Test2 an0s5v4$ telnet localhost 1414

Trying ::1...

Connected to localhost.

Escape character is '^]'.

Handling connection for 1414
</code></pre>

<hr>

<pre><code>L-RCC9048942:Test2 an0s5v4$ telnet HOSTNAME 1414

Trying IP ...

telnet: Unable to connect to remote host: Connection refused
</code></pre>

<hr>

<pre><code>HOSTNAME:Test2 an0s5v4$ nslookup HOSTNAME

;; Truncated, retrying in TCP mode.

Name:   HOSTNAME
Address: IP
</code></pre>

<hr>

<p><strong>Kubernetes pod YAML file contents</strong></p>

<pre><code>apiVersion: v1

kind: Pod

metadata: 

  name: private-reg

  labels:

     app: ibmmq

spec: 

  containers: 

    - 

      env: 

        - 

          name: LICENSE

          value: accept

        - 

          name: MQ_QMGR_NAME

          value: QM4

      image: "image path in docker hub"

      name: private-reg-container

      ports: 

        - 

          containerPort: 1414

          hostPort: 1414
</code></pre>

<hr>

<p><strong>EDIT: ADDED K8S Service to the post</strong></p>

<p><strong>Kubernetes service YAML file contents</strong></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: myservice-nodeport
  labels:
    app: ibmmq
spec:
  ports:
  - port: 3000 
    targetPort: 1414
    nodePort: 31414
  selector:
    app: ibmmq
  type: NodePort
</code></pre>

<p>If you need port forwarding to bind to all the network interfaces, you can give this option. This will be useful when working with servers in OpenShift etc where there are different local and floating IPs</p>
<blockquote>
<p>--address 0.0.0.0</p>
</blockquote>
<p>Example</p>
<pre><code>kubectl port-forward minio-64b7c649f9-9xf5x --address 0.0.0.0 7000:9000 --namespace minio
</code></pre>
