# Kubernetes & Docker

Kubernetes is a container orchestration framework that helps with managing applications requiring one or more container. You create a cluster which holds nodes which holds pods.

Pods that are running inside Kubernetes are running on a private, isolated network. By default they are visible from other pods and services within the same Kubernetes cluster, but not outside that network. When we use `kubectl`, we're interacting through an API endpoint to communicate with apps.

## Kubernetes

```
minikube version
minikube start
kubectl version 
kubectl cluster-info
kubectl get #List resources
kubectl get nodes
kubectl describe  #Show details
kubectl logs #Print logs from a container in a pod
kubectl get pods
kubectl exec POD-NAME -- whoami #Execute command on a container in a pod
kubectl exec -ti POD-NAME -- /bin/bash #Execute command on a container in a pod

kubectl create deployment DEPLOYMENT-NAME --image=DOCKER-IMAGE/DOCK-USER:latest
kubectl get deployments

```

### Pods, nodes, and deployments

When deploying, Kubernetes creates a **Pod** to host your application instance. A Pod is a Kubernetes abstraction that represents a group of one or more application containers (such as Docker), and some shared resources for those containers. Those resources include:

* Shared storage, as Volumes
* Networking, as a unique cluster IP address
* Information about how to run each container, such as the container image version or specific ports to use

{% hint style="info" %}
Learn more here:\
<https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/explore-intro/>
{% endhint %}

{% hint style="info" %}
When deploying an app through kubectl, Kubernetes will do a couple of things:

* searched for a suitable node where an instance of the application could be run (we have only 1 available node)
* scheduled the application to run on that Node
* configured the cluster to reschedule the instance on a new Node when needed
  {% endhint %}

## Docker

```
docker login #Credentials 
docker pull DOCKER-IMAGE/DOCK-USER:latest

```
