Environment Variables in Kubernetes

Can anyone please check below task. It was completed but still show failed.

Environment Variables in Kubernetes

hi @nithyaks, as per question, your image should be ‘httpd’ instead of ‘redis’

@rahul456

When i tried first time it show image as redis. So I tried with same image. Kindly let me know whether i can get one more chance.

Hi @rahul456 @Inderpreet @kodekloud-support3

my task was print Print Environment Variables
before pressing finish button i have to know where its went wrong
my pod template is

apiVersion: v1
kind: Pod
metadata:
name: print-envars-greeting
spec:
containers:

  • name: print-env-container
    image: bash
    env:
    • name: GREETING
      value: “Welcome to”
    • name: COMPANY
      value: “Dev0ps”
    • name: GROUP
      value: “Industries”
      command: [“echo”]
      args: [“$(GREETING) $(COMPANY) $(GROUP)”]

after creating pod , i am getting pod status as CrashLoopBackOff , where i had done wrong in pd template, please check my pod template and tell me the issue where i had done wrong before pressing finish button, i am waiting for replay

Hello, @jayaram.taragala
You missed $ sign for rest 2 variables.

Thanks #player001 , I missed the $ sign , after giving $ sign to environmental variables also I am getting same issue, can please check it, and rectify my issue

Can you share the error output ? Define ${GREETING} like.

player001 rahul456
nithyaks salilpune1

My Task failed. But i think is correct. Please Advise
image

@chawki, sorry for the issue, this is marked pending for you, please give it an another try.

Thanks for your prompt response.

I give it another try. It’s failed again but now because i misspelled the Word Devops instaed of “DevOps”

Hello, @chawki
Can you please share in the “Review” Section?

my templet is below and the out looks wrong, what I did wrong?

@tylorC, the echo command from redis:latest image apparently does not have arguments, so it prints everything. This explains the -en /n.
The variables aren’t being printed because you declared the env under spec and, according to kubectl explain, the env should be under containers

thanks for the reply, I will try it again

if anyone has an issue completing this task, refer to this doc and make the necessary changes as per the task details.
Yaml example: Use Pod fields as values for environment variables

thanks

@rahul456 please look into it
i believe my task is correct but marked as incorrect due to any validation error
yml

Failure Details:

first ENV ‘GREETING’ value is not ‘Welcome to’

Hi @hjavaid

Its not a validation error, you can see the extra quotes in the logs output.
out

1 Like