I am using python to interact with a kubernetes cluster. I am trying to retrieve the number of releases by using the following code:
number_of_releases = subprocess.getoutput(f"helm history myRelease --namespace myNamespace -o json | jq length")
When I run print(number_of_releases)
I get 2
(which is my expected result from using normal kubectl) and running print(type(number_of_releases))
shows that this is a string. However, when I try to use int(number_of_releases)
I get an error saying invalid literal for int() with base 10
.
I have tried no_whitespace_variable = number_of_releases.strip()
but curiously the length of the variable no_whitespace_variable
turns out to be 205. Does anyone know what might be happening, or have any further suggestions for troubleshooting?
George Ji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.