Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views3 pages

Experiment 4

The document outlines the steps to install and configure kubectl, the command-line tool for Kubernetes, and deploy a sample nginx application. It includes prerequisites, installation instructions, and commands for managing the Kubernetes cluster and validating the deployment. The conclusion confirms successful installation and deployment, along with the ability to inspect various Kubernetes components using kubectl.

Uploaded by

surekha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Experiment 4

The document outlines the steps to install and configure kubectl, the command-line tool for Kubernetes, and deploy a sample nginx application. It includes prerequisites, installation instructions, and commands for managing the Kubernetes cluster and validating the deployment. The conclusion confirms successful installation and deployment, along with the ability to inspect various Kubernetes components using kubectl.

Uploaded by

surekha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

🧪 Experiment: Installing Kubectl and Deploying Your

First Kubernetes Application

✅ Objective:
 To install and configure kubectl, the Kubernetes command-line tool.
 To use kubectl to interact with the cluster.
 To deploy a sample Kubernetes application (nginx).
 To validate its deployment using Kubernetes services.

🧰 Tools Required:
 A working Kubernetes cluster (local using Minikube/kubeadm, or on cloud)
 Ubuntu/Linux system or terminal (Windows WSL also works)
 Internet access
 User permissions to run kubectl

📚 Theory:
🔷 What is kubectl?
 kubectl is a command-line tool that allows you to communicate with the Kubernetes
API server.
 It helps in deploying, inspecting, and managing Kubernetes applications.

🔧 Part A: Install kubectl on Ubuntu/Linux


Step 1: Download the Latest kubectl Binary
curl -LO "https://dl.k8s.io/release/$(curl -L -s
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Step 2: Make Binary Executable


chmod +x kubectl
sudo mv kubectl /usr/local/bin/

🔽 Screenshot Placeholder: Kubectl Installed Successfully

Step 3: Verify Installation


kubectl version --client

🔽 Expected Output: Shows kubectl version details


🔧 Part B: Configure kubectl (If Not Done
Automatically)
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

🔽 Screenshot Placeholder: Config Setup for kubectl

🔧 Part C: Run kubectl Cluster Management


Commands
🔹 Check Cluster Nodes:
kubectl get nodes

🔹 Check Namespaces:
kubectl get namespaces

🔹 Get System Pods:


kubectl get pods -n kube-system

🔽 Screenshot Placeholder: kubectl get nodes and get pods output

Part D: Deploy Your First Kubernetes Application


Step 1: Run Nginx Application
kubectl create deployment my-nginx --image=nginx

Step 2: Verify Deployment


kubectl get deployments
kubectl get pods

Step 3: Expose Deployment as a Service


kubectl expose deployment my-nginx --type=NodePort --port=80

Step 4: Get Service Details


kubectl get svc

🔽 Expected Output: Shows service my-nginx with assigned NodePort


✅ Output:
 A fully running nginx pod in Kubernetes.
 Exposed to outside via NodePort.
 Validated using kubectl get commands.

🌐 (Optional) Step: Access the Application


If using Minikube:
minikube service my-nginx

If on EC2 or kubeadm, use:


http://<Node-IP>:<NodePort>

📌 Conclusion:
 You’ve successfully installed kubectl and used it to interact with your Kubernetes
cluster.
 Deployed a sample nginx application and exposed it as a service.
 Learned to inspect deployments, services, and pods using kubectl.

You might also like