LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-13-2021, 11:58 PM   #1
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
kubectl manifest are not applied even true if confition


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

Last edited by sysmicuser; 02-14-2021 at 05:21 AM.
 
Old 02-14-2021, 06:17 AM   #2
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Changed the shell to bash and it worked.
 
Old 02-14-2021, 08:49 AM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Worked without fi closing the if statement? Doubt it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Basic kubectl and Helm commands for beginners LXer Syndicated Linux News 0 02-11-2020 01:33 PM
kubectl ConfigMap creation fails (or so it seems).. emon_lq Linux - Containers 1 01-06-2020 02:16 PM
LXer: Install kubectl and minikube on Linux LXer Syndicated Linux News 0 06-15-2019 12:20 PM
LXer: The definitive pronunciation guide for kubectl LXer Syndicated Linux News 0 12-24-2018 10:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration