Showing posts with label Minikube. Show all posts
Showing posts with label Minikube. Show all posts

Saturday, March 14, 2020

Running Istio 1.5 on Minikube

Istio 1.5 is out. Istio took a very bald and big move. Istio decided to move away from microservices. Considering istio use case it makes lots of sense. As you go with microservice architecture you have several advantages like autonomy, use the best tool for the job(different languages), scale components independently, isolation and many others. However, microservices are not a free lunch and there is a downside from it. One of them is the DevOps engineering price to configure, provision, monitor and maintain several isolated services. The other one is complexity. Microservices are more complex than monolith systems. Istio took the move and went to from the microservices architecture with 5 services(Pilot, Cidatel, Telemetry, Policy, Galley, Injector) into 1 single service called istiod. This move made lots of sense.  Not only because it removed complexity but also make configuration, installation and upgrade much easier. I',m sure this move will drive more adoption.

Running Istio 1.5 in Minikube



There are some important things to keep in mind. First of all, I'm setting up 16GB for istio. Istio runs much better with more memory. It's possible to run it with 8GB if you like. If you are having issues, for sure is the memory. Crash loop back in Kubernetes most of the time is because of the lack of resources like memory.

Secondly, there are some commands that will require you to open new terminals like the minikube tunnel and dashboards. Keep in mind some of the dashboard commands like envoy and controlz require the pod name which will change, so do a kubectl get and pick the right pod name. Keep in mind istio is deployed in a different namespace called (istio-system) in order to access it via kubectl you need to pass -n istio-system at the end of each command.

Here are some screenshots of Istio 1.5 running on my machine.

kubectl get all (show all resources from the demo app)

kubectl get all -n istio-system (show all resources from istio namespace/installation)

istioctl dashboard kiali (show kiali service-mesh graph visualization of the demo app).

istioctl dashboard Prometheus (show Prometheus observability ui).

istioctl dashboard envoy $productpage_pod_name

istioctl dashboard controlz $istiod-pod-name -n istio-system

Product Page demo app running on my chrome

istioctl dashboard jaeger

istioctl dashbaord grafana

Istio 1.5 it's very sexy. One of the biggest downsides of istio just got fixed(complexity of configuration, maintained and upgrade). The only thing we still need to be paying attention to is overhead.  The last time I check was around 10ms. I'm sure istio will get faster and better.

Cheers,
Diego Pacheco


Saturday, April 20, 2019

Using Multiple profiles with Minikube

Kubernetes is the new Linux. K8s is the spec for the multi-poly cloud world. Running k8s could be very resource intensive, so is always a good idea being able to run things locally. For several reasons like Engineering Productivity, Tests and Experiments and so on and on. If you are working with Istio like I'm, you might realize it's a bit heavy to run local, especially if you do have other things running on k8s.  Minikube is the goto solution for local kubernetes clusters. However, as I said before, it can get pretty heavy when Istio gets involved. So the solution is pretty simple, it not much advertised. Minikube has a profile feature which allows you to create multiple profiles. Each profile will be a 2GB DISK VM created in Virtualbox. This is great because now you can run multiple kubernetes versions and multiple clusters doing multi experiments. IMHO is always great to have a k8s cluster ready to test things so I have multiple profiles like istio, lightweight, tests, etc... The first time you create the profile takes some time, up to 10min worst case but after the profile created things are super fast.

Running Multiple profiles with Minikube



Cheers,
Diego Pacheco

Monday, August 7, 2017

Go and Redis running on Kubernetes with Minukube


Go is a simple, fast and powerful programing language. Go is growing a lot into the DevOps Engineering scene like Hashicorp Stack or even Kubernetes.  One of the main advantages of GO is the fact that you can generate a single binary with all you needed, bundled in a single file. This makes distribution so much easier.

Go is also very compact for some use cases and you can write so less code and still very very efficient and get best of performance.  Today we will see how to create a very, very, very simple service in go. This service will access redis to increment how many times it was called.  We will use Minikube in order to run kubernetes locally and we will store our data in Redis.




The Go Service

Let's get down to the code.

Here we are using an external library called go-redis. We need this library to communicate with Redis using Go. You can run this code on your machine right now but first, you need to install the Redis driver you can do it so by running $ go get -u github.com/go-redis/redis .Now you can simply run the app with $  go run main.go .Keep in mind this won't work right now because we don't have Redis running. You can download, install and run Redis or you can use docker. We will run redis with docker but on Kubernetes using Minikube.

As you can see we are exposing a service on the port :9090 and he have a handler function which takes care of the HTTP request to this very server. We want to avoid double counting for this service and some user might call it from the browser so we need to ignore the /favicon.ico request that's why we use the if on the very first lines of the code.

We are connecting on Redis but we are reading Redis URL from an OS env var. I'm doing this so we can run this code in many ways like locally, docker, docker-compose, and kubernetes. IF you have Redis locally now you can do $ REDIS_URL=localhost:6379 go run main.go .For this simple service, we are using Redis commands INCR and GET in order to increment keys(+1) and get the current value of the key.

Go Dockerfile

Right now we need to create a Dockerfile to run our go simple service. In order to do that we will create a Dockerfile file and add the following content:

Dockerfile is quite straightforward we are using GO lang 1.8 and we are installing the Redis driver and we copy the go source code to the container.

Kubernetes deployment

Now we need create 2 yaml files in order to describe the kuerbenetes deployment and Service for the go web app. However before doing that we will create 2 other yaml files in order to deploy Redis so our redis docker container runs on kubernetes as well. We also link connect this 2 containers using kubernetes internal DNS service.

