← Back to Blog

πŸš€ Day 2: Kubernetes Core Components πŸš€

πŸš€ Day 2: Kubernetes Core Components πŸš€ Here's an updated version of your blog post that includes code and execution scripts for a "Hello World" Kubernetes application, integrating emojis to make it engaging: πŸŒ… Morning Session: πŸŒ… Deep Dive into Pods and Nodes πŸ” In the morning, we e

πŸš€ Day 2: Kubernetes Core Components πŸš€

Here's an updated version of your blog post that includes code and execution scripts for a "Hello World" Kubernetes application, integrating emojis to make it engaging:


πŸŒ… Morning Session: πŸŒ…

  • Deep Dive into Pods and Nodes πŸ”
    In the morning, we explored Podsβ€”the smallest deployable units in Kubernetes, and their relationship with Nodes, which run the workloads.

  • Understanding ReplicaSets and Deployments 🧐
    We also dived into how ReplicaSets ensure the right number of Pods are running, while Deployments manage the process of scaling up and updating your applications efficiently.


πŸŒ„ Afternoon Session: πŸŒ„

  • Hands-on: Creating and Managing Pods πŸ’»
    In the afternoon, we got our hands dirty by creating and managing Pods using the kubectl commands. We looked at how to specify configurations and monitor Pods effectively.

  • Working with ReplicaSets and Deployments βš™οΈ
    The final part of the day was all about interacting with ReplicaSets and Deployments. We learned how to create, update, and scale them to maintain our applications in a robust state.


πŸ‘©β€πŸ’» Hello World Kubernetes Example πŸ‘©β€πŸ’»

Now, let's put our knowledge into action by deploying a simple Hello World application on Kubernetes. Follow these steps:

Step 1: Create a Deployment for Hello World 🌍

Create a YAML file for the Hello World deployment:

helloworld-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world-deployment
spec:
replicas: 2
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: hashicorp/http-echo
args:
- "-text=Hello, Kubernetes!"
ports:
- containerPort: 5678

Step 2: Apply the Deployment πŸ“¦

Execute the following command to deploy the helloworld-deployment.yaml:

kubectl apply -f helloworld-deployment.yaml

This will create a deployment that runs two replicas of the Hello World app.

Step 3: Expose the Deployment with a Service πŸšͺ

Create a Service to expose the deployment so it can be accessed outside the cluster:

helloworld-service.yaml

apiVersion: v1
kind: Service
metadata:
name: hello-world-service
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 5678
selector:
app: hello-world

Apply the service with:

kubectl apply -f helloworld-service.yaml

Step 4: Check the Service URL πŸ”—

Run the following command to get the external IP of the service:

kubectl get service hello-world-service

You should see output like this:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-world-service LoadBalancer 10.0.171.239 80:30112/TCP 1m

Once the EXTERNAL-IP is available, navigate to that address in your browser to see the "Hello, Kubernetes!" message.


πŸ”‘ Key Takeaways πŸ”‘

  • Pods and Nodes form the core infrastructure of Kubernetes.

  • ReplicaSets ensure the desired number of Pods are always running.

  • Deployments help automate updates and scaling operations.

  • Hands-on practice solidifies your understanding of Kubernetes components.

  • We deployed a Hello World app using Kubernetes, which helped demonstrate the power of Deployments and Services.


Feel free to copy and paste this into your WordPress post editor! 😊 If you'd like any additional details or sections, let me know!


Imported from rifaterdemsahin.com Β· 2024