The deploy scripts shipped with Hono 0.5 fail to deploy Grafana and influxDB on Kubernetes and Openshift.
When running deploy/kubernetes/kubernetes_deploy.sh the step for deploying Grafana/influxDB fails with the following output:
Deploying influxDB & Grafana ...
serviceaccount "useroot" created
secret "influxdb-conf" created
Error from server (BadRequest): error when creating "/home/hak8fe/git/hono/example/target/deploy/kubernetes/influxdb-deployment.yml": Deployment in version "v1beta1" cannot be handled as a Deployment: v1beta1.Deployment: ObjectMeta: v1.ObjectMeta: Labels: ReadString: expects " or n, parsing 136 ...version":0... at {"apiVersion":"extensions/v1beta1","kind":"Deployment","metadata":{"labels":{"app":"hono-metrics","group":"org.eclipse.hono","version":0.5},"name":"influxdb","namespace":"hono"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"hono-metrics","group":"org.eclipse.hono","version":0.5}},"template":{"metadata":{"labels":{"app":"hono-metrics","group":"org.eclipse.hono","role":"influxdb","version":0.5}},"spec":{"containers":[{"args":["-config","/run/secrets/influxdb.conf"],"env":[{"name":"KUBERNETES_NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}}],"image":"influxdb:1.2.4-alpine","imagePullPolicy":"IfNotPresent","livenessProbe":{"initialDelaySeconds":20,"periodSeconds":9,"tcpSocket":{"port":2003},"timeoutSeconds":1},"name":"eclipsehono-influxdb","ports":[{"containerPort":8086,"name":"api","protocol":"TCP"},{"containerPort":8083,"name":"admin","protocol":"TCP"},{"containerPort":2003,"name":"graphite","protocol":"TCP"}],"readinessProbe":{"initialDelaySeconds":5,"periodSeconds":5,"tcpSocket":{"port":2003},"timeoutSeconds":1},"securityContext":{"privileged":false},"volumeMounts":[{"mountPath":"/var/lib/influxdb","name":"influxdb-storage"},{"mountPath":"/run/secrets","name":"conf"}]}],"volumes":[{"emptyDir":{},"name":"influxdb-storage"},{"name":"conf","secret":{"secretName":"influxdb-conf"}}]}}}}
Error from server (BadRequest): error when creating "/home/hak8fe/git/hono/example/target/deploy/kubernetes/influxdb-svc.yml": Service in version "v1" cannot be handled as a Service: v1.Service: ObjectMeta: v1.ObjectMeta: Labels: ReadString: expects " or n, parsing 117 ...version":0... at {"apiVersion":"v1","kind":"Service","metadata":{"labels":{"app":"hono-metrics","group":"org.eclipse.hono","version":0.5},"name":"influxdb","namespace":"hono"},"spec":{"ports":[{"name":"graphite","port":2003,"protocol":"TCP","targetPort":2003},{"name":"admin","port":8083,"protocol":"TCP","targetPort":8083},{"name":"api","port":8086,"protocol":"TCP","targetPort":8086}],"selector":{"app":"hono-metrics","group":"org.eclipse.hono","role":"influxdb"}}}
Error from server (BadRequest): error when creating "/home/hak8fe/git/hono/example/target/deploy/kubernetes/grafana-deployment.yml": Deployment in version "v1beta1" cannot be handled as a Deployment: v1beta1.Deployment: ObjectMeta: v1.ObjectMeta: Labels: ReadString: expects " or n, parsing 136 ...version":0... at {"apiVersion":"extensions/v1beta1","kind":"Deployment","metadata":{"labels":{"app":"hono-metrics","group":"org.eclipse.hono","version":0.5},"name":"grafana","namespace":"hono"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"hono-metrics","group":"org.eclipse.hono"}},"template":{"metadata":{"labels":{"app":"hono-metrics","group":"org.eclipse.hono","role":"grafana","version":0.5}},"spec":{"containers":[{"env":[{"name":"GF_PATHS_DATA","value":"/var/lib/grafana"},{"name":"GF_PATHS_LOGS","value":"/var/log/grafana"},{"name":"KUBERNETES_NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}}],"image":"grafana/grafana:4.2.0","imagePullPolicy":"IfNotPresent","livenessProbe":{"httpGet":{"port":3000},"initialDelaySeconds":20,"periodSeconds":9,"timeoutSeconds":1},"name":"eclipsehono-grafana","readinessProbe":{"httpGet":{"port":3000},"initialDelaySeconds":5,"periodSeconds":5,"timeoutSeconds":1},"securityContext":{"privileged":false},"volumeMounts":[{"mountPath":"/var/log/grafana","name":"grafana-logs"},{"mountPath":"/var/lib/grafana","name":"grafana-data"}]}],"serviceAccountName":"useroot","volumes":[{"emptyDir":{},"name":"grafana-logs"},{"emptyDir":{},"name":"grafana-data"}]}}}}
Error from server (BadRequest): error when creating "/home/hak8fe/git/hono/example/target/deploy/kubernetes/grafana-svc.yml": Service in version "v1" cannot be handled as a Service: v1.Service: ObjectMeta: v1.ObjectMeta: Labels: ReadString: expects " or n, parsing 117 ...version":0... at {"apiVersion":"v1","kind":"Service","metadata":{"labels":{"app":"hono-metrics","group":"org.eclipse.hono","version":0.5},"name":"grafana","namespace":"hono"},"spec":{"ports":[{"nodePort":31000,"port":3000,"protocol":"TCP","targetPort":3000}],"selector":{"app":"hono-metrics","group":"org.eclipse.hono","role":"grafana"},"type":"NodePort"}}
... done
However, all other services are deployed and seem to work as expected.
The reason for this seems to be missing quotation marks around the version label in the Kubernetes resource descriptors we use for deploying Grafana/influxDB. When the value is something like 0.5-M11 then Kubernetes is smart enough to determine that the value is a string. However, when the value is just 0.5 it tries to parse it as an integer and fails to do so.
This problem can be circumvented quite easily.
If you are deploying using the binary archive downloaded from the Download page, do the following:
eclipse-hono-example-0.5$: sed -i.orig -e 's/version: *0.5/version: "0.5"/' deploy/kubernetes/*.yml
Then deploy using
eclipse-hono-example-0.5$: deploy/kubernetes/kubernetes_deploy.sh
If you are deploying from the source tree, do the following before you run the build:
HONO_HOME$: cd example
HONO_HOME/example$: sed -i.orig -e 's/version: *${project.version}/version: "${project.version}"/' src/main/deploy/kubernetes/*.yml
Then do the build and deploy to Kubernetes as described in the deployment guide.
Thanks @sophokles73
I had to do the following to enable Openshift Deployment
$ sudo sed -i.orig -e 's/version: *0.5/version: "0.5"/' deploy/kubernetes/*.yml
$ sudo sed -i.orig -e 's/version: *0.5/version: "0.5"/' deploy/openshift/*.yml