serving the solutions day and night


Sunday, August 16, 2020

Deploy ASP.NET Core Application images in Kubernetes (K8s) & POD

Publish the image in Docker Hub

Rename the image tag from frontendmvc:v1, to <account_username>/<repository_name>:<tag> (in our case, makdockerhub/myapp:frontendmvc-v1). 

docker tag frontendmvc makader/myapp:frontendmvc-v1

Publish the image with the docker push command. 

  docker push makader/myapp:frontendmvc-v1



Now we can deploy a frontendmvc container everywhere (aws, azure, pcf, Kubernetes,...).

Deploy frontendmvc in Kubernetes, create a Kubernetes resource known as the POD. 

  • A POD is the minimum deployable unit in the cluster, so in Kubernetes, we can refer about PODs instead of containers. 
  • A POD can contain one or more container—usually only one, but if you have more containers that are strongly dependent, you can deploy them together in the same pod. They will scale together and share the same IP address. 
  • Create a POD, specifying a name, the image, and the port where the container responds. restart indicates that if the pod fails or dies, it will never be recreated

 kubectl run frontendmvcv1 --image=makader/myapp:frontendmvc-v1 --port 80 --restart=Never    
 kubectl get pods - list the created pods and their status
 kubectl describe pod frontendmvcv1
  • To analyze the created pod in depth, which shows all the available information about the pod and the containers contained within it. The image contains, a status label for the pod and the container.
  • The POD status values are, the Pending, during which the containers in it are loaded the; the Failed state,errors creating the containers; otherwise, the Running state, all containers are created and at least one is starting, restarting, or running.
  • When all the containers in the pod are terminated successfully and will not be restarted, the pod will assume the Succeeded status.
 kubectl delete pod frontendmvcv1


Create a POD using YAML configuration file (fronendmvc_pod.yml)that will be sent to the cluster 

apiVersion: v1
kind: Pod
  name: frontendmvc-pod
    app: myapp
    version: v1
    zone: prod
      image: "makader/myapp:frontendmvc-v1"
      name: myapp-frontendmvc
         containerPort: 80

  • The version, which is needed by the cluster to correctly understand the configuration. 
  • The kind of item that we want to create, a Pod. 
  • The metadata - name, which indicates the pod name;  labels, which adds some custom labels to the pod in the <key>:<value> format; 
  • The spec (item specification), which in the case of the pod is the definition of the containers in it. 
  • To create, execute command  "kubectl create -f frontendmvc_pod.yaml"

No comments: