1. 程式人生 > >kubectl管理kubernetes叢集

kubectl管理kubernetes叢集

[[email protected] ~]# kubectl get nodes  檢視叢集節點
NAME      STATUS    AGE
node1     Ready     25m
node2     Ready     19m
[[email protected] ~]# kubectl version  檢視版本
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-07-03T15:31:10Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
[

[email protected] ~]# kubectl run nginx --image=docker.io/nginx --replicas=1 --port=9000
deployment "nginx" created
[[email protected] ~]# kubectl get deployment
NAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx     1         1         1            0           15s
[
[email protected]
~]# kubectl get pods
NAME                     READY     STATUS    RESTARTS   AGE
nginx-2187705812-8r0h4   1/1       Running   0          1h
[
[email protected]
~]# kubectl get pods -o wide
NAME                     READY     STATUS    RESTARTS   AGE       IP           NODE
nginx-2187705812-8r0h4   1/1       Running   0          1h        10.255.4.2   node1
想要刪除一個容器的時候:

[[email protected] ~]# kubectl delete pod nginx-2187705812-8r0h4
pod "nginx-2187705812-8r0h4" deleted
[[email protected] ~]# kubectl get pod
NAME                     READY     STATUS              RESTARTS   AGE
nginx-2187705812-6dn2r   0/1       ContainerCreating   0          4s
刪除了之後還依然有,這個是因為建立deployment的時候引數--replicas=1起作用了。想要刪除的話直接刪除deployment就可以了。

[[email protected] ~]# kubectl delete deployment nginx
deployment "nginx" deleted

yaml語法: