<p>I am experimenting with the above mentioned tools right now and ran into some issues.
I cannot forward my ports, because it seems like I am having some problems with the ip-tables
of my pod.</p>
<p>&quot;sudo iptables -P FORWARD ACCEPT&quot; is supposed to get rid of my problems, but I wonder,
how I can insert that command in my yaml-file so that it is going to be executed,</p>
<p>before my pod wants to get the database. Am I right with that?</p>
<p>Maybe you can help me sorting out where to place the code and how to implement the commad.</p>
<p>Best regards!!!!</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-mysql


  initContainers:
    - name: forward accept
      command: [&quot;sudo iptables&quot;]
      args: [&quot;-P&quot;, &quot;FORWARD ACCEPT&quot;]
      
  template:
    metadata:
      labels:
        app: my-mysql
    spec:
      volumes:
          - name: data-volume
            emptyDir: {}
    

      initContainers:
        - name: init-container-data-downloader
          image: curlimages/curl
          args:
            - &quot;-o&quot;
            - &quot;/tmp/data/init.sql&quot;
            - &quot;https://google.de&quot;
          volumeMounts:
            - mountPath: /tmp/data/
              name: data-volume
      containers:
        - name: mysql
          image: mysql
          volumeMounts:
            - mountPath: /docker-entrypoint-initdb.d/
              name: data-volume
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: &quot;mysecretpw&quot;
            - name: MYSQL_DATABASE
              value: &quot;sportsdb&quot;
          ports:
            - containerPort: 3306
            - containerPort: 33060






</code></pre>

Calumeth
<p><code>curlimages/curl</code> docker image does not contain <code>iptables</code> binary. I would recommend you create a custom docker image and add whichever binaries are required.</p>
<p>You can add multiple arguments in <code>initContainer</code></p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-mysql
  template:
    metadata:
      labels:
        app: my-mysql
    spec:
      volumes:
        - name: data-volume
          emptyDir: {}
      initContainers:
        - name: init-container-data-downloader
          image: alpine:3.12
          command: [&quot;/bin/ash&quot;, &quot;-c&quot;]
          args:
            [
              &quot;sudo iptables -P FORWARD ACCEPT; wget -q https://google.de -O /tmp/data/init.sql&quot;,
            ]
          volumeMounts:
            - mountPath: /tmp/data/
              name: data-volume
      containers:
        - name: mysql
          resources: {}
          image: mysql
          volumeMounts:
            - mountPath: /docker-entrypoint-initdb.d/
              name: data-volume
          env:
            - name: MYSQL_ROOT_PASSWORD
              value: &quot;mysecretpw&quot;
            - name: MYSQL_DATABASE
              value: &quot;sportsdb&quot;
          ports:
            - containerPort: 3306
</code></pre>
