Azure

How To Improve Azure Kubernetes Service Software Utilizing The YAML Recordsdata

 

After the Deployment and Scaling of the Azure Kubernetes service utility, now we have now to Improve the appliance, Utilizing deployments in Kubernetes makes upgrading an utility a simple operation. As with all improve, it is best to have good failbacks in case one thing goes mistaken. A lot of the points you’ll run into will occur throughout upgrades. Cloud-native purposes are purported to make coping with this comparatively straightforward, which is feasible you probably have a really robust improvement staff that embraces DevOps ideas.

 

There are a number of methods we are able to make updates in a Kubernetes cluster. On this article, we’ll use the YAML file to improve the Azure Kubernetes sources,

 

In an effort to improve a Kubernetes service or deployment, we are able to replace the precise YAML definition file and apply that to the at the moment deployed utility. Usually, we use kubectl create to create sources. Equally, we are able to use kubectl apply to make modifications to the sources. The deployment detects the modifications (if any) and matches the Operating state to the specified state. Let’s have a look at how that is performed,

 

Step 1 

 

Open the Cloudshell from Azure Portal, Clone the GitHub repository utilizing the next command. I’ve positioned all of the information there,

  1. git clone https:  
  2. cd Scale-Improve  

Step 2

 

We begin with our guestbook utility to reveal this instance,

  1. kubectl create -f guestbook-all-in-one.yaml  
How To Upgrade Azure Kubernetes Service Application Using The YAML Files  

 

Step 3

 

After a couple of minutes, all of the Pods needs to be operating. Let’s carry out our first improve by altering the service from ClusterIP to LoadBalancer, as we did earlier within the earlier article. Nevertheless, now we’ll edit our YAML file fairly than utilizing kubectl edit. Edit the YAML file utilizing this,

  1. code guestbook-all-in-one.yaml  

Uncomment line 108 on this file to set the kind as LoadBalancer and save the file, as proven within the screenshot,

 

How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

Step 4

 

Apply the change as proven within the following code:

  1. kubectl apply -f guestbook-all-in-one.yaml  
How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

  

Step 5

 

Now you can get the general public IP of the service utilizing the next command: 

Give it a couple of minutes, and you need to be proven the IP as displayed within the screenshot:

 

How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

Step 6

 

We are going to now make one other change. We’ll downgrade the front-end picture line on line 133 from the picture: gcr.io/google-samples/gb-frontend:v4 to the next,

  1. picture: gcr.io/google-samples/gb-frontend:v3  

This variation might be made by opening the guestbook utility within the editor through the use of this acquainted command,

  1. code guestbook-all-in-one.yaml  
 How To Upgrade Azure Kubernetes Service Application Using The YAML Files

 

Step 7

 

Run the next command to carry out the replace and watch the Pods change,

  1. kubectl apply -f guestbook-all-in-one.yaml && kubectl get pods -w  
How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

What you possibly can see right here is that the previous model of the Pods (primarily based on the previous ReplicaSet) will get terminated, whereas the brand new model will get created.

 

Step 8

 

Operating kubectl get occasions | grep ReplicaSet will present the rolling replace technique that the deployment makes use of to replace the front-end photographs as follows,

  1. kubectl get occasions | grep ReplicaSet   

Notice: Within the above step 8, we’re making use of a pipe proven by the | signal  and the grep command. A pipe in Linux is used to ship the output of 1 command to the enter of one other command. In our case, we’re sending the output of kubectl get occasions to the grep command. grep is a command in Linux that’s used to filter textual content. In our case, we’re utilizing the grep command to solely present us strains that comprise the phrase ReplicaSet.

 

How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

You possibly can see within the screenshot that the brand new ReplicaSet will get scaled up, whereas the previous one will get scaled down. Additionally, you will see two ReplicaSets for the entrance finish, the brand new one changing the opposite one Pod at a time 

  1. kubectl get replicaset  
How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

Step 9

 

Kubernetes may even preserve a historical past of your rollout. You possibly can see the rollout historical past utilizing this command,

  1. kubectl rollout historical past deployment frontend  
How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

Step 10

 

Since Kubernetes retains a historical past of our rollout, this additionally allows rollback. Let’s do a rollback of our deployment,

  1. kubectl rollout undo deployment frontend  

It will set off a rollback. Which means the brand new ReplicaSet might be scaled right down to zero cases, and the previous one might be scaled as much as three cases once more. We will confirm this utilizing the next command,

  1. kubectl get replicaset  
How To Upgrade Azure Kubernetes Service Application Using The YAML Files 

 

This reveals us, as anticipated, that the previous ReplicaSet is scaled again to 3 cases and the brand new one is scaled right down to zero cases.

 

Step 11

 

Lastly, let’s clear up once more by operating the kubectl delete command,

  1. kubectl delete -f guestbook-all-in-one.yaml  

Congratulations How To Upgrade Azure Kubernetes Service Application Using The YAML Files You’ve got accomplished the improve of an utility and a rollback to a earlier model. On this instance, you may have used kubectl apply to make modifications to your utility. You possibly can equally additionally use kubectl edit to make modifications, which might be explored within the subsequent article.

Tags
Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close