Kubernetes Steps

  •         cd posts
            docker build -t rayalevinson/posts:0.0.1 .
          

    Result: docker.io/rayalevinson/posts:0.0.1


  • Under the project create

    infra --> k8s --> posts-depl.yaml


  • posts-depl.yaml
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: posts-depl
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: posts
        template:
          metadata:
            labels:
              app: posts
          spec:
            containers:
              - name: posts
                image: docker.io/rayalevinson/posts:0.0.1
    

  • Create a deployment out of a config file

    cd myProject\infra\k8s

    kubectl apply -f posts-depl.yaml

    kubectl apply -f [config file name]


  • List all the running deployments

    kubectl get deployments


  • Deployment will recreate a pod tha was suddenly deleted / crashed

    kubectl get deployments


  • Print out information about all of the running pods

    kubectl get pods


  • Print out details about a specific deployment

    kubectl describe deployment [depl name]

    kubectl describe deployment posts-depl


  • Delete a deployment

    kubectl delete deployment [depl_name]


  • Execute the given command in a running pod

    kubectl exec -it [pod_name] [cmd]

    kubectl exec -it posts sh

    <--- run shell

    OR on Windows

    winpty kubectl exec -it posts sh

    <--- run shell

  • Print out logs from the given pod

    kubectl logs [pod_name]

    kubectl logs posts


  • Deletes the given pod

    kubectl delete pod [pod_name]

    kubectl delete pod posts


  • Tells kubernetes to process the config <------

    kubectl apply -f [config file name]

    kubectl apply -f posts.yaml


  • Print out some information about the running pod

    kubectl describe pod [pod_name]

    kubectl describe pod posts