Blue Green Deployment in Cloud Foundry | Pivotal Web Service | DevOps | Tech Primers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
no one wants to do production deployment during a beaconed in order to do production releases on a weekday we will have to perform no downtime deployments let's see what is Bluegreen deployment and implement a Bluegreen deployment scenario using the pivotal Web Services or pivotal Cloud Foundry let's get started [Music] there's the bell icon on the YouTube back and never miss any update from tech famous before getting into the implementation of the blue-green deployment inside cloud foundry we need to understand the routing principles of the cloud foundry and we need to understand how we can perform Bluegreen deployments using that let's consider an application called the production app which we have running inside the pivotal web services and the version of this particular application is 1.0 this is the production copy which is running and in order to access this application we will be using the URL CI CD - production dot C of apps dot IO CF apps dot IO is where our Cloud Foundry instance is hosted and C a CI CD - production is the hostname of this particular instance so just to understand the internals of how these URL is linked to our application the Cloud Foundry has something called head shape proxies so these are the three different IP addresses which will be faced to the external clients so if you are doing a nslookup on CF apps you might find three different IP addresses these are for load balancing purpose so these are software load balancers which are just hijae proxies so they would be helping the Cloud Foundry instance from getting denial of service attacks and all other chicks underneath the hitch a proxy lies the go router the go router has the mapping of the CI CD production with the production app version 1.0 the core router has internal mappings of where is the production app version 1 deployed and which on which port it is running and what is the map URL or the route so we call it route just for the sake of the discussion let's ignore all the instances of HF proxies and go routers and how only one instance so that we can have a clear understanding of how the routing happens inside the platform by default when we push an application with the hostname a route gets created so in our example CI CD - production got created because we pushed our application by default but this particular route in order to perform our blue/green deployment the production version of the application is called blue as the color suggests the version 1.0 is the blue deployment and we are going to add a new name to that application and call it a CI CD blue so you can do that by using a CLI the CFC Li you can have a map route command so we are going to do that after the explanation of this concept so we are going to create the CI c d blue URL and the CI CD production URL for this application so you can access this application with two different URLs one with CI CD blue the other with CI CD production so the downstreams might be using your application with CI CD production but they won't even know that there is a URL called CI CD blue because that is internal for us we are going to use it for Bluegreen deployment once the production app is running we call it as blue now we need to deploy a new version of the application we are going to call this application as green so CI CD green is the name we are giving to this particular application and the version of this particular application is 2.0 we are going to deploy this freshly as a new instance with a new URL basically a new host name so nobody knows that there is a new instance which is deployed and this won't interrupt the existing production version which is the blue version so what we are going to do as a part of the green is be able to run all our smoke test functional tests and the UI tests and whatnot right we are going to run all these tests in the green instance and make sure the green instance is good so once we confirm that the green instance is good we are going to create a new mapping from the CI production onto the green instance so we are going to add green onto the same CIC reproduction route so which basically means all the blue-green and CIC reproduction are linked together however CIC reproduction is pointing to blue and green both so basically half the traffic will be routed to green and half the traffic will be routed to blue because by default the pivotal Cloud Foundry platform does round robin fashion once the green instance is good we are going to remove the mapping of blue from the CI production so what's happening is blue has its own name called CI CD blue however the routing rule of CI CD production has been removed from blue which basically means all the requests are getting redirected to green now the blue becomes stale right so we are gonna have green as the production version and we are going to remove blue so once the blue is removed now we need to green aim the green black to blue that way this becomes our production copy and we can remove our CI CD blue URL and have the CI CD production as our version so this is how we can do a Bluegreen deployment so the platform will help us in doing it by using the go router so core outer helps us in creating aliases for a particular instance and using these Alice's we can play around by doing Bluegreen deployment so in this video I am going to show you by creating manual commands and deploying it into the Cloud Foundry instance in the next video I will show you how you can do that as a part of Jenkins pipeline and automate it so let's get into the console so I am inside run dot pivotal dot IO let me login to this pivotal web service instance right now if you notice there are no apps which are running there is empty space here so there is no quota I mean there is nothing which is running for us right so we have zero apps I'm going to have the same example which we saw as a part of C ICD Jenkins example in the last video we are going to have the same example however I'm gonna add a new rest endpoint just to show which app is blue and which app is green right I'll just add a new controller called blue controller you so we are going to return blue app version 1.0 we are going to build this particular artifact let me go to the palm XML and name this particular artifact SC ICD - blue - app so we are going to deploy this particular blue app so I'm gonna name this as CI CD blue and let's rename this as well here in the manifest file so if you're not sure about how to use manifest file and stuff like that go to my video on pivotal Cloud Foundry you can take a look at that to understand why do we need manifest and stuff like that so I'm going to use the manifest file which is the blue so the manifest or Tamil I'm just naming the application as CI CD blue and I have given the name of this particular jar as CI CD blue just rename this right so that is the name I have given let me build this particular jar meanwhile I will try to login to the CFC Li the Cloud Foundry CLI when the build is going to build so let me open my command-line interface in IntelliJ I'm going to use the CF login come on and login into the API the API dot run dot pivotal dot IO is the API to login to that pivotal instance and I'm gonna give my username as in for take Prime [Music] rose.com so this will API with the CLI by logging into this specific instance see we are logged in to the CFC Li and let's do CF apps to see what are the different apps which are running right now there are no apps see that that's what this says is a no apps found let's check if the build is successful yep the build is successful let's deploy our application now when we deploy this application it will be deployed as blue all right so this is the first production copy however we need to create a routing rule for it right so we need to create a CI CD production right so let's check if you are able to upload blue and then we will create a route I'll show you how you can create it using CF map route so see if map route is the command with which you can create a alias basically this is the new alias which you can create to access this application so let's first apply the blue and then C in the cloud foundry console you should be able to see this app getting deployed ya see that there is something which is getting allocated in my development space CCI CD Blue is present and right now the route is only CI CD blue if I go to the CI CD option there is a tab called route and if I click on the route I can see different mapping routes and you can even map a route from the UI I'll show you from the command line interface so the application is coming up let's hit the URL and see if it is up it's still not up yeah right now it's up so we have created a resting point called version and this version shows what is the version of this blue app right so it is called blue app - V 1.0 so this is what we created now we are going to create a new alias called as CI CD production so let's use the CF CLI so the command for doing that is CF map - route and we need to give them application which we need to route so the application which we need routers blue and the domain where it is present so CF apps dot IO is the domain where we have the application and what is the destination name we want to map it to so if we are going to map it to CI CD production so this route is going to be created with CI CD production to the blue so now we should be able to access the same blue app with the name CIC reproduction so let's open a new tab and then rename this blue to production and see what is the version which we are getting so the same version is getting displayed the blue app is getting displayed and if we go to the console and if you refresh this particular option we should be able to see two routes see this there are two routes CIC the production and CI CD blue so we have created an alias for our current blue application and we have given downstreams the CI CD - production now if you want to add a change to our application so we are going to add a change to our application by renaming this blue controller into green controller we are not going to change the endpoint the rest endpoint however the value is going to be changed we are going to change this to green version 2.0 and let's create a new manifest file I'll create a new manifest file called manifest - green and inside that I will create the name CIC the green and also I'll give the path or CI CD green I'll change my palm to see ICD green and let's build this artifact now so once we build it under the target if you see there is already see ICD blue now if we build it this should build CI CD green so the build is successful and I'm going to deploy using the CF push command and I'm gonna use the manifest green so we have created a new manifest file called manifest green so let's use this new manifest file so I'll pushing the artifact green with the name see I see the - green so now if we go to the console we can see only one application right now in our odd space and automatically see that the green is getting pushed that's what it says already the green is getting pushed to the creating app so the green is getting created so we have a CI CD blue which has two routes CIC reproduction in CI CD blue and now we have a new application which is getting deployed which is called the CI CD green so that this green get deployed and the next step is to create a route again to the production for the green so the CI see the green got deployed now in order to check the route for the CI see the green let's go to the console see that there is a route created default there by default there's only one route and the name of the router CI CD green now we need to add the new route the CI CD production to this green as well so we are going to use the same map route command and the name of the routers CI CD name of the application is CI CD green and the domain name is CF Apps dot IO the host name the alias which we need is CI CD production so we are going to create a new routing role to the existing C ICD production so we are going to point green also to it so notice that you already get a notification saying CIC reproduction already exists we already know that because for blue we created the same one now for green we are creating the same so if i refresh this route again we should be able to see the CI CD production here so see that there are two routes now so if I click on CI CD green and open in a new tab I'll open green it should show my green app right so it shows green app version 2.0 now if I hit on the see I see the production see that it shows green sometimes then it shows blue so it's in round robin fashion so it shows blue green green interchangeably right so that is how the vertol Cloud Foundry redirects your instance to blue or green based on your request and go router takes care of redirecting this request to different application since the CIC the production is pointing to the both these green and the blue we are getting these interchangeably now if we remove the mapping to the blue instance from the CI CD then the green instance alone should be shown from this so let's go and remove the mapping in order to remove the mapping we have to do a CF unmapped route with the same names so we have to remove the routing for CI CD blue and CF apps dot IO the name which we have to remove CI CD - production so we are going to remove CI CD production from the CIC be blue app so see that CI CD production has been removed from CI CD blue now if I hit the production URL I will be always getting green so I won't be getting blue at all just to cross-check it let's go to the deployment and then see what are the different routes for CI CD blue and there is only one route see this there is only one route now if I need to stop this instance you can do a CF stop I can do CF stop or I can do it from the UI as well I can do CF stop - CI - blue so this will totally stop my application so let me go here to the development see that the CI CD blue has been stopped now if we leave this particular space in this particular state what happens is people who are going to deploy again will get confused which one is blue and which one is green so in order to do that we are going to rename the green to blue so what we can do is we can rename the app using CF rename and we are going to rename it green to blue so we are going to rename the green app to the blue app so the app this is because we already have the app so we can do a delete app see ICD - blue so we can do a sea of delete so we need to delete the CI CD - blue so we can use the CF delete to delete it now if I go to the console I won't see this particular app here I can see only CI city green now in order to rename this we will use the same command see I see a free name CI CD - green to see I see the - blue now the rename is successful see that the renaming is successful and if i refresh this particular UI the console we should be able to see the new app name see that the new app name is CI CD - blue however the route is still see I see the - green you can in fact even use the route ping command to route it so let's do that as well see we have to do a map route again to rename the route so we will do a map route CI CD - green so we will map the green see if perhaps dot IO - hostname CI CD - blue so your mapping green to blue for the route and we will remove the green route in fact I am going to rename this to blue because we had the blue route red I need to rename this to blue because blue is the name of the application however we do not have the route for it so we are just creating the route for blue and blue right so it says blue already exist and let's do an unmapped route for the green one so let's remove the unmapped on the green app so let's do the green here so this will remove the green one on the console so let's go to the refresh so let's go to the routes and then refresh the console now we should be able to see only two there are see icd blue and CIC reproduction see that the removing of CICE green was successfully so this is how you can get back to the same state where it was and this is the green application so if i refresh so I'll just summarize what we did as a part of this particular video so we had an application called CI CD blue recreated it with a blue endpoint and then we deployed that application we created a routing rule called CIC reproduction and we deployed a new application called CI CD green we created a routing rule for the CI CD green by pointing to the same CI city production and we saw that the urls were flipping between blue and the green so the routing rules were flipping across these two instances in round robin fashion now in order to bring the blue down we remove the route and then we deleted the app and then we rename the green back to blue and finally we added the route of blue an unmapped tier out of green so this is how you can do a Bluegreen deployment the platform will make sure that you don't have any downtime because it's going to redirect all your requests to the new instance and if there is a request it is stuck with the old instance it will not kill the process until the request is completed so this is how you can leverage the pivotal Cloud Foundry instance to do Bluegreen deployment in the next video we will see how to automate this using the Jenkins build pipeline as always if you liked the video go ahead and like it if you haven't subscribed to the channel go ahead and subscribe to it meet you again in the next video thank you very much [Music]
Info
Channel: Tech Primers
Views: 7,721
Rating: undefined out of 5
Keywords: techprimers, tech primers, cloud foundry blue green deployment, cf map route, blue green tutorial, blue green deployment in pivotal cloud foundry, blue green deployment example, no downtime deployment, seamless deployment, red black deployment, blue green deployment scenario, blue green deployment commands, how to setup blue green deployment, setup blue green deployment
Id: 2Hz7r70ZuFU
Channel Id: undefined
Length: 20min 40sec (1240 seconds)
Published: Tue Mar 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.