Loading video player...
Hello everyone, welcome back to my
YouTube channel. So in this video we are
going to discuss how we can use if else
conditions along with or and not
functions inside our Halum templates. So
let's understand with the help of
example.
So under template section I have a file
called deployment.mml.
So if you see uh under replica sections
so basically what we are going to uh see
in the demonstrations. So based on the
environments we are going to select
number of replicas. So for example if it
is a dev environment or test environment
then replicas count will be two. If it
is a prod environment then the replica
count should be five. And if it is not a
dev test or prod environment something
else maybe test one dev one dev 2
whatever it is then it is going to
select number of replicas one. Okay. So
now let's understand each line one by
one.
Okay. So if you can see this is the one
argument here we have and this is the
another another argument we have and
here we are going to use or operators.
Sorry not operator or functions. So what
does it mean? If the environment value
is dev or test then it is going to run
this particular block or this number of
replicas it is going to select. Okay. So
let's verify this first. So for that
again I'm going to use helum template
command because I want to run the or
maybe I want to render this templates
locally. So let's run hello
template and let's give name ab
dot.
So you can see it is selected number of
replicas too. Why? Because in values dot
environments
values sorry in values doml file we have
environment value is tab. So if I'll go
to my values doml file here we have a
environment value is tab. That's why it
is executed this particular condition
because it is satisfied. We have not
specified test. Let's verify for test
because test environment value we have
not specified in our uh values.mml file.
So let's see what it select. So let me
clear the screen
here. I will use hyphen - set
and here let's see test.
Okay, so spelling mistake here.
Okay.
Okay. So here you can see again it is
selected number of replicas two because
we have passed the flag hyphen set value
involvement equal to true sorry equal to
test that's why again this particular
condition is satisfied and it is
selected number of replicas two so if I
go here we have a number of replicas two
now if the involvement value is not dev
not tested and if involvement value is
pro then it is going to execute this
particular block that's why here we have
used else if conditions else if equal to
dot values dot environment equal to plot
so now let's try this one
so here I will change the value to trot
so now it is you can see the number of
replicas five because it is not
satisfied this particular conditions
that's why it is going through this
particular block because here it is
easily able able to find the environment
value is brought which is we have passed
as a hyphen - set flag that's why it is
going to this particular block.
Okay. Now let's move to another line
which is little confusing and important
as well. So if uh let's understand first
this argu this value. So in or operator
or or functions one of the argument
values should be true. Either this can
be true or this can be false or or maybe
vice versa. This can be false and this
can be true. So at least one of the
argument values should be true then it
is going to execute all functions. And
if you're going to use not operator
sorry not function basically in that
case here you can see we have three
arguments one argument two argument and
three argument. So in this case here
basically all the argument value should
be true. So if sorry uh so here I have
specified when none of them are true.
Okay. So basically not functions only
work when this value is false this value
is false. This value is false because
not function basically flip the result.
What does it mean? Uh suppose
not value
not equal to. If the if the result the
combination of these all three argument
result is true then not basically flip
this result to false.
This is the function or use case of not
function. It basically flip your result.
So to work this particular block all of
the values should be false.
Then it is going to basically run or it
is going to select number of replicas
one. If all of these values are true
then it is not going inside this block
because if you can see it is going to
satisfy one of this particular
conditions which we have specified here.
So in not functions all of the argument
values should be false then it will flip
the result false to true and it will
execute this particular block. This is
the important point which you have to
keep in mind. Okay. Now let's verify
this.
So now what I will do I will se mention
here involvement value equal to prod one
because we don't have prod one anywhere
here. So what it will do? Let me run
this.
It is selected number of replicas one
because first it is check this
conditions which is false. Then this
argument again it is false and this
argument which is again it's false and
then it basically the not functions flip
the result to false to true and it uh
satisfy this this particular condition
block and it will select this number of
replicas. If we will select any one of
the environment here like prod only then
it is not going to under this particular
condition because it is already satisfy
this particular conditions because here
we have a environment value is pro. So
it will select number of replicas five.
So here we can see number of replicas
five. So these uh conditions and boolean
logics are very important when you are
going to create a generic template. So I
have already uh discussed about if files
with EQ and and end functions as well in
previous videos. If you want you can go
and watch those videos as well. I will
mention this code repository link in
GitHub in a YouTube video uh description
box. So if you want to do hands-on you
can do that. So that's all for today.
See you next video. Thank you so much.
Helm Charts: Master If/Else, Or, & Not Like a Pro 🚀 Want to level up your Helm skills? In this tutorial, you’ll learn how to use conditional logic in Helm charts with if/else, or, and not statements. These powerful templating features will help you create more dynamic, flexible, and production-ready Kubernetes deployments. 🔹 What you’ll learn in this video: ✅ How to use if/else conditions in Helm templates ✅ Combining conditions with or ✅ Negating conditions with not ✅ Best practices for cleaner, smarter Helm charts ✅ Real-world examples for practical understanding Whether you’re a beginner exploring Helm or an intermediate user aiming to refine your skills, this tutorial will give you the confidence to manage Kubernetes deployments more effectively. GitHub Repo - https://github.com/shubhamagrawal17/Tutorial/tree/main/Helm/helm-ifelse-OR-NOT-demo 👉 Don’t forget to like, share, and subscribe for more DevOps and Cloud tutorials! #Helm #Kubernetes #DevOps #CloudComputing