<p>I am a total newbe with Helm charts,  but I have managed to get a pod with with ApacheDS  (LDAP server)  running on it.  I can exec shell into it and I can login and get responses from the LDAP server.</p>
<p>However, from outside the cluster,  I get a connection refused.  Looking this up, I &quot;think&quot; I need a NodePort:  <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">Kube documentation</a>  However,  I cannot see where to put that spec.  I have tried many things but just cant get it.  According to the documentation I need something like this:</p>
<pre><code>spec:
  type: NodePort
  selector:
    app: MyApp
  ports:
    - port: 10389
    targetPort: 10389
    nodePort: 30007
</code></pre>
<p>Here is my deployment.yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include &quot;buildchart.fullname&quot; . }}
  labels:
    {{- include &quot;buildchart.labels&quot; . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include &quot;buildchart.selectorLabels&quot; . | nindent 6 }}
  template:
    metadata:
    {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include &quot;buildchart.selectorLabels&quot; . | nindent 8 }}
    spec:
      {{- if .Values.imagePullSecrets }}
      imagePullSecrets:
        - name: {{ .Values.imagePullSecrets }}
      {{- end }}
      serviceAccountName: {{ include &quot;buildchart.serviceAccountName&quot; . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: &quot;{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}&quot;
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: admin-port
              containerPort: 8080
              hostPort: 8080
              protocol: TCP
            - name:  ldap-port
              containerPort: 10389
              hostPort: 10389
              protocol: UDP
          livenessProbe:
             exec:
              command:
              - curl ldap://localhost:10389/
            initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
          readinessProbe:
            exec:
              command:
              - sh
              - -c
              - curl ldap://localhost:10389/
            initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.readinessProbe.periodSeconds }}              
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
</code></pre>
<p>How do I open this port to the rest of the world?  Or at least the box the container is on.</p>

mmaceachran
<p>Yes, you need to create a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service" rel="nofollow noreferrer">Service</a> for your deployment.</p>
<p>Also, I suggest you do it without hardcoding, because easier to change a value in the <code>values.yaml</code> file than edit templates files for adding a new hardcode values.</p>
<p>In the <code>deployment.yaml</code> set:</p>
<pre><code>...
{{ if .Values.ports }}
ports:
{{ range .Values.ports }}
  - name: {{ .name }}
    containerPort: {{ .containerPort }}
    protocol: {{ .protocol }}
{{ end }}
{{ end }}
...
</code></pre>
<p>In the <code>values.yaml</code> set:</p>
<pre><code>ports:
  - name: admin-port
    containerPort: 8080
    nodePort: 8080
    protocol: TCP
  - name:  ldap-port
    containerPort: 10389
    nodePort: 10389
    protocol: UDP
</code></pre>
<p>Create <code>service.yaml</code> file and set</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: {{ include &quot;buildchart.fullname&quot; . }}
  labels:
    {{- include &quot;buildchart.labels&quot; . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
  {{ range .Values.ports }}
    - port: {{ .nodePort }}
      targetPort: {{ .containerPort }}
      protocol: {{ .protocol }}
      name: {{ .name }}
  {{ end }}
  selector:
    {{- include &quot;buildchart.selectorLabels&quot; . | nindent 4 }}
</code></pre>
