# DevOps/Kubernetes/Installation
## Installation

Kubernetes as of April 2019 can be installed in more that 40 differentes ways and in particular can be installed using your Linux distribution packages or using Kubernetes upstream version. It is also possible to use any of Kubernetes managed solution offered by Cloud Computing provider like EKS from AWS, Google Kubernetes Engine (GKE) in Google Cloud Platform (GCP) or GKE on-prem or also some CI/CD tools like Jenkins X and GitLab that support integration with different Kubernetes Cloud providers.

### Install Kubernetes on Debian/Ubuntu using upstream

* Our first step is to download and add the key for the Kubernetes and docker install. Back at the terminal, issue the following command:
* Add the Docker Repository on all your servers:
* Add the Kubernetes repository in your apt source.list on all your servers.
* And now, Install Docker, kubeadm, kubelet, and kubectl on all your servers.

### Initialize your master

* Enable net.bridge.bridge-nf-call-iptables on all your nodes.
* On only the Kube Master server, initialize the cluster and configure kubectl.
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
When this completes, you'll be presented with the exact command you need to join the nodes to the master. In case you make any mistake and want to undo your changes you can use: kubeadm reset command.
* Before you join a node, you need to issue the following commands:
* Install the flannel networking plugin in the cluster by running this command on the Kube Master server.
* The kubeadm init command that you ran on the master should output a kubeadm join command containing a token and hash. You will need to copy that command from the master and run it on both worker nodes with sudo.
* Now you are ready to verify that the cluster is up and running. On the Kube Master server, check the list of nodes.

### Containers and Pods

Pods are the smallest and most basic building block of the Kubernetes model. A pod consist of one or more containers storage resources, and a unique IP address in the Kubernetes cluster network.
In order to run containers, Kubernetes schedules pods to run on servers in the cluster. When a pod is scheduled the server will run the containers that are part of that pod.
Create a simple pod running an nginx container, for more configuration options check Kubernetes Pod official documentation:
* Create a basic Pod file definition with your container image: mypod.yml
* Create Pod: kubectl create -f mypod.yml
* Get a list of pods and verify that your new nginx pod is in the Running state:
* Get more information about your nginx pod:
* Delete the pod:
See also ReplicaSet concept.

### Clustering and Nodes

Kubernetes implements a clustered architecture . In a typical production environment, you will have multiple servers that are able to run your workloads (containers) These servers which actually run the containers are called nodes. A kubernetes cluster has one or more control servers which manage and control the cluster and host the kubernetes API. These control server are usually separate from worker nodes, which run applications within the cluster.
* Get a list of nodes: kubectl get nodes
* Get more information about a specific node:

### Networking in Kubernetes

The Kubernetes networking model involves creating a virtual network across the whole cluster. This means that every pod on the cluster has a unique IP address, and can communicate with any other pod in the cluster, even if that other pod is running on a different node.
Kubernetes supports a variety of networking plugins that implements this model in various ways. One of the most popular and easy-to-use is Flannel, although as of April 2019 do not support network policies.
* Create a deployment with two nginx pods:
* Create a busybox pod to use for testing:
* Get the IP addresses of your pods:
* Get the IP address of one of the nginx pods, then contact that nginx pod from the busybox pod using the nginx pod's IP address:
* ↑ https://linuxacademy.com/blog/linux-academy/top-ten-ways-not-to-sink-the-kubernetes-ship/
* ↑ https://cloud.google.com/gke-on-prem/
* ↑ https://about.gitlab.com/solutions/kubernetes/
* ↑ https://www.techrepublic.com/article/how-to-quickly-install-kubernetes-on-ubuntu/
* ↑ https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
* ↑ https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-reset/
* ↑ https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/
* ↑ https://kubernetes.io/docs/tasks/configure-pod-container/
* ↑ https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
* ↑ https://linuxacademy.com/blog/linux-academy/top-ten-ways-not-to-sink-the-kubernetes-ship/