Tick_charts deployment.yaml cannot apply with kubectl

11/22/2019

I am trying to apply the deployment.yaml file to my Kubernetes cluster with the command:
kubectl apply -f .\deployment.yaml
but I get this error:
error: error parsing .\deployment.yaml: error converting YAML to JSON: yaml: line 27: could not find expected ':'

The yaml file is the exact same with the original one at github:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "fullname" . }}
  labels:
    app: {{ template "fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: {{ template "fullname" . }}
      annotations:
        # Include a hash of the config in the pod template
        # This means that if the config changes, the deployment will be rolled
        checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
    spec:
      containers:
      - name: {{ template "fullname" . }}
        image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
        resources:
{{ toYaml .Values.resources | indent 10 }}
        ports:
        - name: api
          containerPort: {{ .Values.config.http.bind_address }}
        {{- if .Values.config.graphite.enabled }}
        - name: graphite
          containerPort: {{ .Values.config.graphite.bind_address }}
        {{- end }}
        {{- if .Values.config.collectd.enabled }}
        - name: collectd
          containerPort: {{ .Values.config.collectd.bind_address }}
        {{- end }}
        {{- if .Values.config.udp.enabled }}
        - name: udp
          containerPort: {{ .Values.config.udp.bind_address }}
        {{- end }}
        {{- if .Values.config.opentsdb.enabled }}
        - name: opentsdb
          containerPort: {{ .Values.config.opentsdb.bind_address }}
        {{- end }}
        livenessProbe:
          httpGet:
            path: /ping
            port: api
          initialDelaySeconds: 30
          timeoutSeconds: 5
        readinessProbe:
          httpGet:
            path: /ping
            port: api
          initialDelaySeconds: 5
          timeoutSeconds: 1
        volumeMounts:
        - name: data
          mountPath: {{ .Values.config.storage_directory }}
        - name: config
          mountPath: /etc/influxdb
      {{- if .Values.priorityClassName }}
      priorityClassName: {{ .Values.priorityClassName }}
      {{- end }}
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
      volumes:
      - name: data
      {{- if .Values.persistence.enabled }}
        persistentVolumeClaim:
          claimName: {{ template "fullname" . }}
      {{- else }}
        emptyDir: {}
      {{- end }}
      - name: config
        configMap:
          name: {{ template "fullname" . }}

So according to the error message,the line 27:

26 {{ toYaml .Values.resources | indent 10 }}
27         ports:
28         - name: api

is missing a : , which according to what I see it is there. Why do I get this error?

-- Flora Biletsiou
indentation
kubectl
kubernetes
yaml

1 Answer

11/22/2019

Not sure why you are trying to apply simple helm's deployment.yaml(that is skeleton for Values.yaml file)

In order to install it correctly I suggest you follow the latest InfluxDB documentation and install with Helm from stable/influxdb repo.


Install helm:

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller / helm init --service-account tiller --upgrade(in case you have already done heln init)
helm repo update

Install chart:

helm install --name my-release stable/influxdb

LAST DEPLOYED: Fri Nov 22 14:10:41 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                 DATA  AGE
my-release-influxdb  1     1s

==> v1/Pod(related)
NAME                   READY  STATUS   RESTARTS  AGE
my-release-influxdb-0  0/1    Pending  0         1s

==> v1/Service
NAME                 TYPE       CLUSTER-IP  EXTERNAL-IP  PORT(S)            AGE
my-release-influxdb  ClusterIP  *.*.*.*   <none>       8086/TCP,8088/TCP  1s

==> v1/StatefulSet
NAME                 READY  AGE
my-release-influxdb  0/1    1s


NOTES:
InfluxDB can be accessed via port 8086 on the following DNS name from within your cluster:

- http://my-release-influxdb.default:8086

You can easily connect to the remote instance with your local influx cli. To forward the API port to localhost:8086 run the following:

- kubectl port-forward --namespace default $(kubectl get pods --namespace default -l app=my-release-influxdb -o jsonpath='{ .items[0].metadata.name }') 8086:8086

You can also connect to the influx cli from inside the container. To open a shell session in the InfluxDB pod run the following:

- kubectl exec -i -t --namespace default $(kubectl get pods --namespace default -l app=my-release-influxdb -o jsonpath='{.items[0].metadata.name}') /bin/sh

To tail the logs for the InfluxDB pod run the following:

- kubectl logs -f --namespace default $(kubectl get pods --namespace default -l app=my-release-influxdb -o jsonpath='{ .items[0].metadata.name }')



kubectl get all -l app=my-release-influxdb
NAME                        READY   STATUS    RESTARTS   AGE
pod/my-release-influxdb-0   1/1     Running   0          11m

NAME                          TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
service/my-release-influxdb   ClusterIP   CLUSTER-IP  EXTERNAL-IP  PORT(S)            AGE
my-release-influxdb  ClusterIP  *.*.*.*    <none>        8086/TCP,8088/TCP   11m

NAME                                   READY   AGE
statefulset.apps/my-release-influxdb   1/1     11m
-- VKR
Source: StackOverflow