How to pass variable to deployment file

Replace this template with your information

Hi Everyone,

I have my kubernetes deployment file kept in my gitlab branch. Now when i run the CICD pipeline I need to update image name each time I make an deployement.

Is there a way where I can pass an variable to my this file at the time of running the pipeline?

Regards,
Shashil

if I am reading your request correctly you just want to inject a variable into an existing file, correct? If yes, then yes you can. It can be as simple as using sed (or some other editing tool). I would need to know more about your environment, but something along the lines of inserting a placeholder in your template file and they calling

sed -i.bu ā€œs |YOURTEMPLATEVAR|$YOURREPLACEMENTVAR|gā€ ./folder/file.ext

Again this is only based on what I understand of your problem. I hope it starts you to looking outside the box.

Best of luck.

1 Like

Hi Thanks you for your input over my query. I have tried and was able to successfully able to achieve my desired result. Below is the command i have followed.

sed ā€œs/{{PLACE_HOLDER}}/${PLACE_HOLDER:=1}/gā€ | kubectl apply -f -

1 Like