<p>I'm using a static yaml file to install gitlab. Therefore I run</p>
<pre><code>helm template gitlab gitlab/gitlab -f &quot;config.yaml&quot; &gt; gitlab.yaml
</code></pre>
<p>But in this generated yaml file I always have to modify these three values:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: gitlab-gitlab-shell
  namespace: gitlab # &lt;--- change
  labels:
    app: gitlab-shell
    chart: gitlab-shell-4.4.2
    release: gitlab
    heritage: Helm
  annotations:
    environment: prod
spec:
  type: NodePort # &lt;--- change
  ports:
    - port: 30022
      targetPort: 2222
      protocol: TCP
      nodePort: 30022 # &lt;-- add
      name: ssh
  selector:
    app: gitlab-shell
    release: gitlab
</code></pre>
<p>Is it possible to 'automate' this? Maybe directly in the config file?</p>
<p>This is how my config.yaml looks like:</p>
<pre><code>global:
  edition: ce
  hosts:
    domain: domain.com

  shell:
    port: 30022

  pod:
    labels:
      environment: prod

  deployment:
    annotations:
      environment: prod

  service:
    annotations:
      environment: prod

  ingress:
    class: nginx
    configureCertmanager: false
    annotations:
      cert-manager.io/cluster-issuer: letsencrypt-prod
      acme.cert-manager.io/http01-edit-in-place: 'true'

certmanager:
  install: false

nginx-ingress:
  enabled: false

gitlab:
  webservice:
    ingress:
      tls:
        secretName: gitlab-webservice-tls
  gitaly:
    persistence:
      size: 2Gi

gitlab-runner:
  runners:
    privileged: true

registry:
  ingress:
    tls:
      secretName: gitlab-registry-tls

postgresql:
  persistence:
    size: 2Gi
minio:
  ingress:
    tls:
      secretName: gitlab-minio-tls
  persistence:
    size: 2Gi
redis:
  persistence:
    size: 2Gi

prometheus:
  alertmanager:
    enabled: false
    persistentVolume:
      enabled: false
      size: 2Gi
  pushgateway:
    enabled: false
    persistentVolume:
      enabled: false
      size: 2Gi
  server:
    persistentVolume:
      enabled: true
      size: 2Gi
</code></pre>

user3142695
<p>In general, it's hard to modify the <em>output</em> of a Helm chart.  You can configure things the chart author has specifically allowed using Helm template syntax but not make arbitrary changes.</p>
<p>Typically I would expect a chart to not include an explicit <code>namespace:</code> at all, and to honor the <code>helm install --namespace</code> option (<code>helm template</code> has a similar option).  Configuring a Service is extremely common and I would expect the chart to have settings for that.</p>
<p>If you're using the official <a href="https://docs.gitlab.com/charts/" rel="nofollow noreferrer">GitLab cloud native Helm Chart</a> then it has a lot of settings, including specifically for the <a href="https://docs.gitlab.com/charts/charts/gitlab/gitlab-shell/index.html" rel="nofollow noreferrer">GitLab Shell chart</a>.  In your <code>values.yaml</code> file you should be able to specify</p>
<pre class="lang-yaml prettyprint-override"><code>gitlab-shell:
  service:
    type: NodePort
    nodePort: 30022
</code></pre>
<p>(These are specific configuration options specific to this chart because the chart author has made them configurable, not a generic way to edit the generated object.)</p>
<p>Generally all of the related objects in a larger-scale deployment need to be in the same namespace.  I don't see an option to manually configure the GitLab shell subchart namespace, and indeed it'd be a little unusual; if it needs to access a global GitLab ConfigMap, for example, those would have to be in the same namespace.  In your specific example the Service and the Pods bound to it need to be in the same namespace.  I'd expect you can use the <code>helm install -n</code> option to move <em>everything</em> to a different namespace, but not on a per-component basis.</p>
