<p>i have a question about kubernetes networking.</p>
<p>My working senario:</p>
<ul>
<li>I have a Jenkins  container my localhost and this container up and running. Inside Jenkins, i have a job. Access jenkins , i use &quot;http://localhost:8080&quot; url. (jenkins is not runing inside kubernetes)</li>
<li>My flask app, trigger the Jenkins job with this command:</li>
</ul>
<blockquote>
<pre><code>    @app.route(&quot;/create&quot;,methods=[&quot;GET&quot;,&quot;POST&quot;])
def create():
    
    if request.method ==&quot;POST&quot;:
        dosya_adi=request.form[&quot;sendmail&quot;]
        server = jenkins.Jenkins('http://localhost:8080/', username='my-user-name', password='my-password')
        server.build_job('jenkins_openvpn', {'FILE_NAME': dosya_adi}, token='my-token')
</code></pre>
</blockquote>
<ul>
<li>Then, i did Dockerize this flask app. My image name is: &quot;jenkins-app&quot;</li>
<li>If i run this command, everythings perfect:</li>
</ul>
<blockquote>
<p><code>docker run -it --network=&quot;host&quot; --name=jenkins-app jenkins-app</code></p>
</blockquote>
<p>But i want to do samething with kubernetes. For that i wrote this yml file.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: jenkins-pod
spec:
  hostNetwork: true
  containers:
  - name: jenkins-app
    image: jenkins-app:latest
    imagePullPolicy: Never
    ports:
    - containerPort: 5000
</code></pre>
<ul>
<li>With this yml file, i access the flask app using port 5000. While i want to trigger jenkins job, i get an error like this: requests.exceptions.ConnectionError</li>
</ul>
<p>Would you suggest if there is a way to do this with Kubernetes?</p>

<p>I create an endpoint.yml file and add in this file below commands, this solve my problem:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Endpoints
metadata:
    name: jenkins-server
subsets:
    - addresses:
        - ip: my-ps-ip
    ports:
        - port: 8080
</code></pre>
<p>Then, I change this line in my flask app like this:</p>
<pre class="lang-py prettyprint-override"><code>server = jenkins.Jenkins('http://my-ps-ip:8080/', username='my-user-name', password='my-password')
</code></pre>
