I have the following .yaml file to install redisgraph in kubernetes.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: redisinsight-storage-class
provisioner: 'kubernetes.io/gce-pd'
parameters:
type: 'pd-standard'
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: redisinsight-volume-claim
spec:
storageClassName: redisinsight-storage-class
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redisinsight #deployment name
labels:
app: redisinsight #deployment label
spec:
replicas: 1 #a single replica pod
selector:
matchLabels:
app: redisinsight #which pods is the deployment managing, as defined by the pod template
template: #pod template
metadata:
labels:
app: redisinsight #label for pod/s
spec:
initContainers:
- name: change-data-dir-ownership
image: alpine:3.6
command:
- chmod
- -R
- '777'
- /db
volumeMounts:
- name: db
mountPath: /db
containers:
- name: redisinsight #Container name (DNS_LABEL, unique)
image: redislabs/redisinsight #repo/image
imagePullPolicy: Always #Always pull image
volumeMounts:
- name: db #Pod volumes to mount into the container's filesystem. Cannot be updated.
mountPath: /db
ports:
- containerPort: 8001 #exposed conainer port and protocol
protocol: TCP
volumes:
- name: db
persistentVolumeClaim:
claimName: redisinsight-volume-claim
---
apiVersion: v1
kind: Service
metadata:
name: redisinsight
spec:
ports:
- port: 8001
name: redisinsight
type: LoadBalancer
selector:
app: redisinsight
But the redisinsight pod does not get launched and gives the following error:
INFO 2020-07-03 06:30:08,117 redisinsight_startup Registered SIGTERM handler
ERROR 2020-07-03 06:30:08,131 redisinsight_startup Error in main()
Traceback (most recent call last):
File "./startup.py", line 477, in main
ValueError: invalid literal for int() with base 10: 'tcp://10.69.9.111:8001'
Traceback (most recent call last):
File "./startup.py", line 495, in <module>
File "./startup.py", line 477, in main
ValueError: invalid literal for int() with base 10: 'tcp://10.69.9.111:8001'
My guess is that the port number is tried to be read as int but it comes as a string with protocol, ip address and port. I could also be wrong. This seems like a code issue. Or if there is any other ENV variable that I should set, I will be happy to add it. The documentation is inadequate in kubernetes related things. Any help ?
Once the deployment has been successfully applied and the deployment complete, access RedisInsight. This can be accomplished by exposing the deployment as a K8s Service or by using port forwarding, as in the example below:
The issue only seems to appear when a Service is provisioned to expose the redisinsight endpoint.
You can work around the bug by creating the Deployment first, allowing the redisinsight container to start up, then create the Service. Skipping the startup.py script bug.
Super inconvenient if you’re using Helm to deploy since Helm prioritises the creation of Services before Deployments.
@aniket Do you mean that you want to use Redis as a cache for a node.js application? If so, yes, you can do this. You can get more information here: https://redislabs.com/lp/node-js-redis/
The problem is with the name of the service. Since there’s a service named “redisinsight”, the new environment variables that is created via the service is passed to the redisinsight pod and there’s an environment variable conflict and so the redisinsight pod is crashing.
RedisInsight’s kubernetes documentation has been updated recently. It clearly describes how to create a RedisInsight k8s deployment with and without a service.
IT also explains what to do when there’s a service named “redisinsight” already:
Note - If the deployment will be exposed by a service whose name is ‘redisinsight’, set REDISINSIGHT_HOST and REDISINSIGHT_PORT environment variables to override the environment variables created by the service.
The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that’s not an integer to the int() function . In other words it’s either empty, or has a character in it other than a digit. You can solve this error by using Python isdigit() method to check whether the value is number or not. The returns True if all the characters are digits, otherwise False . The other way to overcome this issue is to wrap your code inside a Python try…except block to handle this error.
Sometimes the difference between Python2.x and Python3.x that leads to this ValueError: invalid literal for int() with base 10 . With Python2.x , int(str(3/2)) gives you “1”. With Python3.x , the same gives you (“1.5”): ValueError: invalid literal for int() with base 10: “1.5”.
RedisInsight has two port variables. RIPORT and REDISINSIGHT_PORT.
The problem is, @psankar has created a service under name REDISINSIGHT which causes k8s to pass service ip details as environment variable in the redisinsight container.
So k8s does <service_name>_PORT = “service-ip”, i.e., REDISINSIGHT_PORT=“service-ip” inside the container which is causing the crash. The solution is to not use “RI” or “Redisinsight” as service name.