kubectl command management

kubectl command management

View more help command

[root@k8s-master ~]# kubectl --help

 

Creating a namespace

[root@k8s-master ~]# kubectl create namespace yunjisuan

namespace "yunjisuan" created

[root @ k8s-master ~] # kubectl get namespace / ns can

 

View All

[root@k8s-master ~]# kubectl get all

NAME                        READY     STATUS    RESTARTS   AGE

po/nginx-5fc8fd597f-4q22p   1/1       Running   0          9m

po/nginx-5fc8fd597f-8h94r   1/1       Running   0          11m

po/nginx-5fc8fd597f-ppfhf   1/1       Running   0          11m

 

View resources yaml file information, and can be modified

I directly modify nginx version number is 1.12

[root@k8s-master ~]# kubectl edit deploy/nginx

 template:

    metadata:

      creationTimestamp: null

      labels:

        run: nginx

    spec:

      containers:

      - image: nginx:1.12

        imagePullPolicy: Always

 

View yaml file resource has been modified successfully

[root@k8s-master ~]# kubectl describe po/nginx-5fc8fd597f-4q22p

 nginx:

    Container ID:   docker://706661f913c042c2aa2edfd2d649eccade76b9bad71e53052f69588749580f4e

    Image:          nginx:1.12

 

Check into the group information

[root@k8s-master ~]# kubectl cluster-info

Kubernetes master is running at http://localhost:8080

kubernetes-dashboard is running at http://localhost:8080/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy

 

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

 

View pod log

[root@k8s-master ~]# kubectl logs nginx-5fc8fd597f-4q22p

 

Into the pod

[root@k8s-master ~]# kubectl exec -it nginx-5fc8fd597f-4q22p bash

root@nginx-5fc8fd597f-4q22p:/#

 

View pod catalog file

[root@k8s-master ~]# kubectl exec -it nginx-5fc8fd597f-4q22p -- ls

bin   dev  home  lib64 mnt  proc  run  srv  tmp  var

boot  etc  lib  media opt  root  sbin  sys  usr

 

View version

[root@k8s-master ~]# kubectl version

 

Delete Resource

[root@k8s-master ~]# kubectl delete deploy/nginx

[root@k8s-master ~]# kubectl delete svc/nginx

 

View Resources

[root@k8s-master ~]# kubectl get all

 

Guess you like

Origin www.cnblogs.com/zc1741845455/p/11140004.html