Skip to content

Instantly share code, notes, and snippets.

@felipejoq
Created September 2, 2025 01:19
Show Gist options
  • Select an option

  • Save felipejoq/007d5a8b4234696c3fe73b9d35ccb955 to your computer and use it in GitHub Desktop.

Select an option

Save felipejoq/007d5a8b4234696c3fe73b9d35ccb955 to your computer and use it in GitHub Desktop.
# Comandos útiles Kubectl
kubectl version # Ver versión de kubectl y del cluster
kubectl cluster-info # Info del cluster
kubectl get nodes # Listar nodos
kubectl describe node <nombre-nodo> # Detalles de un nodo
kubectl get pods # Listar pods
kubectl get pods -o wide # Con IPs y nodos donde corren
kubectl describe pod <nombre-pod> # Detalles de un pod
kubectl logs <nombre-pod> # Ver logs del pod
kubectl exec -it <nombre-pod> -- sh # Entrar al contenedor dentro del pod
kubectl get deployments # Listar deployments
kubectl describe deployment <nombre> # Ver detalles
kubectl scale deployment <nombre> --replicas=3 # Escalar replicas
kubectl rollout status deployment <nombre> # Ver estado del despliegue
kubectl rollout undo deployment <nombre> # Hacer rollback
kubectl get svc # Listar servicios
kubectl describe svc <nombre-servicio> # Detalles del servicio
kubectl get configmaps # Listar configmaps
kubectl describe configmap <nombre> # Ver detalles
kubectl get secrets # Listar secrets
kubectl describe secret <nombre> # Ver detalles
kubectl apply -f archivo.yaml # Crear o actualizar recursos
kubectl delete -f archivo.yaml # Eliminar recursos definidos en el archivo
kubectl get all # Listar todo en el namespace actual
kubectl get ns # Listar namespaces
kubectl config set-context --current --namespace=mi-namespace
kubectl get pods -n kube-system # Listar pods en kube-system
# 📌 En resumen:
# get → listar.
# describe → ver detalles.
# logs → revisar salida de pods.
# exec → entrar al contenedor.
# apply/delete → trabajar con archivos YAML.
@felipejoq
Copy link
Author

felipejoq commented Sep 2, 2025

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: eks-sample-linux-deployment
  namespace: eks-sample-app
  labels:
    app: eks-sample-linux-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: eks-sample-linux-app
  template:
    metadata:
      labels:
        app: eks-sample-linux-app
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/arch
                operator: In
                values:
                - amd64
                - arm64
      containers:
      - name: nginx
        image: public.ecr.aws/nginx/nginx:1.23
        ports:
        - name: http
          containerPort: 80
        imagePullPolicy: IfNotPresent
      nodeSelector:
        kubernetes.io/os: linux

services.yaml

apiVersion: v1
kind: Service
metadata:
  name: eks-sample-linux-service
  namespace: eks-sample-app
  labels:
    app: eks-sample-linux-app
spec:
  selector:
    app: eks-sample-linux-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer

hpa.yaml

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: eks-sample-hpa
  namespace: eks-sample-app
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: eks-sample-linux-deployment  # Apunta a tu Deployment existente
  minReplicas: 2
  maxReplicas: 4
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment