𝗟𝗮𝗯𝗲𝗹𝘀 𝗮𝗻𝗱 𝘀𝗲𝗹𝗲𝗰𝘁𝗼𝗿𝘀 𝗶𝗻 𝗞𝘂𝗯𝗲𝗿𝗻𝗲𝘁𝗲𝘀 #90daysofDevops : 𝗔𝗹𝗹 𝘆𝗼𝘂 𝗻𝗲𝗲𝗱 𝘁𝗼 𝗸𝗻𝗼𝘄 🔥

¡

2 min read

Labels and Selectors

👉We can specify labels on pod to define and 𝘀𝗲𝗹𝗲𝗰𝘁𝗼𝗿 is used to extract the labelled pods from cluster.

👉Labels are mechanism you to organise K8S Objects, basically giving name to the pods.

👉A Label is like key value pair without any meaning that can be attached to any object: 𝗽𝗼𝗱, 𝗻𝗼𝗱𝗲 𝗮𝗿𝗲 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 𝗶𝗻 𝗞𝟴𝘀.

👉Labels are similar to 𝘁𝗮𝗴𝘀 in AWS or GIT. Use the label for quick reference.

👉Free to choose labels as you need it to refer an environment which is used for dev or testing or production. 𝘌𝘹𝘢𝘮𝘱𝘭𝘦: 𝘥𝘦𝘷𝘈, 𝘥𝘦𝘷𝘉, 𝘛𝘦𝘴𝘵𝘪𝘯𝘨 𝘢𝘴 𝘭𝘢𝘣𝘦𝘭𝘴 𝘵𝘰 𝘥𝘦𝘧𝘪𝘯𝘦

𝙒𝙚 𝙘𝙖𝙣 𝙙𝙚𝙛𝙞𝙣𝙚 𝙢𝙪𝙡𝙩𝙞𝙥𝙡𝙚 𝙡𝙖𝙗𝙚𝙡𝙨 𝙤𝙣 𝙖 𝙨𝙞𝙣𝙜𝙡𝙚 𝙤𝙗𝙟𝙚𝙘𝙩 (𝙣𝙤𝙙𝙚, 𝙥𝙤𝙙).

𝗪𝗲 𝘄𝗿𝗶𝘁𝗲 𝗹𝗮𝗯𝗲𝗹 𝗶𝗻 𝗺𝗲𝘁𝗮𝗱𝗮𝘁𝗮 𝗶𝗻 𝘁𝗵𝗲 𝘆𝗺𝗹 𝗳𝗶𝗹𝗲 (𝗸𝗲𝘆: 𝘃𝗮𝗹𝘂𝗲 𝗽𝗮𝗶𝗿). After changes in yml apply it. 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘢𝘱𝘱𝘭𝘺 -𝘧 𝘱𝘰𝘥𝘴.𝘺𝘮𝘭

𝗧𝗼 𝗰𝗵𝗲𝗰𝗸 𝗹𝗮𝗯𝗲𝗹𝘀 & 𝗽𝗼𝗱𝘀: 𝗣𝗼𝗱: 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘱𝘰𝘥𝘴 --𝘴𝘩𝘰𝘸-𝘭𝘢𝘣𝘦𝘭𝘴 𝗡𝗼𝗱𝗲: 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘯𝘰𝘥𝘦𝘴 --𝘴𝘩𝘰𝘸-𝘭𝘢𝘣𝘦𝘭𝘴

𝗤. 𝗛𝗼𝘄 𝘁𝗼 𝗽𝘂𝘁 𝗹𝗮𝗯𝗲𝗹𝘀 𝗼𝗻 𝗲𝘅𝗶𝘀𝘁𝗶𝗻𝗴 𝗽𝗼𝗱 ? 𝗜𝗺𝗽𝗲𝗿𝗮𝘁𝗶𝘃𝗲 𝘄𝗮𝘆(without yml): 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘭𝘢𝘣𝘦𝘭 𝘱𝘰𝘥𝘴 <𝘱𝘰𝘥-𝘯𝘢𝘮𝘦> <𝘬𝘦𝘺>=<𝘷𝘢𝘭𝘶𝘦> 𝘦𝘹: 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘭𝘢𝘣𝘦𝘭 𝘱𝘰𝘥𝘴 𝘢𝘮𝘪𝘵-𝘱𝘰𝘥 𝘮𝘺𝘯𝘢𝘮𝘦=𝘢𝘮𝘪𝘵

