k8s command-line tool - kubectl

View the status of the service

kubectl get

Gets the namespace

kubectl get namespaces

Gets pods

kubectl get pods

For more information about obtaining pods

kubectl describe pods

View log

kubectl logs podname

Execute commands in the pod

kubectl exec -ti podname bash

K8s service

 k8s in the service cluster is a group of abstract pod. Target pods in LabelSelector defined by yaml definition. By type field service application defines several ways of exposure:

  • ClusterIP, by default, to provide services by the external ip cluster, this approach can only be accessed within the cluster.
  • NodePort use NAT to provide external external services in the designated port node.
  • LoadBalancer, carried out by an external load balancing service access.
  • ExternalName

Check the service status

kubectl get service

External exposure services

kubectl expose deplyment/servicename --type="NodePort" --port 8080

 

Guess you like

Origin www.cnblogs.com/chenqr/p/11204618.html