Kubernetes kubectl基础

创建: 2020/04/08

完成: 2020/04/09

 

创建集群(Cluster)
 检查版本  
minikube version

 

 启动集群  
minikube start

 

 检查kubectl版本  
kubectl version

 

 检查集群信息  
kubectl cluster-info

 

 获取nodes  
kubectl get nodes

 

   
   
   
部署应用(Deployment)
 创建Deployment  
kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1

 

 获取Deployment  
kubectl get delpoyments

 

 获取代理

 

 
kubectl proxy

 ● 直接接入Cluster内部,可以不用kubectl而直接通过curl发送api

   
   
   
   
   
探索应用程序
 列出资源  
kubectl get <resource-name>

 

 显示有关资源的详细信息  
kubectl describe <resource-name>

 

 获取pods和其中容器的log  
kubectl logs <pod-name>

 

 在pod中的容器内运行

 

kubectl exec <pod-name> <command>

 

 

   
   
   
   
使应用程序外部可见
 公开应用  
kubectl expose

 

 添加标签  
kubectl label <resource-type> <resource-name> <label-name>

 

 minikube ip  
$(minikube ip)

 

   
   
   
   
   
应用的扩展
 增加副本(replica)  
kubectl scale <type> <resource-name> --replicas=<count>

 

   
   
   
   
   
   
   
应用的更新
 更新image  
kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2

 

 rollout

 
Manage the rollout of a resource.
  
 Valid resource types include:

  *  deployments
  *  daemonsets
  *  statefulsets

Examples:
  # Rollback to the previous deployment
  kubectl rollout undo deployment/abc
  
  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

Available Commands:
  history     View rollout history
  pause       Mark the provided resource as paused
  restart     Restart a resource
  resume      Resume a paused resource
  status      Show the status of the rollout
  undo        Undo a previous rollout

Usage:
  kubectl rollout SUBCOMMAND [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).

 

   
   
   
   
   
   
posted @ 2020-04-08 08:48  懒虫哥哥  阅读(182)  评论(0编辑  收藏  举报