π 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 thekubectlcommands. 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
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