Skip to content
Diana Salamanca edited this page Mar 1, 2021 · 5 revisions

Welcome to the ft_services wiki!

Basic commands

minikube

# Start
minikube start
# Display dashboard
minikube dashboard
# Stop minikube
minikube stop
# Display profile
minikube profile <"profile's name">
# Delete profile
minikube delete -p <"profile's name">
# List all params we can change
minikube config
# Display a list of global command-line options (applies to all commands)
minikube options
# List help options
minikube <"command"> --help
# Display current ip
minikube ip
# List available addons
minikube addons list

kubectl

⚠️ Before start using this commands, be sure minikube is running.

# Display all (namespaces, pods, etc)
kubectl get all
# List the current namespaces in a cluster
kubectl get namespaces
# List current pods:
kubectl get pods
# List all pods in ps output format with more information (such as node name):
kubectl get pods -o wide
# List the current deployments:
kubectl get deployments
# List the current services:
kubectl get services
# List ingress:
kubectl get ingress
# Display events with changes
kubectl get events -w
# Allow to change between namespaces. Without the name, it will list all namespaces available.
kubens <"namespace's name">
# Display IPs
kubectl get pod -o wide
# Display log to see activity and if there are errors
kubectl logs -f pod/telegraf-596d6fbbf8-gg6s9

Create Namespace / POD / Deployment / Service / Ingress

# Using command line (for namespace)
kubectl create namespace <"namespace's name">
#Using YALM or JSON file
kubectl apply -f <"file name">
  • From Dashboard on webpage (Except Ingress)

⚠️ For Ingress, it's important to allow an addon

minikube addons enable ingress

Delete Namespace / Pod / Deployment / Service

# Using command line (namespace/ pod)
kubectl delete namespace <"namespace's name">
# Using YALM or JSON file and command line
kubectl delete -f <"file name">
  • From Dashboard on webpage

PODs/ Deployment details

# List the current pods in a cluster
kubectl get pods
# List the current deployment
kubectl get deployments
# List the deployment apps
kubectl get deployments.apps
# Display details about a pod/ service
kubectl describe pod <"pod name">
kubectl describe service <"service name">
# Display pod's logs:
kubectl logs -f <"file name">

Access to PODs

# Using command line
kubectl exec -it <"pod's name"> -- /bin/bash
# Check which the Operating System is (inside the pod) 
cat /etc/*release
# List the available hosts(inside the pod)
cat /etc/hosts
# Display conexion between two pods (inside the pod; before you had to create a service)
ping mariadb-service
#Kubernetes has a intern DNS, for that reason is able to resolve conexion between pods.

Create a Service

#Using YALM or JSON file
kubectl apply -f <"file name">

Run on Windows

Using the docker motor inside the minikube

  1. Run in the terminal:
minikube docker-env
  1. Check what do you need to run
# To point your shell to minikube's docker-daemon, run:
# & minikube -p minikube docker-env | Invoke-Expression

How to start with this project - Advice

  1. Start with the data bases MySQL, InfluDX (telegraf)
  2. Wordpress, PHPmyadmin, Grafana
  3. Ngnix, ftps

Useful links

yaml

VSFTPD (Very Secure File Transfer Protocol Daemon)

telegraf

Grafana

mysql

wordpress

PHP

Nginx

Configmap and secrets


Reverse Proxy

Concepts

Namespaces

Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.

When to Use Multiple Namespaces

Namespaces are intended for use in environments with many users spread across multiple teams, or projects. For clusters with a few to tens of users, you should not need to create or think about namespaces at all.

Pod

  • Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.
  • Pod is like a container.
  • Pod is the minimun unit of work.
  • A Pod is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers.

Deployment

A Deployment provides declarative updates for Pods and ReplicaSets.

Services

  • Kubernetes Pods are created and destroyed to match the state of your cluster. Pods are nonpermanent resources.
  • ReplicaSets create and destroy Pods dynamically

A Service is an abstraction which defines a logical set of Pods and a policy by which to access them (sometimes this pattern is called a micro-service). The set of Pods targeted by a Service is usually determined by a selector. Es el punto de entrada, siempre es fijo.

Ingress

Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster. Traffic routing is controlled by rules defined on the Ingress resource.

						Internet
						    |
						[Ingress]
						----|----
						[Services]

Liveness and Readiness Probes (No required for the project)

Readiness probes are designed to let Kubernetes know when the app is ready to serve traffic. Kubernetes makes sure the readiness probe passes before allowing a service to send traffic to the pod. If a readiness probe starts to fail, Kubernetes stops sending traffic to the pod until it passes.

Kubernetes uses readiness probes to decide when the container is available for accepting traffic. The readiness probe is used to control which pods are used as the backends for a service. A pod is considered ready when all of its containers are ready. If a pod is not ready, it is removed from service load balancers. For example, if a container loads a large cache at startup and takes minutes to start, you do not want to send requests to this container until it is ready, or the requests will fail—you want to route requests to other pods, which are capable of servicing requests. Una vez levantado el servicio, si esta en disposicion de aceptar o no peticiones.

Kubernetes uses liveness probes to know when to restart a container. If a container is unresponsive—perhaps the application is deadlocked due to a multi-threading defect—restarting the container can make the application more available, despite the defect. It certainly beats paging someone in the middle of the night to restart a container. Para saber si esta levantado el servicio

Kubernetes is an orchestrator for microservice apps

  • Masters: there are in charge
  • Nodes: are minions, they are doing the work We've got the code, and we containerize it. And, we define it in an object call a deployment, then we write it up and define in a YAML file.

Then we give the file to K8s on the master, and the master looks at the file and deploys the app on the cluster.

MASTERS

  • ⚠️ Don't run user workloads on Master
  • API server: It's our front‑end into the master or the control plane. Kubernetes API server: main part of Master.

NODES

Kubelet -> Main Kubernetes agent

  • The kubelet is the primary "node agent" that runs on each node.
  • Registers node with cluster
  • Watches apiserver
  • Instantiates pods
  • Reports back to master
  • Exposes endpoint on :10255

If a pod fails on a node, the kubelet is not resposible for restarting it or finding another node for it to run. It simply reports the state back to the master.

Declarative model & Desired State

Kubernetes operates in a declarative model. This means we give the API server manifest files that describe how we want the cluster to look and feel. YAML or JSON

PODS

  • Kubernetes run containers always inside of pods.
  • A container without a pod in Kubernetes is a naked container.
  • Pods can have multiple containers (advanced use-case)
  • Pod is a ring-fenced (cercado) environment to run containers. Itself doesn't run anything. It can have 1) Network stack, 2) Kernel namespaces, etc, n containers.
  • All containerss in pod share the pod environment

To check to see what was running on port

netstat -tulpn

Clone this wiki locally