Anonymous
×
Create a new article
Write your page title here:
We currently have 27 articles on PhenixOps. Type your article name above or click on one of the titles below and start writing!



PhenixOps
27Articles

Kubernetes: Difference between revisions

No edit summary
(How to setup kubectl and minikube)
Line 1: Line 1:
== Soon Swami, Soon. ==
== K8S on Minikube ==


First let me learn it, then i can teach you!<br>
I have started to setup a Kubernetes environment locally. For this setup i am using a 2009 Macbook Pro as this is the only option i have to do something local. I do have a server running for backups and other tasks but it does not seem not to support virtualization.<br>  


Some good info to start with: http://bit.ly/do-k8s-tut<br>
The machine will just be doing some testing with small images, just finger practice and getting things to work.<br>
 
Taking my notes here, based on information from Kubernetes.io The setup is described for a Linux environment, ofcourse. The instruction apply to MacOs as well, just download the installers for OSX.<br>
 
=== Pre check and dependencies ===
First you need to be sure your machine is supporting Virtualization, otherwise all effort is lost.<br>
VMX or SVM should be highlighted, provided you run Linux.<br>
<code>
grep -E --color 'vmx|svm' /proc/cpuinfo
</code>
 
Next, make sure Virtualbox is installed, find it here for your OS: https://www.virtualbox.org/wiki/Downloads.<br>
 
=== Kubectl ===
Get the installer and make it executable, command a run as root user<br>
 
LINUX
<code>
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod + x kubectl
</code><br>
OSX
<code>
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl"
</code><br>
 
Move it to the right dir in your path<br>
<code>
mv kubectl /usr/local/bin
</code><br>
 
=== minikube ===
Do the same thing for minicube<br>
LINUX
<code>
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 && chmod +x minikube
</code><br>
OSX
<code>
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 \
  && chmod +x minikube
</code><br>
 
Now move it into your path<br>
<code>
mv minicube /usr/local/bin
</code><br>
 
=== Check Setup ===
Now switch back to your login user and try if things are working<br>
 
This will download some images and install them using Virtualbox.<br>
 
Start Minikube<br>
<code>
minikube start
</code></br>
 
Check the status<br>
<code>
minikube status
</code><br>
 
which will provide you with info:<br>
<pre>
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
</pre><br>
 
Check if kubectl can access the cluster<br>
<code>
kubectl cluster-info
</code><br>
<pre>
Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
 
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'
</pre><br>
 
So, you are good to go from here and make a deployment<br>
 
== Hello World ==
Just a small hello world kind of test and exposing to local port 8888<br>
 
Create the deployment
<code>
kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
</code><br>
 
Expose the deployment to local port 8888
<code>
kubectl expose deployment hello-minikube --type=NodePort --port=8888
</code><br>
 
Now, we can check for the deployment which is a pod<br>
<code>
kubectl get pod
</code><br>
This will produce you with some info:<br>
<pre>
NAME                              READY  STATUS              RESTARTS  AGE
hello-minikube-64b64df8c9-krr6p  0/1    ContainerCreating  0          37s
</pre>
 
To see where is running<br>
<code>
minikube service hello-minikube --url
</code>
 
Shows you the url:<br>
<pre>
http://192.168.99.100:32463
</pre>
 
When you have stopped enjoying the magic:<br>
<code>
minikube stop
</code></br>
 
To delete all the good work<br>
 
Removing just the deployment of hello-minikube<br>
<code>
kubectl delete services hello-minikube
</code>
 
To remove the minikube cluster<br>
<code>
 
</code>
 
 
Some more good info to start with: http://bit.ly/do-k8s-tut<br>


[[Category:Kubernetes]]
[[Category:Kubernetes]]

Revision as of 20:59, 18 June 2020

K8S on Minikube

I have started to setup a Kubernetes environment locally. For this setup i am using a 2009 Macbook Pro as this is the only option i have to do something local. I do have a server running for backups and other tasks but it does not seem not to support virtualization.

The machine will just be doing some testing with small images, just finger practice and getting things to work.

Taking my notes here, based on information from Kubernetes.io The setup is described for a Linux environment, ofcourse. The instruction apply to MacOs as well, just download the installers for OSX.

Pre check and dependencies

First you need to be sure your machine is supporting Virtualization, otherwise all effort is lost.
VMX or SVM should be highlighted, provided you run Linux.
grep -E --color 'vmx|svm' /proc/cpuinfo

Next, make sure Virtualbox is installed, find it here for your OS: https://www.virtualbox.org/wiki/Downloads.

Kubectl

Get the installer and make it executable, command a run as root user

LINUX curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl && chmod + x kubectl
OSX curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl"

Move it to the right dir in your path
mv kubectl /usr/local/bin

minikube

Do the same thing for minicube
LINUX curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 && chmod +x minikube
OSX curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 \

 && chmod +x minikube


Now move it into your path
mv minicube /usr/local/bin

Check Setup

Now switch back to your login user and try if things are working

This will download some images and install them using Virtualbox.

Start Minikube
minikube start

Check the status
minikube status

which will provide you with info:

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured


Check if kubectl can access the cluster
kubectl cluster-info

Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'


So, you are good to go from here and make a deployment

Hello World

Just a small hello world kind of test and exposing to local port 8888

Create the deployment kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10

Expose the deployment to local port 8888 kubectl expose deployment hello-minikube --type=NodePort --port=8888

Now, we can check for the deployment which is a pod
kubectl get pod
This will produce you with some info:

NAME                              READY   STATUS              RESTARTS   AGE
hello-minikube-64b64df8c9-krr6p   0/1     ContainerCreating   0          37s

To see where is running
minikube service hello-minikube --url

Shows you the url:

http://192.168.99.100:32463

When you have stopped enjoying the magic:
minikube stop

To delete all the good work

Removing just the deployment of hello-minikube
kubectl delete services hello-minikube

To remove the minikube cluster


Some more good info to start with: http://bit.ly/do-k8s-tut