Articles → MICROSOFT AZURE → Create The Kubernetes Cluster Using The CLI Commands

Create The Kubernetes Cluster Using The CLI Commands






Create And Upload App.Yml And Service.Yml






apiVersion: apps/v1
kind: Deployment
metadata:
 name: app-deployment
spec:
 replicas: 1
 selector:
   matchLabels:
     app: my-app
 template:
   metadata:
     labels:
       app: my-app
   spec:
     containers:
     - name: my-image
       image: nginx
       ports:
       - containerPort: 80




apiVersion: v1
kind: Service
metadata:
 name: my-service
spec:
 type: LoadBalancer
 ports:
 - port: 80
 selector:
   app: my-app





Code For Kubernetes Creation




// Create a new resource group
az group create --name kubernetes --location eastus
// Create a new Kubernetes cluster
az aks create --resource-group kubernetes --name companycluster --node-count 1 --enable-addons monitoring --generate-ssh-keys
// Get the credentials of the cluster
az aks get-credentials --resource-group kubernetes --name companycluster
// Get the nodes running in the cluster
kubectl get nodes
// Apply the application configuration file
kubectl apply -f app.yml
// Apply the service configuration file
kubectl apply -f service.yml
// Get the list of services running in Kubernetes
kubectl get service



Output


Picture showing the output of creating the kubernetes cluster using the CLI commands
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, May 16, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250