एक सिंगल कंटेनर को डिप्लॉय करना सरल है। दस को डिप्लॉय करना प्रबंधनीय है। लेकिन एक बार जब आप दर्जनों मशीनों पर सैकड़ों कंटेनर चलाने लगते हैं, तो मैन्युअल मैनेजमेंट केवल कठिन ही नहीं, बल्कि असंभव हो जाता है। आप इस बात का ट्रैक खो देते हैं कि कौन सा कंटेनर कहाँ चल रहा है। एक सर्वर डाउन हो जाता है, और आपका एप्लिकेशन तब तक गायब रहता है जब तक कोई उसे रीस्टार्ट करने के लिए जाग नहीं जाता। इससे पहले कि आप नए इंस्टेंस (instances) शुरू कर सकें, ट्रैफिक स्पाइक्स आपके सेटअप को ओवरवेलम कर देते हैं। यहीं पर Kubernetes की भूमिका शुरू होती है। यह केवल एक और DevOps टूल नहीं है। यह एक ऑर्केस्ट्रेशन लेयर (orchestration layer) है जो कंटेनर मैनेजमेंट को स्क्रिप्टिंग एक्सरसाइज के बजाय एक कंट्रोल प्रॉब्लम के रूप में देखती है।

आखिर स्क्रिप्ट्स अंततः क्यों विफल हो जाती हैं

अधिकांश टीमें शेल स्क्रिप्ट्स या बेसिक ऑटोमेशन से शुरुआत करती हैं। वे इमेज खींचने (pull), कंटेनर शुरू करने, लॉग्स देखने और विफल प्रक्रियाओं को रीस्टार्ट करने के लिए कमांड लिखते हैं। यह दृष्टिकोण 'प्रूफ ऑफ कॉन्सेप्ट' के लिए तो काम करता है, लेकिन वास्तविक दुनिया के लोड के नीचे यह ढह जाता है। माइक्रोसर्विसेज अलग-अलग होस्ट पर एक-दूसरे से बात करती हैं, विशिष्ट एनवायरनमेंट वेरिएबल्स पर निर्भर करती हैं, उन्हें कंटेनर रीस्टार्ट होने के बाद भी सुरक्षित रहने वाले पर्सिस्टेंट स्टोरेज की आवश्यकता होती है, और वे वर्जन्स के बीच निरंतर नेटवर्किंग की अपेक्षा करती हैं। जब कोई वर्चुअल मशीन गायब हो जाती है, तो एक स्क्रिप्ट वर्कलोड को स्वचालित रूप से रीशेड्यूल नहीं कर सकती। यह क्रैश लूप में फंसे इंस्टेंस को छोड़कर स्वस्थ इंस्टेंस के बीच नेटवर्क ट्रैफिक को वितरित नहीं कर सकती। Kubernetes इसे क्लस्टर को ही उन निर्णयों के लिए जिम्मेदार बनाकर हल करता है। आप जो चाहते हैं उसका वर्णन करते हैं, और सिस्टम लगातार उस स्थिति (state) को लागू करता है।

तीन चीजें जो यह आपको प्रदान करता है

Kubernetes तीन मुख्य क्षमताएं प्रदान करता है जो मैन्युअल 'फायरफाइटिंग' (आपातकालीन प्रबंधन) को ऑटोमेटेड विश्वसनीयता से बदल देती हैं।

High availability का अर्थ है कि आपके इंफ्रास्ट्रक्चर के कुछ हिस्से विफल होने पर भी आपके एप्लिकेशन ऑनलाइन रहते हैं। यदि कोई कंटेनर क्रैश हो जाता है, तो Kubernetes कुछ ही सेकंड में उसे बदल देता है। यदि कोई पूरा वर्कर नोड (worker node) बंद हो जाता है, तो शेड्यूलर मिसिंग हार्टबीट को नोटिस करता है और प्रभावित वर्कलोड को क्लस्टर में कहीं और स्वस्थ मशीनों पर स्थानांतरित कर देता है। सिस्टम आपके द्वारा परिभाषित वांछित स्थिति (desired state) पर निरंतर नज़र रखता है और मानवीय हस्तक्षेप के बिना विचलनों को ठीक करता है।

Scalability का अर्थ है कि आपके एप्लिकेशन आपके उपयोगकर्ताओं के साथ बढ़ते हैं। केवल दो घंटे के ट्रैफिक पीक को झेलने के लिए बीस सर्वर प्रोविजन करने के बजाय, आप महत्वपूर्ण मेट्रिक्स (metrics) जैसे CPU उपयोग या रिक्वेस्ट लेटेंसी (request latency) को परिभाषित करते हैं, और थ्रेशोल्ड पार होने पर क्लस्टर को अधिक कंटेनर इंस्टेंस जोड़ने देते हैं। जब मांग कम होती है, तो रेप्लिका काउंट (replica count) फिर से कम हो जाता है। आप केवल उतना ही भुगतान करते हैं जितनी आपको आवश्यकता होती है।