Redis Deployment on Kubernetes

Let's create a file called: redis-deployment.yaml.

We also need to create a service. So create a file called redis-service.yaml.

The most important information here is that we are using the image called redis. We are also setting the spec on the service for LoadBalancing on the port 6379 and this means we will be able to access outside of the cluster. This is not required but is quite useful so you can use redis-cli and access the redis instance on Kubernetes.

Right now we can create the deployment and service yaml files for the web go simple service application.  So first create a file called: webappgo-deployment.yaml


Then, create another file called webappgo-service.yaml.

Here we have some important things that need to be noted such as the image which is: webappgo:v1. This image does not exist on public docker repo so we need to build on our local machine and send the docker image to minikube dockers registry.

When we write the go code we were expecting to receive the redis URL via OS ENV var. We can set this vars via Kubernetes and kubernetes will forward this vars to Docker we did this on the property called env. You might notice some specific name for the redis url which is: redis.default.svc.cluster.local:6379 .This is the kubernetes internal DNS. Where redis is the name of the service, the default is the default namespace and cluster.local is the domain.

Another important thing to notice is that the spec type on the service in LoadBalancer so we are exposing the port 9090.

kubectl and Minikube

okay, now we can go on and deploy theses files in kubernetes on our minikube local cluster.

There are some important steps here.  We are doing eval on minikube docker-env so we can use docker commands on out machine but send docker images to minikube docker registry. We are also baking a docker images for the go service application.

You might notify we are using kubectl create -f and passing a directory. This is created because you don't need to specify a file by files and long as you have redis and go deployment and services files properly in each respective directory.

Now we can run the GO simple service in our browser. You might need to run  $ kubectl describe services webappgo to get the proper port mapping.



IF you go to the minikube dashboard(http://192.168.99.100:30000/#!/pod?namespace=default) you can the see the GO service LOGs, like this:



You can get all the files in my github.

Cheers,
Diego Pacheco

Thursday, July 27, 2017

Kubernetes with Docker and Minikube

Kubernetes is getting more popular every day. Kubenertes is an open source system for automating deployments, scaling and managing containerized applications. Created by Google on 2014 and also know as k8s. Why? Because there are 8 letters between k and s :-).

K8s has many features such as Automatic bin-packing which is the capability of placing containers based on resources and constraints.  K8s also has horizontal scaling, storage orchestration using local storage or cloud storage such as AWS or GCP.

K8s has important Cloud native capabilities such as Self Healing, Service Discovery and Load Balancing and secret and dynamic config management. For this blog post, we will see how to bake a simple docker image using node js application and deploy this docker image on hibernates using minikube in order to run locally.

There are other cloud-native solutions such as NetflixOSS Stack. Also Spring Cloud, which uses NetflixOSS too. However, on this post, we will be focusing on Docker and Kuerbenete .


Running Minikube on Ubuntu Linux 17.04

You can do it with other Linux distributions such as 16.04 LTS for instance, however, I will show in Ubuntu Linux 17.04 because of thats the distro I'm currently using. In theory, it should be very straight forward to get Minikube up and running on Linux. However is not that easy. If you search on the internet you will see lots of people complaining about:



Some people spend days to figure this out, lots of open issues on GitHub and threads on stack overflow. Las t night I spent 3hours to figure out what was going on.

There are also sorts of trying this, try that. Some folks said Minikube is not stable on Ubuntu Linux 17.04 but actually that all wrong. The issue is Virtualbox. Every time I update VirtualBox something stop working like Vagrant, Docker or Kubernetes. So the fix is pretty simple but you need to keep in mind that every time you update VirtualBox you need do this.


Installing Minikube and kubectl

Alright! Let's get down to business and install Minikube and kubecetl on our Linux. First commands will wipe out all previous installations this works well for the first time installs and also for upgrade scenarios. The beauty of minikube is you can continue working normally with kubectl console tool. So there is no difference if you running minikube locally or running k8s on GKE or AWS with Kops.It all works in the same way.


Baking NodeJS Docker image 

So let's build a simple node js application and also bake a docker image with this application. Let's get to the Javascript code. The main reason I'm showing this code in JavaScript is that is some small and concise. We could do it in other languages but for sake of simplicity and focus on Kubernets and minikube let's go with JS.


We also need to have a Dockerfile in order to bake the image. Ther we go.


Deploying to Kubernetes

Now it's time. Let's start minikube and push this docker image to minikube dockers registry and see this app running on our local Kubernetes.

There are some important things to keep in mind such eval $(minikube docker-envwhich does the trick to integrate our local docker with minikube. Otherwise, the kubernetes registry will try to download images from public docker hub.

 

You also can take a look on the kubernetes dashboard and check our app if you want. To do it so you do $ minikube dashboard and go to http://192.168.99.100:30000/#!/workload?namespace=default As you can see your image is there. This dashboard is very useful you can use it to check information about your containers and also deploy new containers.


All right that's it. Have fun!

cheers,
Diego Pacheco

Chuyên mục văn hoá giải trí của VnExpress

.

© 2017 www.blogthuthuatwin10.com

Tầng 5, Tòa nhà FPT Cầu Giấy, phố Duy Tân, Phường Dịch Vọng Hậu, Quận Cầu Giấy, Hà Nội
Email: nguyenanhtuan2401@gmail.com
Điện thoại: 0908 562 750 ext 4548; Liên hệ quảng cáo: 4567.