“This is the 12th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

A brief introduction of K8S

Kubernetes is a complete distributed system support platform with complete cluster management capabilities. More multi-level security protection and access mechanism, expanding multi-tenant application supporting ability, transparent service registration and discovery mechanism, built-in intelligent load balancer, strong fault detection and repair ability, service rolling upgrade and expansion ability, extensible online automatic scheduling mechanism and multi-granularity resources quota management ability. At the same time, Kubernetes provides perfect management tools, including development, deployment testing, operation and maintenance monitoring and other links.

K8S role:

  1. Service discovery and scheduling
  2. Load balancing
  3. Service self-healing
  4. Flexible Service Expansion
  5. Lateral capacity
  6. Mounting a storage volume

2. Common commands

2.1 Want to view kubectl command method

kubectl help 
kubectl <command> --help
Copy the code

2.2 Common Command Classes

Editing class: Editing services

kubectl edit svc  test0927-1-service -n ns-2    
Copy the code

Describe the class

Kubectl describe type/specific name -n namespaceCopy the code

Get detailed information class

Kubectl get type/specific name -n namespace -o wideCopy the code

Get detailed information class

Kubectl get/specific name -n namespace -o wide(or YAML) types include pods, ConfigMap, Replicasets (RS), Service (SRV), Deployment, and EndPoints.Copy the code

Roll back the class

kubectl rullout
Copy the code

2.3 K8S Common Commands

View parameter descriptions

kubectl explain deployment.spec.selector 
kubectl explain Ingress.spec
Copy the code

Check the labels

get pods --show-labels 
kubectl get pod -n kube-xx -l env
kubectl get pod -n kube-xx -l env=dev
kubectl get all -n kube-xx -l env
Copy the code

View the available API versions

 kubectl api-versions
Copy the code

Check the POD deployment

kubectl get pod -n kube-xx-dev -o wide
Copy the code

Delete the pod

kubectl delete pod jenkins-64b866d55f-vw6wf -n kube-xx-dev
Copy the code

For example, pod startup failed, pod restart, you can use this to check why

kubectl describe pod nacos-2 -n kube-xx-dev
Copy the code

See the log

kubectl logs -f jenkins-6bbf69d97c-x9gk8 -c jenkins -n kube-xx-dev
Copy the code

Inside the pod container

kubectl exec -ti jnlp-slave-b1g8x -c nlp-slave /bin/bash -n kube-xx-dev
Copy the code

Check pod, do not know which space is deployed

kubectl get pod -A -o wide |grep ingress
kubectl get ingress -A -o wide |grep ingress
kubectl get svc -A -o wide |grep ingress
kubectl get all -A -o wide |grep ingress
Copy the code