0% found this document useful (0 votes)
68 views23 pages

Instalar Virtualbox en Debian 1.-Actualizar El Linux

The document provides instructions for installing VirtualBox, Docker, Kubernetes, Minikube and related tools on a Debian Linux system. It includes commands to update the system, install various packages and configure services. Key steps include installing VirtualBox, pulling Docker images, deploying Kubernetes components like kubectl and configuring Minikube for local Kubernetes cluster development.

Uploaded by

Nicolas Polo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views23 pages

Instalar Virtualbox en Debian 1.-Actualizar El Linux

The document provides instructions for installing VirtualBox, Docker, Kubernetes, Minikube and related tools on a Debian Linux system. It includes commands to update the system, install various packages and configure services. Key steps include installing VirtualBox, pulling Docker images, deploying Kubernetes components like kubectl and configuring Minikube for local Kubernetes cluster development.

Uploaded by

Nicolas Polo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Instalar virtualbox en Debian

1.- Actualizar el Linux

2.-Instalar virtualbox
Instalar Docker.

sudo apt update

sudo apt install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o


/usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-


keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo
tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update


apt-cache policy docker-ce

sudo apt install docker-ce

sudo systemctl status docker

3.- Instalar

The following packages were automatically installed and are no longer required:

libflashrom1 libftdi1-2

Use 'sudo apt autoremove' to remove them.

curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s


https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/
amd64/kubectl

Cambiar permisos kubectl y mover a bin


chmod +x kubectl && sudo mv kubectl /usr/bin/.

Validar ubicación de kubectl

Instalar Minikube
Cambiar permisos y ubicación Minikube

Validar la instalación del Minikube

minikube version

Instalar componentes requeridos


sudo apt-get install -y conntrack

Instalar complementos para ejecutar Minikube

wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.2.0/cri-
dockerd-v0.2.0-linux-amd64.tar.gz

sudo mv ./cri-dockerd /usr/local/bin/


$ wget
https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/
systemd/cri-docker.service

$ wget
https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/
systemd/cri-docker.socket

$ sudo mv cri-docker.socket cri-docker.service /etc/systemd/system/

$ sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,'


/etc/systemd/system/cri-docker.service

$ systemctl daemon-reload

$ systemctl enable cri-docker.service

$ systemctl enable --now cri-docker.socket

$ systemctl status cri-docker.socket

VERSION="v1.24.1"

curl -L https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$
{VERSION}-linux-amd64.tar.gz --output crictl-${VERSION}-linux-amd64.tar.gz
sudo tar zxvf crictl-$VERSION-linux-amd64.tar.gz -C /usr/local/bin

rm -f crictl-$VERSION-linux-amd64.tar.gz

Instalar vim

Sudo apt install vim

Despues de instalación

Minikube ssh

Ls

Docker ps

Minikube ip

Minikube stop
Minikube delete

Kubectl get nodes (ver nodos del cluster de kubernetes)

Kubectl –help

Kubectl get nodes

Kubectl config get-contexts

Namespace = división logica del cluster, separar la carga

Kubectl get ns

1 cont en cada pod, contenedor corra un solo proceso.

Kubectl -n kube-system get pods -o wide (más informacion de los pods)

Kubectl -n kube-system delete pod “nombre del pod” y se elimina el pod

Vim 01-pod.yaml

Manifiesto de un pod:

apiVersion: v1

kind: Pod

metadata: “se pueden agregar etiquetas o nombres”

name:nginx “nombre del pod”

spec:

containers

- name: nginx

image: nginx:alpine

kubectl apply -f 01.pod.yaml

kubectl exec -it nginx –sh

ps fax

crear orden para levantar nuevamente el pod

apiVersion: v1

kind: Pod

metadata: “se pueden agregar etiquetas o nombres”

name:nginx “nombre del pod”

spec:

containers
- name: nginx

image: nginx:alpine

env

- name : MI_VARIABLE
- value: “pelado”
- name MI_OTRA_VARIABLE
- value: “abel”
- name: DD_AGENT_HOST
- valueFrom
- fieldRef
- fieldPath: status.hostIP (obtener esa IP)
- resources
- requests: (siempre disponibles)
- memory: “64Mi”
- cpu: “200,” mil milicore es un core
- limits: (limites que puede utilizar de memoria)
- memory:”128Mi” ---si se pasa el kernel de Linux mata el proceso, si se mueren hay
que asignar mas memoria o crear copias del pod
- cpu: “500m”
- readinessProbe: de explicar a kubernetes que mi pod esta listo para recibir trafico
- httpGet:
- path: /
- port: 80
- initialDelaySeconds: 5
- periodSeconds: 10
- livenessProbe: (indicar que tu pod esta vivo)
- tcpSocket:
- port: 80
- initialDelaySeconds: 15
- periodSeconds: 20
- ports
- containerPort: 80

