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: FAILURE


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: FAILURE