Installing kubectl and minikube

Richard Chesterwood
A free video tutorial from Richard Chesterwood
Software developer at VirtualPairProgrammers
4.7 instructor rating • 4 courses • 73,314 students

Learn more from the full course

Kubernetes Hands-On - Deploy Microservices to the AWS Cloud

Use Kubernetes to deploy a Microservice architecture. You'll deploy, manage and monitor a live Kubernetes cluster.

25:20:40 of on-demand video • Updated April 2021

  • Deploy containers to a Kubenetes Cluster
  • Run Kubernetes in AWS using either EKS or Kops
  • Monitor a live Kubernetes cluster using Prometheus and Grafana
  • Analyse system-wide logs using the ELK Stack (ElasticStack); Kibana and ElasticSearch
  • Handle Alerts in a Kubernetes cluster by notifying Slack Channels
  • Understand how Requests and Limits work in Kubernetes
  • Use Kubernetes Horizontal Pod Autoscaling
  • Use RBAC to restrict access to a Kubernetes cluster
  • Configure Ingress Control on a live Kubernetes deployment
  • Understand Kubernetes StatefulSets
  • Integrate Kubernetes with a Continuous Deployment System (CD)
English Instructor: So by now you should have either VirtualBox installed if you're on OSX or if you're on Windows, except for Windows 10 Professional, where you've probably by now got Hyper-V set up. Wow, I think that's the worst of it over now. The job now is we need to instal these two command-line tools called kubectl and Minikube. Let's start with kubectl and the instructions can be found by following the link, here. And kubectl is just a standalone programme. There's no complex installation process required here. It's just a single file that we're going to need on our computer's path. So there's a lot of instructions here and you can, if you want, use a package management system such as apt-get if you're running on Ubuntu and Debian. You can use yum if you're running on CentOS or red hat, and if you go a little further down, if you're on macOS, you could use Homebrew. Brew instal kubectl should do the job. And if you're on Windows you can use the Chocolatey package manager. I don't personally use that, myself. And having said all of that, if you go further down it's just a file that you need to download. So you can if you want. Just download this file directly and put it into a folder somewhere. So there are some instructions on how to do that. On macOS, you're going to do a curl in a terminal window. And then you need to make the binary file executable and put it into your path. So just follow steps one, two, and three here on macOS. Pretty much the same process on Linux. You really don't need a package manager to do this. And finally for Windows, well, you might not have curl installed. So, no problem. Its a simple case of following this link. In fact, that's exactly what I'll do here on the video. So that's kubectl.exe downloading. So all I've done on my Windows installation is I've made a folder called kube. Really it doesn't matter what you call that folder. You can put it anywhere. I have it on a C drive and I've put the kubectl.exe file into that folder. Now this folder will need to be on your path. If you followed the instructions on mac and Linux, you'll have put this file into a folder that's already on your path. So you only need to do this if you're on windows. I'm going to right-click on the PC, go for Properties, and then Advanced system settings. And then click on Environment Variables, and you are looking for the variable called Path. If there isn't one there then create one with New. I already have it, though, so I'll click on Edit. And you can see, there, I already have an entry for C:\kube. You'll need to click that by clicking on New, and just add in C:\ and whatever you've called that folder. And we need to check this. If you're on mac or Linux then you'll just be using your regular terminal window. If you're on Windows you can use the regular command prompt for this course, I guess. You can get that by Windows + R, and then in the open box, cmd. And we can check kubectl with kubectl and you should get a list of all of the commands supported by kubectl. I don't really recommend the command shell for working it on Windows. I'm going to be using Cygwin for the rest of this course, which is a far superior command shell and will support lots of Linux style commands. So kubectl in there, and yes, that's responding correctly. If you want to try Cygwin for yourself, then you can find it from cygwin.com and there's a regular Windows installer here. So hopefully, by now, you have kubectl installed. The next job, if we go back to the manual, here. We'll go back. The next job after installing kubectl is to instal Minikube itself. This is the cut-down version of Kubernetes for a development computer. Follow the link to the latest release. Now, at the time of recording, the version of Minikube is 0.27.0 and this is released fairly frequently, so by the time you watch this, there will probably be a higher version number here. The first thing is there's a list of these assets here, which is all quite bewildering and, you know, which one of these do you need to download? But if you go a little further down, there are some instructions on how to instal. So pretty much as before, for OSX and Linux, you are going to be simply curling it to download, chmod-ing it to make it executable, and then moving it into the path. So just copy that line on OSX or Linux and paste that into your terminal. I wouldn't bother with Linux package managers to be honest. Now, if you're on Windows, what you need to do is download the minikube-windows-amd64.exe file. Bit confused by that. I'm not sure why there isn't an intel version, but it seems to work. So that applies to me. I need to download this and then we need to rename it to Minikube and add it to the path. Now, that will be easy. We'll just put it in the same folder that you put kubectl. So there's no link there. Ill need to find it from here. Minikube-windows-amd64, there it is. I'll let that download off camera. A final note, there is an installer available for Windows. I'll be honest, I've never used it. I'm a little bit suspicious of complicated installers. It's really not needed. This is a simple file. So that's downloaded, then. I need to rename this file, though, to minikube.exe. And be sure that you do have the executable extension. Just one more word for Windows. Now, I know you probably know all this stuff but I've got to be careful. I don't want to lose anybody on these videos. You've got to have extensions enabled, and you do that by- click on the View tab, go to Options, and then on this pop-up, on the View tab you need to deselect Hide extensions for known file types. That's ticked by default. Un-tick it, click Okay, and you should now be able to rename this to minikube.exe. So as I mentioned, for the rest of this course I will be using the Cygwin terminal. If you're on Windows you can use any terminal that you like. The PowerShell or any that you've downloaded. I recommend that you don't mix and match different terminal types. I used to do that in my early days. I'd switch between the PowerShell and Cygwin, and things can get in a real mess if you do that. So we've installed Minikube. We can check it's installed just by typing minikube, and you should get a help page back. Now, all we need to do now is run Minikube. Now, I had some horrible problems getting this working while I was recording the course and I would hate you to have the same problems. What we should be able to do at this stage is to simply type minikube start. Now, as I mentioned in the video, for Windows 10 Professional only, you will also need to enter here --vn-driver=hyperv, that's all one word with no dash and you also need --hyperv-virtual-switch= and then in quote marks, the name of the switch that you created earlier on. I can't test that because I'm not running on Windows 10 Professional, so do let me know if you have problems with that. But for the rest of you, in theory, it should be sufficient to simply type minikube start, so let's try that. And the first thing I'm seeing is it's starting a virtual machine. Now, all of these operations can take quite a long time, and what you'll also notice is it will start doing some downloads. It will download some ISO images. And depending on the speed of your internet connection, that can take a significant amount of time. I also notice that the servers that serve up these ISO images can often be quite heavily loaded, so don't be surprised if this is a very slow process the first time you attempt it. Now, it just did an edit there because that's a quite long time, but you can also see that it's downloading some further tools called kubelet and kubeadm. Now, these are the underlying tools that are used to manage the Kubernetes Cluster. Once again, these will take quite a while to download the first time that you do this. So what we're hoping to see, eventually, is a return back to the command prompt with no errors reported, so some kind of output like this. Now if you've had any problems here, if this is hanging and you've waited, let's say 15 minutes would be kind of a reasonable time to start panicking, or if you get a nasty error, then towards the end of this video, I'm going to give you some troubleshooting tips. If you have got to a command line, then you should be able to type kubectl version, and what you should see is a response for the client's version. This is actually giving me the version of Kubernetes that we're running. This is 1.10 and there should be a similar result for the server version. If Minikube's not running properly then you might see a client version but you'll not get anything for the server version. So I you have got this far, seriously, invite your friends around and have a party. You really have got to a very good stage. The rest of this course will be a lot easier but will also be a lot more fun. If you've had a hang or a crash at this stage, then I have some advice for you in the next video. If it is working for you then that's absolutely great. You might find in future sessions when you try to start Minikube, it can sometimes lock itself up and that sometimes happens if configuration files somehow get corrupted. So the next video is how to troubleshoot Minikube. If it's working for you, for now you can skip that video, but remember that that troubleshooting video is there. And if you have any further problems with Minikube later on in the course then you can always return to that troubleshooting video.