kubectl get pod nginx -o yaml

Deployments

apiVersion: apps/v1

kind: Deployment

metadata:
name: nginx-deployment

spec:

selector:

matchLabels:

app: nginx

replicas: 2 (es la cantidad de pod que queremos en el deployment, un template para crear
pod)

template:

metadata:

labels:

app: nginx

spec:

containers:

- name: nginx

image: nginx:alpine

env:

- name: MI_VARIABLE

value: "pelado"

- name: MI_OTRA_VARIABLE

value: "pelade"

- name: DD_AGENT_HOST

valueFrom:

fieldRef:

fieldPath: status.hostIP

resources:

requests:

memory: "64Mi"

cpu: "200m"

limits:

memory: "128Mi"

cpu: "500m"
readinessProbe:

httpGet:

path: /

port: 80

initialDelaySeconds: 5

periodSeconds: 10

livenessProbe:

tcpSocket:

port: 80

initialDelaySeconds: 15

periodSeconds: 20

ports:

- containerPort: 80

Kubectl apply -f 04-deployment.yaml

Otra forma de hacer deployment es usando Daemon pero 1 solo pod por cada nodo, sirve para
servicios de monitoreo

apiVersion: apps/v1

kind: DaemonSet

metadata:

name: nginx-deployment

spec:

selector:

matchLabels:
app: nginx

template:

metadata:

labels:

app: nginx

spec:

containers:

- name: nginx

image: nginx:alpine

env:

- name: MI_VARIABLE

value: "pelado"

- name: MI_OTRA_VARIABLE

value: "pelade"

- name: DD_AGENT_HOST

valueFrom:

fieldRef:

fieldPath: status.hostIP

resources:

requests:

memory: "64Mi"

cpu: "200m"

limits:

memory: "128Mi"

cpu: "500m"

readinessProbe:

httpGet:

path: /

port: 80

initialDelaySeconds: 5

periodSeconds: 10
livenessProbe:

tcpSocket:

port: 80

initialDelaySeconds: 15

periodSeconds: 20

ports:

- containerPort: 80

POD con un statefulset, tienen un volumen, un directorio o un disco atado en ese pod, sirve
para base de datos.

apiVersion: apps/v1

kind: StatefulSet

metadata:

name: my-csi-app-set

spec:

selector:

matchLabels:

app: mypod

serviceName: "my-frontend"

replicas: 1

template:

metadata:

labels:

app: mypod

spec:

containers:

- name: my-frontend

image: busybox

args:

- sleep

- infinity
volumeMounts:

- mountPath: "/data"

name: csi-pvc

volumeClaimTemplates:

- metadata:

name: csi-pvc

spec:

accessModes:

- ReadWriteOnce

resources:

requests:

storage: 5Gi

storageClassName: do-block-storage

kubectl describe pod “nombre pod” (estado y eventos del pod)

kubectl get pvc (el pedido de hacer discos)

kubectl describe pvc “nombre del pvc”

kubectl get statefulsets

kubectl delete sts “nombre del statefulsets deployment”

kubectl delete pvc “nombre del pvc”

manejar bd, packets3, load balancer, infraestructura en una bd


Cluster networking interface - crea una vpn entre todos los pods que están entre los nodos.

Agente calico, corre en cada nodo, crear rutas ip en cada instancia donde esta el pod que
corresponde con esa ip.

Etcd base de datos de kubernetes.

Servicios en kubernetes

Set de pods , contactar api, desde un pod hacia otro o desfde afuera del cluster

Cluster IP, ip fija dentro del cluster,funciona como un load balancer entre todos los pods donde
se asigne este servicio

Node Port, crear un puerto en cada nodo que va a recibir el trafico y lo va a mandar los pods
que quieras mandarlo.

Load Balancer, atado a la nube, crear un balanceador en el proveedor de nube y redireccionar


el trafico a cada uno de los pods.

apiVersion: v1

kind: Pod

metadata:

name: ubuntu

spec:

containers:

- name: ubuntu

image: ubuntu

args:

- sleep

- infinity

Random Pod

Acceder a los demás pod que están dentro del cluster.

Hello Deployment

apiVersion: apps/v1

kind: Deployment

metadata:

name: hello
spec:

replicas: 3

selector:

matchLabels:

role: hello

template:

metadata:

labels:

role: hello

spec:

containers:

- name: hello

image: gcr.io/google-samples/hello-app:1.0 (corer esta app de google)

ports:

- containerPort: 8080

---

apiVersion: v1

kind: Service

metadata:

name: hello

spec:

ports:

- port: 8080

targetPort: 8080

