 Okay, so hello everyone, my name is Dave Nielsen. As I mentioned earlier, I am the founder of the Silicon Valley Cloud Foundry Meetup Group and we've been running meetups now for about three years. And for my day job, I do consulting and my primary focus is on platform consulting. So how do companies figure out how to get their platform up and running? And that can mean one that they buy or download and run themselves or it can be a company who has a platform that they want to market to others. So basically all things platforms. And I'm doing some consulting right now with Alatoros, which is a consulting company as well, but they specialize in deploying Cloud Foundry. And then some of you, I don't know if any of you are familiar with some of the events that I've run in the past. I started something called Cloud Camp back in 2008 and we ran about 350 Cloud Camps around the world in about 100 cities with about 50,000 people, all grass roots, and if you happened to have gotten here early yesterday and you attended the CF camp, that was something that I organized and I really enjoy those kind of events because it helps me learn a lot about what's going on in the street. So if you want to follow me, you can follow me at Dave Nielsen on Twitter. If you want to contact me, I'll just play this information later so you can write it down. I just want to give a special thanks to Alatoros. They're really the ones who've been sponsoring me to do a lot of the work that I'm doing. I'm consulting with them and a lot of the experience I've had has been in running events and workshops that they have sponsored. So a shout out to them. So the main goal here of this talk is to talk about deploying your first app to Cloud Foundry but of course first we've got to talk about why you're going to deploy your first app to Cloud Foundry. And there's a couple of basic examples. You can deploy, run, and scale your application as needed. You can choose from a variety of run times and frameworks. So you're not limited to any particular set of code as long as there's somebody who's open sourced a build pack or the framework that you need to run on Cloud Foundry, you should be able to do so. And there's a very quickly growing third party service broker ecosystem so that just like when you deploy your application, if your application needs to use services, there's a lot of services out there that are already running for you or that you can deploy next to Cloud Foundry and use as a service as well. So it's becoming easier and easier to get all the things that your application needs as a service. And as I said earlier, there's a growing ecosystem, not just a third party service brokers but also different platforms out there. So folks who are taking Cloud Foundry and hosting it for you or providing a downloaded version that you can use, a distribution if you will. So Cloud Foundry as a product itself can be hosted for you or you can download it and it's open sourced so we're seeing a lot of innovation around Cloud Foundry. Folks are doing things that you might not have thought you would do with Cloud Foundry because it's open sourced and they can. And you have a choice between both public and private clouds. So, but you know really the reason why we like Cloud Foundry is as a developer you can deploy your application and it goes up onto a compute cluster essentially and now your code, your application code can scale out horizontally and you as a developer don't have to do much to make that happen. So once it's set up for you as a developer, you don't really have to worry about the nuts and bolts of how your virtual machines or your containers, et cetera, are set up. That's done for you as a service. But let me clarify a little bit more on this concept of Cloud Foundry, the software versus Cloud Foundry, the service. A lot of folks get confused about this and I just want to make sure that we're on the same page. Because Cloud Foundry is actually just software. It's not a service, it's software. However, you can choose to download that and or purchase it, you know, a license to it from one of the distribution vendors and run it yourself. Now once you run it yourself, when I say you, I mean you're the IT department, you're not the developer. So Cloud Foundry is not really meant for developers to download and run. It's meant for IT departments to set up and run inside of your company. You know, system architects, you know, your data center folks, they're going to be interested in setting up Cloud Foundry, not the developers. If you're going to deploy just one application, Cloud Foundry is probably not the right thing for you unless this is a massive application and Cloud Foundry can help you scale out. Cloud Foundry as a software solution is something that you would download and set up and then give all of your developers access to that so they can quickly deploy their applications and then you're providing a cloud for them. And that's what most people are doing with Cloud Foundry. They're getting a distribution and setting it up and then offering it to their developers. You can also use it as a service. But before I get to that, let me just point out some of the options you have if you want to download and run the software yourself. It's open source, so there's a lot of vendors out there. It's not just these, but these are the main ones. There's Pivotal, of course. There's ActiveState Staccato. There's IBM. It has something called Bluemix Local. HP, Helion Dev Platform. And you can also, if you really want to, you can download the open source version and run just that. So if you download it yourself, then, yeah, you can create your own Cloud Foundry as a service for your company or for your employees or offer it as a public cloud. So this is what Cloud Foundry, the software, looks like. It's got all these components that basically run your cloud for you. It's a little bit of an outdated diagram, but this is the general idea. And this is not something that you, as a developer, should have to worry about. This is what your IT folks, your sysadmins, your architects, they're going to look at this and figure out how it works and set it up for your company. Now, what about Cloud Foundry, the service? So, like I said, you could set it up for others to use. They could be your employees. They could be on the public cloud new customers who are paying you to provide that service. There are two predominant ones right now, which is Pivotal Web Services, which is different than Pivotal CF. Pivotal CF is a software. Pivotal Web Services is the service running. You can use that, and that way, your developers go straight to that, and you don't have to have IT staff setting it up. Same goes with IBM Bluemix Cloud Platform. That's a service, and you can use that as well. And there's others out there. I just don't have as much familiarity with them. I think I need to go find out more about those, but I wanted to mention some of them that I knew about, like AppFog and N9 and Canopy. There's some others out there. Okay, so you can deploy your application to onto these clouds, and the idea here is that the vendors are collaborating on the Cloud Foundry code base, but then they're competing on the software ease of use or extending the software to offer additional services. But the core of Cloud Foundry is open source and it remains consistent across most of the vendors. So in this particular session, what I wanted to do is focus more on the services, because if you're going to deploy your first app, I recommend not downloading Cloud Foundry and installing it and then deploying your first app. Simply go to one of the public clouds first and try it there. You'll get a sense for what Cloud Foundry can do. You can poke around and see what these, these are the two primary ones that I'd recommend. Pivotal and Bluemix. And, you know, you can poke around and see what it's like. Okay. So once you've set it up, it's supposed to be easy. And, you know, you may have seen this haiku earlier. I'm not sure. I saw somebody tweet it. You know, here's my source code. Run it on the cloud for me. I do not care how. As a developer, you just want to be creative. You want to get functionality into your application. You want to push it out there and get feedback. You really don't want to have to worry about, oh shoot, this one VM didn't start the way I expected or I have some patches to deal with. You know, you just don't want to deal with that. All right? So what a developer should be doing is really something called CF push. And this is something you need to do to basically move your application code from your laptop up into the Cloud Foundry service that you've chosen. And then that service is going to automatically take that code and create a container image that's going to be stored as a binary and then as you need to scale out your application it will take that binary image and deploy it as many times as you need. And each one of those deployments is a container instance running in the Cloud and gives you more compute power to serve your customers. So you may need one if you're just starting out. You don't have very many customers or you may need hundreds if you have a very large application with lots of customers. So yeah, and then like I said before you can tell it to scale up or scale down as you need and that's really nice. It's not a lot of complexity for the developer. So I know I don't have a lot of time here but what I wanted to do is just kind of quickly show you what the seven steps to CF push would be. So if you're going to try this for your first time then you're going to go to one of those Cloud Foundry service providers I mentioned and you'll basically go through this process. So let's shoot over here, see if that works. Oh and by the way, I have a workshop that I've been giving and if you want to download this document it's a quick start guide. It's basically the same thing that I'm showing you here and I'll show you the URL again at the end of the slide so you can download it there or copy the URL but it's basically cloudworkshop.org slash cloudfoundry and it's just my own little landing page. So let's take a look at Pivotal first. Now I've already logged in here and it's kind of showing me a slightly different view than you might see on your laptop because it's formatted for the projector here but it'll look a little different but basically the same. And what you're going to do is you're going to go create an account, accounts free. You've got to run.pivotal.io, create your account. By the way, Pivotal does require a text message confirmation code so you'll have to give them a cell phone to receive a text message just to eliminate the folks who are just creating spam and stuff like that. So you go create that account and then you'll log in and this is what you'll see. Remember your email address and password because later on you're going to use that to log in from the command prompt or from terminal. And once you log in, you'll see that you have this org and you have spaces. So an org is basically your team or your group of people working together on a project. And spaces is the different stages. Actually you can organize it however you want but it's the different stages of your application. So you can create a development space, you can create a testing space and you can have a production space. And then what you do is you would deploy your app into each one of those spaces as you progress through the application lifecycle. You can also download a CLI right from this page. It'll just click over and show you where to link. Or you can go to GitHub directly and go to this cloud foundry slash CLI page. Let me show you where that is. Don't go to the download the code page. You don't need the source code for the CLI. What you need is the binary or the installer because unless you want to contribute to the CLI as an open source developer, sure go ahead but you don't need that. You can just scroll down below and find the right download for you. And I recommend if it's your first time just grab one of the installers and just run that. It's very simple but it sets up all the paths and all the things you need to run. So those are the two things you're going to want to do. Create an account and download the CLI. By the way, the same thing. It works just as well on Bluemix. So basically all of the steps that I'm going to show you will work on IBM's Bluemix or Pivotal Web Services. And let's see if I go to the dashboard here. You can see it's similar but different. I'm going to click on the cloud foundry link here. And you can see that there's no applications currently here. But we'll come back to that and we'll see an application running. Okay, I'm going to get rid of this screen here. And then let's see, I guess I have a lot of time left. So now let's go back to my instructions. So at this point I would have created an account, again on either Pivotal or IBM, and I would have downloaded the CLI. And CLI stands for command line interface. It's a very generic term. CLI is out there for lots of different software. So CLI is not the name that we all use for just this. CLI is a very generic term. This is the cloud foundry CLI. You're going to download it and then you're going to run the commands. Now what I've done is shown you a very simple example of how you can try this yourself. I've already got an application, a super simple application stored up on GitHub that you can download. And it really goes as simple as this. Let's see here. Let's say I'm going to create, just to make it easier, I'm going to create a folder called workshop. And then inside this workshop folder, as you can see the code here, it's github.com and it's my github account and then hello cloud git. So I didn't really copy that, but git clone hello cloud.git. Now for those of you who have not used git before, or github, it's just a source code repository and this command is going to download the code right into my laptop here. Hold on a second. I know what I did. Now let's try that again. So it's very quick. It's a very small application so I downloaded it quickly. And from this point, again going back to the steps, I need to move into the folder that it just created. So I just downloaded basically a folder called hello cloud and inside that is some code so let's move into hello cloud. And now you can see it just has a few files. So it's a very simple application. This is super simple. This is kind of the hello world example that you see demonstrated quite often. Now from here, I'm going to go ahead and log in. So I've moved into that folder. Cloud Foundry with the CLI, basically it knows what folder you're in and when it's talking to the cloud service itself, it uses that as that folder as a reference. So it knows that you've got code, application code in that folder and it's basically going to try to take that code and push it up into Cloud Foundry. Now I haven't chosen a cloud yet, but let's go ahead and use... James Waters just gave me a free account at Pivotal, so we'll use that. Thank you, James. And what we're going to do is log in first. So to make sure that you have the CLI running, just type CF and you'll get a bunch of commands. So you can see a whole bunch of commands here and there's lots and lots and lots of them. All right, tons of them. Basically everything you can do from the web interface, you can do from the command line. So it's a very robust command line. Also, while not all of these are implemented on every cloud, most of them are. So if you use a command on one cloud, like Pivotal versus IBM, the command is going to work the same on both of them. You can kind of think of it like Linux in many ways, where the Linux kernel is basically the same from Linux distribution to Linux distribution. But then whether you're a Ubuntu, more canonical with Ubuntu or Red Hat, they compete by adding additional features on top of that Linux kernel. And so they listen to their customers and determine what their set of features they should add and they create Ubuntu or they create Red Hat Linux. But the core remains the same. So Cloud Foundry Open Source is basically the same, no matter what you do. And CLI will basically do the same thing on any cloud, Cloud Foundry Cloud. Okay, so let's go back down here. At this point I'm going to go ahead and log in. So everything starts with CF. And we're going to log in. And this time I'll use... The dash A just simply means what API am I pointing to? And if I don't fat finger this, I can probably get through it quickly. Yeah, I can't see as well. All right, here we go. And it's api.run.pivotal, okay? All right, so it found the endpoint and it actually connected to the server. And now it's pinging me back saying, hey, great, you know, you found me, but I don't know who you are yet. So tell me who you are. Now I can use my email address. This is the email address of the account that I have. And then my password. Hooray, I remember my password. All right, so at this point it says, great, now I know who you are, but I need you to tell me which org and which space you want to use. See, James gave me this one, but actually I'm going to use this, the one I've been using. So I just logged into my own org called dnelson-org. And at this point I'm logged in. He knows who I am. And there's really nothing left to do except for CF push. Now, this may or may not work the first time and I'll explain why it might not work in just a moment. Yeah, okay. If you read the instructions here it says, the host is taken. Now think about it, I'm sharing this cloud with lots of other users. When they say the host is taken, what they mean is the subdomain of the application that we thought you wanted to deploy is already being used by another application. I happen to know because I have a fairly unique subdomain that I've specified in my manifest that's me. So I knew that was going to happen. How do I fix that? Well, let's go ahead and take a look at the files of the application so you can see how Cloud Foundry handles this. So again, let's take a look at the files. You can see that there's five files here. Of these five files, four of them are the application and one of them is the Cloud Foundry manifest. I'm just going to use nano here to make it nice and easy. If you're new to Linux, you can use nano. It's a nice easy text editor. And let's take a look at the file. Now you don't have to have a manifest. When you deploy your application to a Cloud Foundry provider, Cloud Foundry will take a look at the files that you're pushing through the CF push. All those files that get pushed up to Cloud Foundry, they'll take those files, score them, and then go look through them and try to figure out what programming language your application is using. And based on that, it will go grab a build pack to then build the image and then run your application. But it's guessing. And most of the time it guesses right. However, you might not want it to guess. You might want it to be very specific about not only a programming language build pack, but a specific version of a build pack or create your own custom build pack. And so you can see here that with the build parameter here, this is just the YAML file, by the way. It's pretty simple to edit. With this build parameter here, that's the build pack. And I've simply specified a Node.js one. I didn't have to specify that. It's going to use the same one. I've also specified how much memory. I've specified a host. This is the subdomain. And I'm going to just increment this. Let's just put it up to eight. So I think I already used seven as well. Cf Node Hello Cloud. Now I'm going to save this. And I'll go ahead and do my CF push again. Now it's going to go through this process. The process it's going through is actually quite sophisticated. There's a lot going on here. And this is basically the value of Cloud Foundry. It automates all the deployment process so your developers don't have to deal with that. And it does it the same way for everybody. So operations folks can take a look at what's going on with the open source version. If they want to change something, they can. And then they run it for their entire company or division or department, whatever. And then everybody's basically using the same process. This is great for any big company that has a lot of rules and regulations and all these things that they have to go by because they can certify that process once and then all the applications that are deployed from then on are running that same certified process. Okay, so what happened here? Oh, good. It went through. Now I could go through and explain all this but I don't have a lot of time here. I think I've got like five minutes left. So what I'm just going to quickly do is show you that it's telling us that I've got one instance running. It's showing that I've got my 128 megabytes of memory which is what I'd asked for. And it took the domain that this Pivotal Cloud, Pivotal Web Services uses and added my subdomain to it so now I have an application running right here and if I go take a look at it, I can see my application running. It's a really simple app like I said before. The only thing dynamic in that is the zero. And what that's doing is it's using a custom Cloud Foundry routine to simply look at the node and determine how many nodes are running and it's outputting the ID, the instance ID of that node. So there's zero means one in math. Go figure. So in computer science zero means one. So we actually have one running. If we had zero running, we wouldn't even see this page. Now what I can do, like I said before, everything you can do through the UI, you can actually do through the command line. Now what I can do is I can type CfScale and I have to remember the name of my app which I think is CfNodeHelloCloud and then I can say instance and let's say three. Okay. Oh, what happened here? Oh, thank you. Fatfingers. That's what they should call me. Get all fatfingers. So it looks like it worked. If I want to see some details about my app, I can type in CfApp. I'm going to have fatfingers again. Okay. And it's going to tell me some information and you can see that now I've got three instances running and I'm going to go back over to my UI and if I refresh, you'll see that number changing. So that's instance one, instance three, instance one, instance two. Okay. Love the math there. Alright. It's always confusing. Anyway, so that's basically a demo of how you deploy an app and you can scale it. Now it's running on three physical container nodes. Alright. And just to kind of round this out, I can go back to my UI, take a look at the app that was deployed. Here it is right here. I'm going to go and take a look at the UI version of this app and you can see I can do all the same things and at least most of the same things I can do. You can see that I now have three instances running and I can shrink that back down to, let's say, one instance and when I do so, you'll see that it's already killed off those other two instances, so that was fast. I'm going to round this out because I don't have a lot of time to show you how to connect to a database and all the other things but basically the way, let me just show you some slides here, okay, so we deployed the one instance. Let me just fast forward this through this. So the process is you're going to prepare to deploy which is we created our accounts. You're going to identify the endpoint, get your user ID and password. You're going to, if you want, you can actually specify your own full domain name. You don't have to use the one provided but here are the ones that Pivotal and Bluemix provide. Then you go in and edit the manifest, okay, like we saw. These are the variables that you can put in the manifest. There's a lot more information but these are the main ones. Then you push, we just did a CF push but you can also specify the app name. If you want, you can add additional services to your app. The way you do that is you go find your application, you click on the services tab and then you click add from marketplace. Now I only have a minute left here but as you can see Pivotal has a bunch of services that are listed up in their marketplace. I'm not sure I would call this a marketplace. I think of it more as just like a catalog but it's a list of all these third-party services and you can add them. Let's say, for example, I think I'm running out of time here so let me just wrap this up. I'm not going to get too clever here. Let's take the Redis instance. You can view the plans. You can then select the plan, the default plan. It's free. Now at this point, you can configure it and add it. What's being done here is Cloud Foundry is going out using a service broker. It's talking to that third-party service. It's sending it a command saying please add an account to your service for this Cloud Foundry application. That service replies back with the credentials so that application can now contact and talk to that service and those credentials are pushed into memory of the instance of the application. So now in your code, you just refer to the configuration details in your instance just like you would a configuration file that you pushed to your application and now you can get the user ID and the password and all the other details that you need to talk to that service. It's a beautiful way of separating out so that you're not putting user ID and passwords and all that kind of stuff into your source code. This is a service broker concept. Like I said before, these service brokers are extending. There's more and more companies adding service brokers all the time. So you should be able to find most of what you need and if you don't, somebody will probably add it soon. So at this point, I'm out of time. What I can do is I can quickly... Oh, yeah. One last thing I left out, to troubleshoot, there's a really nice log system you can choose. You can type in, well, I won't get into it. But you can type in CF logs and then the application name dash dash recent and you'll see all the logs of your applications. So if something went wrong, you can troubleshoot. If you want, I said here's that URL. You can go download this guide that I've created. I'll put the slides up there too. They're not up there yet, but I'll put them up there too. And you can just follow along the guide. If you have any suggestions or if you catch anything that's not quite clear, please email and let me know. I'd like to make this easy for folks. And my goal, by the way, is to take this and turn it into something that can be offered in schools and get started with Cloud Foundry Workshop. All right, with that, here's my contact information. And I don't have any time here. I don't think, but it says stop, so I better stop. Thank you very much.