Article 5E5DF kubectl manifest are not applied even true if confition

kubectl manifest are not applied even true if confition

by
sysmicuser
from LinuxQuestions.org on (#5E5DF)
Hello,

I have shell script as like below;

Code:ns_exists=$(kubectl get ns | grep ${consider_namespace} || true )
if [ -z "${ns_exists}" ]
then
echo "No namespace ${consider_namespace} exists in the cluster ${target_cluster}"
echo "Creating namespace ${consider_namespace} in the cluster ${target_cluster}"
kubectl apply -f ${BUILD_NUMBER}-${source_cluster}-${consider_namespace}-namespace.yaml
else
echo "Continue further procesing"However, I get an error like the below:

Code:++ kubectl get namespaces
++ grep test
+ ns_exists=
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURElatest?d=yIl2AUoC8zA latest?i=wXzxMyJvK_Y:X97jIxyWKYQ:F7zBnMy latest?i=wXzxMyJvK_Y:X97jIxyWKYQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=wXzxMyJvK_Y:X97jIxyWKYQ:gIN9vFwwXzxMyJvK_Y
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments