Minikube in the Cloud on Ubuntu
Linux Training Architect I in Content
In this course we will be exploring Minikube. It is a local implementation of Kuberenetes, in a single node format, that is useful for local development.
Welcome to the Course
Welcome to the course! In this video, I provide an overview of what we will be learning. I hope that you enjoy this course as much as I enjoyed creating it!
About the Instructor
My name is Mike, and I am a DevOps engineer with over a decade of experience working in cloud environments. I got my start in enterprise support, and then moved to web hosting. I am proud to bring you this course on Minikube.
Containers and Kubernetes Review
In this lesson we will contrast containers and virtual machines. We will also take a look at exactly what a container is, and how a container is created using namespaces. This will give us the foundation that we need to move forward into orchestrating containers with Kubernetes, and how to manage them locally using Minikube.
In this lesson we will cover the absolute basics of Kubernetes, as they applies to a full installation of Kuberentes in a cluster. We will talk about container orchestration and pods. If you already know Kubernetes, please feel free to mark this as complete and move on to the next section.
The Difference Between Traditional Kubernetes and Minikube
In this lesson we will look at the differences between a full Kubernetes cluster and Minikube. We will focus mostly on the differences in deployment, and how to leverage Minikube to allow quick deployment of a local Kubernetes cluster.
Installing Minikube in the Cloud Playground
In this lesson we will look at installing Minikube in our Cloud Playground. There are a few things that make this different than installing it on an Ubuntu workstation. This is a virtualization-on-virtualization type of installation, and we can use these techniques to deploy to the major cloud providers. Commands used in this lesson: Installing and testing Docker (remember to log out and back in for group changes to take effect):
Get and install Minikube:
sudo apt install -y docker.io sudo usermod -aG docker cloud_user docker run hello-world
Configure and start Minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_1.4.0.deb sudo dpkg -i minikube_1.4.0.deb
Additional configurations and installation of
sudo minikube config set vm-driver none sudo minikube start
sudo chown -R $USER $HOME/.kube $HOME/.minikube
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
sudo chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl
sudo kubectl create deployment --image nginx my-nginx sudo kubectl expose deployment my-nginx --port=80 --type=NodePort sudo minikube ip sudo kubectl get svc
In this lesson we will be taking a look at the Minikube commands. We can use these commands to manage a cluster and perform tasks such as starting, stopping, and deleting the cluster. Additionally we can check the logs, cache images, and get the status of the cluster.
In this lesson we will take a look at how to enable Minikube addons, specifically the Kubernetes dashboard. There are some additional steps we will be taking to ensure that the dashboard is acessible via the public IP of our server, as we are running a Cloud Playground server.
In this lesson, we use the
minikube config command to work with the configuration of the Minikube cluster. We demonstrate how to configure the memory allocation of the Minikube installation as well as revert those changes. We also show a listing of all of the configurations that can be modified in the Minikube installation.
Using a Specific Version of Kubernetes
In this lesson, we discuss how to install specific versions of Kubernetes. Typical production environments are the last ones to be updated, and any changes need to be tested first. This means that in our development environment, we most likely will not be building against the latest version of Kubernetes, and will need to install the same version as what is in the production environment.
Local Storage and Volumes
In this lesson, we map a local directory to our pod by creating a volume mapped to the directory. Then we create a claim on that volume. Once the claim is bound, we can mount it into our pod and access the data located on our local storage. link to the repository used in this lesson
In this lesson, we leverage the dynamic provisioner to create persistent storage for a MySQL pod. This is in contrast to our local storage, and this is the method that would be used for production Kubernetes clusters.
Deploying to Minikube
Our First Deployment
In this lesson, we take the objects we've previously created and package them into a deployment. This allows us to create the objects in one command and also delete the objects in a command. This sets the stage for future deployments so we can create more complicated environments.
Deploying with Persistent Storage
In this lesson, we leverage the kustomization tool using an example from the official Kuberentes site. We include our YAML charts and a kustomization file in a directory, and then allow
kubectl to deploy using the kustomization file. This deployment will use dynamically-provisioned persistent storage for a WordPress installation.
Microservices in Minikube
In this lesson, we deploy microservices in Minikube. We use the robot-shop application from Instana for this purpose. Once we have the application deployed, we explore the services created and look at the performance of the application on our Minikube cluster.
git clone https://github.com/instana/robot-shop.git
Helm on Minikube
In this lesson, we install Helm into our Minikube cluster. Then we use Helm to deploy both a database and the robot-shop application into our cluster. Helm is the "package manager" for Kubernetes, and it can be used to simplify deployment by using a preconfigured package or chart into our cluster.
In this lesson, we work with a new instance in the Cloud Playground. Minikube is installed, but nothing will work. We fail to deploy Minikube and then show how to correct the issue to eventually get a working cluster. We walk through permissions errors, version issues, and driver problems, as well as how to recognize and correct these issues.
Logging and Debugging
In this lesson, we take a look at Minikube logging, exploring how to enable the different log levels when we start our cluster. We also take a look at getting some insight into the containers that make up our Kubernetes deployment within Minikube.
Users, Certificates, and Contexts
In this lesson, we look at how users are added into Kubernetes. We generate keys and certificates for the users so they can access the Kubernetes API. When troubleshooting a cluster issue, it's important to understand how users are created, so that we can take things like certificate expiration into account. Commands used in this lesson:
openssl genrsa -out dev.key 2048 openssl req -new -key dev.key -out dev.csr -subj "/CN=dev/O=group" openssl x509 -req -in dev.csr -CA /home/cloud_user/.minikube/ca.crt -CAkey /home/cloud_user/.minikube/ca.key -CAcreateserial -out dev.crt -days 500 kubectl config set-credentials dev --client-certificate=/home/cloud_user/keys/dev.crt --client-key=/home/cloud_user/keys/dev.key kubectl config set-context dev --cluster=minikube --namespace=default --user=dev
RBAC and What It Does
In this lesson, we take a look at role-based access control (RBAC). This is the permissions system for Kubernetes. We have a created user and will apply permissions for that user by creating a role, and then binding the role to the user.
Files used in this lesson:
kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: namespace: default name: pod-reader rules: - apiGroups: [""] # “” indicates the core API group resources: ["deployments", "pods"] verbs: ["get", "watch", "list"]
kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: read-pods namespace: default subjects: - kind: User name: dev # Name is case sensitive apiGroup: "" roleRef: kind: Role #this must be Role or ClusterRole name: pod-reader # must match the name of the Role apiGroup: ""
Food for Thought
Courses to Take Once You Have Completed This One
In this video, we take a look at the courses available on Linux Academy. We also review the search page that we can use to locate additional courses about Kubernetes and related technologies.
Take this course and learn a new skill today.
Transform your learning with our all access plan.Start 7-Day Free Trial