Cloud Container, Pods, Kubernetes – Command Summary

Kubernetes –  Docker – GCloud in a Nutshell

CREATE ARTIFACTS –  CLUSTER, DEPLOYMENT->PODS, SERVICES

Options available for cloud container cluster

keikis@keikis-academy:~$ gcloud container clusters

ERROR: (gcloud.container.clusters) Command name argument expected.

Usage: gcloud container clusters [optional flags] <command>

  command may be         create | delete | describe | get-credentials | list |

                         resize | update | upgrade

Creating cluster

gcloud container clusters create test –scopes “cloud-platform” –num-nodes 2 –zone us-central1-a

List Zones

gcloud compute zones list

jgarcicr@keikis-academy-186711:~$ gcloud compute zones list

 

Get info of the cluster

gcloud container clusters list

Example

jgarcicr@keikis-academy-186711:~$ gcloud container clusters list

 

More detail about nodes

kubectl get nodes

Describe a certain node

$ kubectl describe node gke-cluster-1-default-pool-777adf16-w20k

 

Example

jgarcicr@keikis-academy-186711:~$ kubectl get nodes

 

More info for nodes

 

BUILD DOCKER IMAGES

Build the application’s Docker image

docker build -t gcr.io/[YOUR_PROJECT_ID]/academy .

Example

jgarcicr@keikis-academy-186711:~/kubernetes/test$ docker build -t gcr.io/keikis-academy-186711/test .

 

Push the image to Google Container Registry so that your cluster can access the image

gcloud docker — push gcr.io/[YOUR_PROJECT_ID]/academy

Example

jgarcicr@keikis-academy-186711:~/kubernetes/test$ gcloud docker — push gcr.io/keikis-academy-186711/test

 

RUNS & DEPLOYMENTS

Run the container locally

docker run –rm -p 8080:8080 gcr.io/${PROJECT_ID}/hello-app:v1

Use kubectl to deploy the resources to the cluster

kubectl create -f academy.yaml

 

Create the academy service

kubectl create -f academy-service.yaml

 

QUERY ARTIFACTS – DEPLOYMENTS, PODS, SERVICES

Show Docker images

docker image ls -a

 

Get Cluster info

jgarcicr@keikis-academy-186711:~/kubernetes/test$ kubectl cluster-info

 

Track the status of the deployment

kubectl get deployments

Once the deployment is complete you can see the pods that the deployment created

kubectl get pods

Query for pods

kubectl get  pods

More info for pods

kubectl describe  pods

Get more info about service. The service’s external IP address to use

kubectl describe service academy

Service Info. Look out for the external IP still pending

jgarcicr@keikis-academy-186711:~/kubernetes/test$ kubectl get services

 

Get all info with containers name in json format

jgarcicr@keikis-academy-186711:~/kubernetes/test/test$ kubectl get pods -o json

 

DELETE ARTIFACTS – CLUSTER, DEPLOYMENT, PODS

Remove single image

docker rmi image_name:version/image-id

Remove all images

docker rmi $(docker images -qf “dangling=true”)

Kill containers and remove them

docker rm $(docker kill $(docker ps -aq))

Delete deployment

Once the deployment has the same number of available pods as desired pods, the deployment is complete. If you run into issues with the deployment, you can delete it and start over:

kubectl delete deployments academy-frontend

Delete Cluster in Zone. Zone is mandatory

jgarcicr@keikis-academy-186711:~$ gcloud container clusters delete test –zone  us-central1-a

 

Delete pods

kubectl delete pods <pod>

Delete pods force

kubectl delete pods <pod> –grace-period=0 –force

Delete all nodes

kubectl delete node –all

MONITOR & LOGS

View the Container’s logs by pod name with only one container

kubectl logs dapi-envars-resourcefieldref

Logs of Pod in Container

kubectl logs test-frontend-3341430478-2rq35 test-app

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Social media & sharing icons powered by UltimatelySocial