Documentation
k8s

Kubernetes

Documentacion de kubernetes.

Arquitectura de kubernetes

  • kubelet
  • control plane

Pod

Crear Pod con kubectl
kubectl run nginx-pod \
    --image=nginx:1.27 \
    --port=80 \
    --restart=Never
Delete pod
kubectl delete pod nginx-pod

Replicaset

  • utilizado para garantizar la disponibilidad del numero definido de pods identicos
  • Selector: identificar los pods
  • Replica count:
  • Pod template

Deployment

Create deployment
kubectl create deployment nginx-deployment \
    --image=nginx:1.27 \
    --replicas=2
Delete deployment
kubectl delete deployment nginx-deployment

Service

Create service
kubectl expose deployment nginx-deployment \
    --name=nginx-service \
    --type=ClusterIP \
    --port=80 \
    --target-port=80
delete service
kubectl delete service nginx-service

Namespace

create namespace
kubectl create namespace dev
get namespace
kubectl get namespace
set default namespace
kubectl config set-context --current --namespace=dev

Logs y troubleshooting

logs
kubectl logs <pod>
kubectl logs -f <pod>
kubectl logs --tail=100 <pod>
execute
kubectl exec -it <pod> -- /bin/bash
kubectl exec -it <pod> -- /bin/sh

configmap

execute
kubectl create configmap app-config \
    --from-literal=ENV=prod \
    --from-literal=LOG_LEVEL=info
config.properties
ENV=prod
LOG_LEVEL=info
config.properties
kubectl create configmap app-config \
    --from-file=./config.properties

secrets

  • ingress
  • cronjob