k8s 命令

发布时间 2023-09-22 18:31:29作者: MaxBruce

kind create cluster --name my-cluster

 

kind create cluster --config kind-example-config.yaml

 

加载镜像到集群:

kind load docker-image k8s.net.demo --name my-cluster

kubectl cluster-info --context kind-mytest

//显示当前的集群

kubectl config current-context

//显示当前的集群

kind get clusters

kubectl config get-contexts

切换集群

kubectl config use-context kubernetes-admin@kubernetes

//进入pod

kubectl exec -it nginx-deployment-77b4fdf86c-tm9hz – sh

查看节点的详细信息

kubectl get nodes -o wide

 

kubectl get namespaces

 

Kubectl get namespaces <name>

 

Kubectl describe namespace <name>

 

kubectl create namespace test-env #创建命名空间

 

 

kubectl get namespace #获取命名空间列表

 

kubectl get pods --namespace=test-env #获取指定命名空间中的pod

 

kind delete cluster --name mytest2

 

//pod 的端口映射.

$ kubectl port-forward k8s-net-pod 8090:80

Forwarding from 127.0.0.1:8090 -> 80

Forwarding from [::1]:8090 -> 80