<p>I'm getting the following error, when I try to deploy nexus using Kubernetes.</p>
<p><em>Command:</em> <code>kubectl appy -f templates/deployment.yaml</code></p>
<blockquote>
<p>error parsing templates/deployment.yaml: json: line 1: invalid
character '{' looking for beginning of object key string</p>
</blockquote>
<p>Please find the below code which I'm trying:</p>
<pre class="lang-yaml prettyprint-override"><code>  {{- if .Values.localSetup.enabled }}
  apiVersion: apps/v1
  kind: Deployment
    {{- else }}
  apiVersion: apps/v1
  kind: StatefulSet
    {{- end }}
  metadata:
    labels:
      app: nexus
    name: nexus
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: nexus
    template:
      metadata:
        labels:
          app: nexus
      spec:
    {{- if .Values.localSetup.enabled }}
  volumes:
    - name: nexus-data
      persistentVolumeClaim:
        claimName: nexus-pv-claim
    - name: nexus-data-backup
      persistentVolumeClaim:
        claimName: nexus-backup-pv-claim
    {{- end }}
  containers:
    - name: nexus
      image: &quot;quay.io/travelaudience/docker-nexus:3.15.2&quot;
      imagePullPolicy: Always
      env:
        - name: INSTALL4J_ADD_VM_PARAMS
          value: &quot;-Xms1200M -Xmx1200M -XX:MaxDirectMemorySize=2G -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap&quot;
      resources:
        requests:
          cpu: 250m
          memory: 4800Mi
      ports:
        - containerPort: {{ .Values.nexus.dockerPort }}
          name: nexus-docker-g
        - containerPort: {{ .Values.nexus.nexusPort }}
          name: nexus-http
      volumeMounts:
        - mountPath: &quot;/nexus-data&quot;
          name: nexus-data
        - mountPath: &quot;/nexus-data/backup&quot;
          name: nexus-data-backup
    {{- if .Values.useProbes.enabled }}
  livenessProbe:
    httpGet:
      path: {{ .Values.nexus.livenessProbe.path }}
      port: {{ .Values.nexus.nexusPort }}
    initialDelaySeconds: {{ .Values.nexus.livenessProbe.initialDelaySeconds }}
    periodSeconds: {{ .Values.nexus.livenessProbe.periodSeconds }}
    failureThreshold: {{ .Values.nexus.livenessProbe.failureThreshold }}
    {{- if .Values.nexus.livenessProbe.timeoutSeconds }}
  timeoutSeconds: {{ .Values.nexus.livenessProbe.timeoutSeconds }}
    {{- end }}
  readinessProbe:
    httpGet:
      path: {{ .Values.nexus.readinessProbe.path }}
      port: {{ .Values.nexus.nexusPort }}
    initialDelaySeconds: {{ .Values.nexus.readinessProbe.initialDelaySeconds }}
    periodSeconds: {{ .Values.nexus.readinessProbe.periodSeconds }}
    failureThreshold: {{ .Values.nexus.readinessProbe.failureThreshold }}
    {{- if .Values.nexus.readinessProbe.timeoutSeconds }}
  timeoutSeconds: {{ .Values.nexus.readinessProbe.timeoutSeconds }}
    {{- end }}
    {{- end }}

    {{- if .Values.nexusProxy.enabled }}
                    - name: nexus-proxy
                      image: &quot;quay.io/travelaudience/docker-nexus-proxy:2.4.0_8u191&quot;
                      imagePullPolicy: Always
                      env:
                        - name: ALLOWED_USER_AGENTS_ON_ROOT_REGEX
                          value: &quot;GoogleHC&quot;
                        - name: CLOUD_IAM_AUTH_ENABLED
                          value: &quot;false&quot;
                        - name: BIND_PORT
                          value: {{ .Values.nexusProxy.targetPort | quote }}
                        - name: ENFORCE_HTTPS
                          value: &quot;false&quot;
                      {{- if .Values.localSetup.enabled }}
                    - name: NEXUS_DOCKER_HOST
                      value: {{ .Values.nexusProxy.nexusLocalDockerhost }}
                    - name: NEXUS_HTTP_HOST
                      value: {{ .Values.nexusProxy.nexusLocalHttphost }}
                      {{- else }}
                    - name: NEXUS_DOCKER_HOST
                      value: {{ .Values.nexusProxy.nexusDockerHost}}
                    - name: NEXUS_HTTP_HOST
                      value: {{ .Values.nexusProxy.nexusHttpHost }}
                      {{- end }}
                    - name: UPSTREAM_DOCKER_PORT
                      value: {{ .Values.nexus.dockerPort | quote }}
                    - name: UPSTREAM_HTTP_PORT
                      value: {{ .Values.nexus.nexusPort | quote }}
                    - name: UPSTREAM_HOST
                      value: &quot;localhost&quot;
  ports:
    - containerPort: {{ .Values.nexusProxy.targetPort }}
      name: proxy-port
    {{- end }}
    {{- if .Values.nexusBackup.enabled }}
    - name: nexus-backup
      image: &quot;quay.io/travelaudience/docker-nexus-backup:1.4.0&quot;
      imagePullPolicy: Always
      env:
        - name: NEXUS_AUTHORIZATION
          value: false
        - name: NEXUS_BACKUP_DIRECTORY
          value: /nexus-data/backup
        - name: NEXUS_DATA_DIRECTORY
          value: /nexus-data
        - name: NEXUS_LOCAL_HOST_PORT
          value: &quot;localhost:8081&quot;
        - name: OFFLINE_REPOS
          value: &quot;maven-central maven-public maven-releases maven-snapshots&quot;
        - name: TARGET_BUCKET
          value: &quot;gs://nexus-backup&quot;
        - name: GRACE_PERIOD
          value: &quot;60&quot;
        - name: TRIGGER_FILE
          value: .backup
      volumeMounts:
        - mountPath: /nexus-data
          name: nexus-data
        - mountPath: /nexus-data/backup
          name: nexus-data-backup
  terminationGracePeriodSeconds: 10

    {{- end }}

    {{- if .Values.persistence.enabled }}
  volumeClaimTemplates:
    - metadata:
        name: nexus-data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 32Gi
        storageClassName: {{ .Values.persistence.storageClass }}
    - metadata:
        name: nexus-data-backup
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 32Gi
        storageClassName: {{ .Values.persistence.storageClass }}
    {{- end }}
</code></pre>

<p>The template you provided here is the part of helm chart, which can be deployed using <code>helm-cli</code>, not using <code>kubectl apply</code>.</p>

<p>More info on using helm is <a href="https://helm.sh/docs/" rel="nofollow noreferrer">here</a>.</p>

<p>You can also get the instructions to install nexus using helm in <a href="https://github.com/helm/charts/tree/master/stable/sonatype-nexus" rel="nofollow noreferrer">this</a> official stable helm chart.</p>

<p>Hope this helps.</p>
