<p>My Helm chart (run by Rancher pipeline)'s structure is:</p>
<pre><code>charts/web/0.3.0/templates
  deployment.yaml
  service.yaml
  ingress.yaml
  webinspect-runner.yaml
</code></pre>
<p>The <code>deployment.yaml</code> deploys a web server (say flask-restful or django), and I set a service to it:</p>
<h2>service.yaml</h2>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: {{ include &quot;web.name&quot; . }}-svc
  labels:
    {{- include &quot;iiidevops.labels&quot; . | nindent 4 }}
spec:
  type: NodePort
  selector:
    app: {{ include &quot;web.name&quot; . }}
  ports:
      - port: {{ .Values.web.port }}
        protocol: TCP
</code></pre>
<p>And I want to create a web scan (by webinspect) service to scan it, so I write this:</p>
<h2>webinspect-runner.yaml</h2>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    &quot;helm.sh/hook&quot;: post-install,post-upgrade,post-rollback
    &quot;helm.sh/hook-delete-policy&quot;: before-hook-creation,hook-succeeded
  name: &quot;{{ .Release.Name }}-webinspect-{{ .Values.pipeline.sequence }}&quot;
spec:
  template:
    metadata:
      name: &quot;{{ .Release.Name }}-webinspect-{{ .Values.pipeline.sequence }}&quot;
      labels:
        {{- include &quot;iiidevops.labels&quot; . | nindent 8 }}
    spec:
      containers:
        - name: &quot;webinspect-runner-{{ .Values.pipeline.sequence }}&quot;
          image: &quot;{{ .Values.harbor.host }}/{{ .Values.harbor.cache }}/iiiorg/webinspect-runner:{{ .Values.webinspect.runnerVersion }}&quot;
          command: ['sh', '-c', 'cd /usr/src/app; node /usr/src/app/app.js;']
          env:
            - name: inspect_url
              value: http://{{ .Release.Name }}.{{ .Values.ingress.externalHost }}{{ .Values.webinspect.startPath }}
...
   restartPolicy: Never
  backoffLimit: 4
</code></pre>
<p>The point is <code>inspect_url</code> env. I now use an external domain and ingress to redirect it, but it requires a domain name.</p>
<p>Since <code>kubectl</code> can get the service's IP and port like <code>http://10.50.40.99:32147</code>, can I also write something to let <code>inspect_url</code> also become <code>http://10.50.40.99:32147</code>?</p>

Romulus Urakagi Ts'ai
<p>I'm not sure if you need the scan to be external or if you are okay with an internal scan as well, but either way, you could obtain IP and port by manually requesting them at creation time.</p>
<p><strong>If it is okay to use internal IP and port:</strong></p>
<p>First, for the ClusterIP assigned to a service, it is possible to manually require it (<a href="https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address</a>)</p>
<p>You just need to specify the <code>.spec.clusterIP</code> field of the Service resource.</p>
<p>Second, for the port you can just use the internal one, the one that you define with:</p>
<pre><code>- port: {{ .Values.web.port }}
</code></pre>
<p><strong>If you want to scan it externally at the NodePort port:</strong></p>
<p>First, you can scan the service at whichever node of the cluster, since the NodePort service will expose the communication on all nodes IP Addresses. For the IP you can then just choose one of the cluster's nodes address.</p>
<p>Instead, for the external port, you can specify it manually, simply by adding the optional field:</p>
<pre><code># By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
nodePort: your_port_here
</code></pre>
<p>in the Service declaration.</p>