Disaster recovery का अर्थ है कि क्रैश के बाद आपका डेटा और कॉन्फ़िगरेशन वापस मिल जाता है। Kubernetes पूरे क्लस्टर की स्थिति को एक डिस्ट्रिब्यूटेड की-वैल्यू स्टोर (distributed key-value store) में संग्रहीत करता है। यदि कोई बड़ी विफलता वर्कर नोड्स या कंट्रोल प्लेन के किसी हिस्से को भी मिटा देती है, तो वह संग्रहीत स्थिति सिस्टम को आपके वर्कलोड को ठीक उसी तरह से फिर से बनाने की अनुमति देती है जैसा उन्हें कॉन्फ़िगर किया गया था। आपका डेटा वापस आ जाता है क्योंकि ऑर्केस्ट्रेटर को याद रहता है कि उसे कैसा दिखना चाहिए था।

सेटअप: दिमाग और मांसपेशियां

एक Kubernetes क्लस्टर में दो मौलिक भूमिकाएं होती हैं जिन्हें दिमाग और मांसपेशियां कहा जा सकता है, और यह उपमा व्यवहार में भी सटीक बैठती है।

Master Node दिमाग है। यह आपके कस्टमर-फेसिंग एप्लिकेशन नहीं चलाता है। इसके बजाय, यह कंट्रोल प्लेन घटकों (components) को होस्ट करता है जो कार्यों को शेड्यूल करते हैं, क्लस्टर की स्थिति को प्रबंधित करते हैं, और परिवर्तनों पर प्रतिक्रिया देते हैं। जब आप कोई कमांड जारी करते हैं या कॉन्फ़िगरेशन फ़ाइल सबमिट करते हैं, तो मास्टर नोड तय करता है कि वर्कलोड कहाँ रहना चाहिए, क्या वह स्वस्थ है, और यदि नहीं, तो क्या करना चाहिए।

Worker Nodes मांसपेशियां हैं। प्रत्येक वर्कर एक हल्का एजेंट (lightweight agent) चलाता है जो मास्टर के साथ संचार करता है और वास्तविक पॉड्स (pods) को निष्पादित करने के लिए कंटेनर रनटाइम का उपयोग करता है। ये वे नोड्स हैं जहाँ आपका एप्लिकेशन कोड CPU और मेमोरी का उपयोग करता है। अधिक वर्कर नोड्स जोड़ें, और आपके क्लस्टर की क्षमता बढ़ जाती है। रिडंडेंसी के लिए कॉन्फ़िगर किए गए अधिक मास्टर नोड्स जोड़ें, और आपका कंट्रोल प्लेन व्यक्तिगत हार्डवेयर विफलताओं के प्रति लचीला (resilient) हो जाता है।

Pods, Containers, and Services

Kubernetes के साथ काम करने के लिए, आपको उन तीन शब्दों को समझने की आवश्यकता है जो यह परिभाषित करते हैं कि सॉफ्टवेयर को कैसे पैक किया जाता है और उस तक कैसे पहुँचा जाता है।

Containers वे पैकेज हैं जो आपके एप्लिकेशन को उसकी डिपेंडेंसीज़, लाइब्रेरीज़ और कॉन्फ़िगरेशन के साथ बंडल करते हैं। वे सॉफ्टवेयर को अंतर्निहित होस्ट से अलग (isolate) करते हैं ताकि यह डेवलपमेंट, स्टेजिंग और प्रोडक्शन में एक ही तरह से चले।

Pods are the smallest deployable unit in Kubernetes. A pod wraps one or more containers that need to share resources. They share the same network namespace and can access the same local storage volumes. This is important: you do not deploy a bare container directly. You deploy a pod that holds it. Pods are also intentionally ephemeral. They get created, destroyed, and replaced as conditions change. Their lifespans are dynamic by design.

Services exist because pods are transient. Every time a pod restarts, it likely receives a new internal IP address. If other parts of your application tried to connect to those shifting addresses directly, they would constantly break. A service gives your pods a fixed IP address and DNS name. It acts as a stable front door, load-balancing incoming requests across all healthy pods that match its selector. This decouples your clients from the chaos of individual container life cycles.

Kubernetes at Scale: The Netflix Example

Netflix uses Kubernetes to manage its content delivery network. This infrastructure pushes video streams to millions of viewers simultaneously across the globe. When a popular show drops and demand surges, the cluster scales out the cache nodes that store video segments closer to users. If a regional node fails, traffic reroutes automatically. The result is that movies keep running for millions of people without a manual emergency page to an engineer. The orchestrator handles the scale and the failure so the service continues uninterrupted.

Starting Out: YAML, JSON, and the API Server

Getting started with Kubernetes means leaving behind imperative click-ops and embracing declarative configuration. You write what you want in YAML or JSON files. These manifests describe everything from the container image to the number of replicas, exposed ports, environment variables, and storage mounts. Once your file is ready, you send it to the API server on the master node. The control plane ingests that declaration, stores it in the cluster state database, and then sets to work making reality match your description. You do not tell Kubernetes exactly how to do its job. You tell it what the end result should be, and it figures out the steps.

The Real Takeaway

Kubernetes has a learning curve. The terminology feels dense at first. There are many moving parts, and debugging a distributed system is inherently harder than debugging a single server. But the payoff is operational calm. You stop babysitting individual machines. You stop praying that your startup scripts work during a 3 AM outage. You start designing for failure by default, assuming nodes will die, and trusting the orchestrator to keep your application intact. That shift in mindset, from hoping nothing breaks to knowing the system can handle breakage, is what makes the effort worth it.

Source: What Is Kubernetes? Kubernetes Explained in 15 Mins

Optional learning community: GyaanSetu AI on Telegram