𝙉𝙤𝙩𝙚: 𝙇𝙖𝙗𝙚𝙡𝙨 𝙙𝙤 𝙣𝙤𝙩 𝙥𝙧𝙤𝙫𝙞𝙙𝙚 𝙪𝙣𝙞𝙦𝙪𝙚𝙣𝙚𝙨𝙨 𝙪𝙣𝙡𝙞𝙠𝙚 𝙣𝙖𝙢𝙚𝙨/𝙐𝙄𝘿

𝗖𝘂𝗿𝗿𝗲𝗻𝘁𝗹𝘆 𝗔𝗣𝗜 𝘀𝘂𝗽𝗽𝗼𝗿𝘁 𝟮 𝘁𝘆𝗽𝗲𝘀 𝗼𝗳 𝗹𝗮𝗯𝗲𝗹𝘀 - 𝘀𝗲𝗹𝗲𝗰𝘁𝗼𝗿𝘀: 𝟭. 𝗘𝗾𝘂𝗮𝗹𝗶𝘁𝘆 𝗯𝗮𝘀𝗲𝗱 (=, !=)

𝗤. 𝗛𝗼𝘄 𝘁𝗼 𝗹𝗶𝘀𝘁 𝗽𝗼𝗱𝘀 𝘄𝗶𝘁𝗵 𝗺𝗮𝘁𝗰𝗵𝗶𝗻𝗴 𝗹𝗮𝗯𝗲𝗹𝘀? 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘱𝘰𝘥𝘴 -𝘭 <𝘬𝘦𝘺>=<𝘷𝘢𝘭𝘶𝘦> 𝘦𝘹: 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘱𝘰𝘥𝘴 -𝘭 𝘮𝘺𝘯𝘢𝘮𝘦=𝘢𝘮𝘪𝘵

𝗤. 𝗪𝗮𝗻𝘁 𝘁𝗼 𝗲𝘅𝗰𝗹𝘂𝗱𝗲 𝗽𝗼𝗱 𝘄𝗶𝘁𝗵 𝗺𝗮𝘁𝗰𝗵𝗶𝗻𝗴 𝗹𝗮𝗯𝗲𝗹𝘀 𝗮𝗻𝗱 𝗼𝘁𝗵𝗲𝗿𝘀 𝘁𝗼 𝘀𝗵𝗼𝘄 𝘂𝗽? 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘱𝘰𝘥𝘴 -𝘭 𝘮𝘺𝘯𝘢𝘮𝘦!=𝘢𝘮𝘪𝘵

𝗤. 𝗧𝗼 𝗱𝗲𝗹𝗲𝘁𝗲 𝘁𝗵𝗲 𝗽𝗼𝗱𝘀 𝗺𝗮𝘁𝗰𝗵𝗶𝗻𝗴 𝗮 𝗹𝗮𝗯𝗲𝗹? 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘥𝘦𝘭𝘦𝘵𝘦 𝘱𝘰𝘥 -𝘭 𝘮𝘺𝘯𝘢𝘮𝘦=𝘢𝘮𝘪𝘵

𝟮. 𝗦𝗲𝘁 𝗯𝗮𝘀𝗲𝗱: we can match multiple values 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘱𝘰𝘥𝘴 -𝘭 '𝘢𝘱𝘱 𝘪𝘯 (𝘧𝘳𝘰𝘯𝘵𝘦𝘯𝘥, 𝘣𝘢𝘤𝘬𝘦𝘯𝘥)' 𝘬𝘶𝘣𝘦𝘤𝘵𝘭 𝘨𝘦𝘵 𝘱𝘰𝘥𝘴 -𝘭 '𝘢𝘱𝘱 𝘯𝘰𝘵𝘪𝘯 (𝘧𝘳𝘰𝘯𝘵𝘦𝘯𝘥, 𝘣𝘢𝘤𝘬𝘦𝘯𝘥)' 𝗡𝗼𝘁𝗲: 𝗮𝗽𝗽 𝗶𝘀 𝗸𝗲𝘆 𝗮𝗻𝗱 𝗳𝗿𝗼𝗻𝘁𝗲𝗻𝗱 𝗮𝗻𝗱 𝗯𝗮𝗰𝗸𝗲𝗻𝗱 𝗶𝘀 𝘃𝗮𝗹𝘂𝘂𝗲.

Thanks for supporting this journey transition to DevOps Engineer.

Â