selector:

role: hello (que pod van a ser los backend para estos servicios, redireccionar trafico a esta
etiqueta “hello” cada pod tiene su ip y cuando se elimina y asi vamos a llegar a todos los pod
mediante estas etiquetas)

kubectl geta ll

kubectl describe svc hello


kubectl exec -it Ubuntu –bash

kubectl get svc

dentro del ubuntu ---- curl http://hello:8080 y hacer ping

kubectl delete -f 07-hello-de……

NODE PORT

apiVersion: apps/v1

kind: Deployment

metadata:

name: hello

spec:

replicas: 3

selector:

matchLabels:

role: hello

template:

metadata:

labels:

role: hello

spec:

containers:

- name: hello

image: gcr.io/google-samples/hello-app:1.0

ports:

- containerPort: 8080

---

apiVersion: v1

kind: Service

metadata:
name: hello

spec:

type: NodePort (por defecto es clusterip por eso se especifica)

ports:

- port: 8080

targetPort: 8080

nodePort: 30000

selector:

role: hello

kubectl get nodes -o wide (para mostrar la ip publica de los nodos)

curl http://ip publica:30000 pod de la pp hello

puerto al internet

LOAD BALANCER

Mejor que el nodeport porque en este no hay que saber la ip de cada nodo para poder llegar a
cada servicio, sino que con una misma ip puedo llegar a todos los servicios

Kubectl get svc

Kubectl describe svc hello

Curl http://ip publica:8080

Cluster ip : crea una ip dentro del cluster privada no funciona desde afuera, y nos lleva a los
pod que queremos basados en etiquetas

Node port crea un servicio que encuentra los pods basados en etiquetas pero lo que hace es
crear un puerto en cada nodo que es publico y que puedes entrar desde afuera si tienes una ip
publica

Load balancer: encontrar pod basado en etiquetas, conecta nuestro cluster con el proveedor
de nube y crea un load balancer en aws, Google o azure que apunta a los nodos donde están
corriendo esos pods

Ingress: accesos a los servicios basados en el path.

apiVersion: networking.k8s.io/v1

kind: Ingress

metadata:

name: hello-app
spec:

rules:

- http:

paths:

- path: /v1

pathType: Prefix

backend:

service:

name: hello-v1

port:

number: 8080

- path: /v2

pathType: Prefix

backend:

service:

name: hello-v2

port:

number: 8080

HELM manejador de paquetes de kubernetes.

kubectl -n ingress-nginx get pods

kubectl get ing

recursos tipo ingress son controladores en la nube

kubectl -n ingress-nginx get svc

curl http://ip del ingress get ing/v1 o v2

path se puede cambiar por un host

node port ip publica de cada nodo

mejor usar ingress

CONFIGMAP

Un archivo que hosteas en kubernetes y puedes acceder desde los pods

Kubectl exec -it nginx – sh


Ls / config/

Cat /config/game.properties

SECRET

Parecido a configmap el contenido esta codificado

/env

Kustomization

Kustomize build

Kubectl logs -f “nombre pod »

Stern hello-v1

En caso de que no sea instalando el minikube hay que exportar el KUBECONFIG

Export KUBECONFIG= /Downloads/k8s-1…….(dirección que te entrega el cloud)

Instalar lens kubectl interfaz grafica

INSTALAR HELM

curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee


/usr/share/keyrings/helm.gpg > /dev/null

sudo apt-get install apt-transport-https –yes


echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg]
https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-
stable-debian.list

sudo apt-get update

sudo apt-get install helm

helm repo add bitnami https://charts.bitnami.com/bitnami

helm show values bitnami/wordpress

helm install miwordpress bitnami/wordpress –wordpressUserame=admin –


wordpressPassword=admin

nano install.yml
helm install miwordpress -f install.yml bitnami/wordpress

Helm delete fycowordpress

Crear carpeta de helm

Mkdir mihelm

Cd mihelm/

Helm create miappfyco

Ls

Cd miappfyco/

Ls

Nano Chart.yaml

Nano values.yaml

Echo “” > values.yaml


Nano values.yaml

frontReplicaCount: 3

backReplicaCount: 3

appTitle: Mi app

modificar templates

cd templates/

ls

rm hpa.yaml

rm service.yaml

ls

deployment.yaml

NOTES.txt

_helpers.tpl

cd test/

rm *¨

cd

echo “” > NOTES.txt

nano NOTES.txt

cualquier cosa

nano _helpers.tpl

echo “” > _helpers.tpl

cualquier cosa

nano deployment.yaml

echo “” > deployment.yaml

cd

helm package miappfyco


helm repo index

ls

helm repo add nokia https://nokia.com/altiplano/

helm show values nokia/altiplano

You might also like