0

Crear un pod en .yaml

Armando Serrano
Armando Serrano

Requerimientos:

  1. Tener un cluster de kubernetes .
  2. Referencias :
  3. https://web.digitalinnovation.one/articles/crear-cluster-de-kubernetes-con-minikube?back=/articles
  4. https://web.digitalinnovation.one/articles/crear-cluster-de-kubernetes-con-k3d?back=/articles

Actividades:

  1. Crear un pod
  2. Desplegar un pod
  3. Listar pod
  4. Describir el pod
  5. Eliminar el pod

----------------------------------------------------------------------------------

Crear un pod

[root@localhost ~]# touch simple_pod.yaml
[root@localhost ~]# vi simple_pod.yaml
### presiona la tecla "insert"  y copia lo sigueinte dentro del simple_pod.yaml ####

apiVersion: v1
kind: Pod
metadata:
  name: simple-pod
  namespace: default
  labels:
    app: simple-pod
spec:
  containers:
  - name: simple-pod
    image: busybox
    command:
      - sleep
      - "3600"



### presiona la tecla "ESC" y escribe ":wq"  ###

Desplegar un pod

[root@localhost ~]# kubectl apply -f simple_pod.yaml -n default
pod/simple-pod created

Listar pod

[root@localhost ~]# kubectl get pods -n default
NAME         READY   STATUS             RESTARTS   AGE
simple-pod   1/1     Running            0          87s

Describir el pod

[root@localhost ~]#  kubectl describe pod simple-pod -n default
Name:         simple-pod
Namespace:    default
Priority:     0
Node:         control-plane.minikube.internal/192.168.0.11
Start Time:   Sat, 12 Jun 2021 01:59:06 -0400
Labels:       app=simple-pod
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"simple-pod"},"name":"simple-pod","namespace":"default"},"spe...
Status:       Running
IP:           172.17.0.4
IPs:
  IP:  172.17.0.4
Containers:
  simple-pod:
    Container ID:  docker://061997feef315efb1d3f96ea7a9d3171f9a153abb8d7d22381eb9a672f613fda
    Image:         busybox
    Image ID:      docker-pullable://busybox@sha256:930490f97e5b921535c153e0e7110d251134cc4b72bbb8133c6a5065cc68580d
    Port:          <none>
    Host Port:     <none>
    Command:
      sleep
      3600
    State:          Running
      Started:      Sat, 12 Jun 2021 01:59:09 -0400
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-fltdx (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  default-token-fltdx:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-fltdx
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age   From                                      Message
  ----    ------     ----  ----                                      -------
  Normal  Scheduled  49s   default-scheduler                         Successfully assigned default/simple-pod to control-plane.minikube.internal
  Normal  Pulling    47s   kubelet, control-plane.minikube.internal  Pulling image "busybox"
  Normal  Pulled     45s   kubelet, control-plane.minikube.internal  Successfully pulled image "busybox" in 1.848810918s
  Normal  Created    45s   kubelet, control-plane.minikube.internal  Created container simple-pod
  Normal  Started    44s   kubelet, control-plane.minikube.internal  Started container simple-pod


Eliminar el pod

kubectl delete pod  simple-pod -n default
pod "simple-pod" deleted




0
0

Comentários (0)