k8s常用命令(增)
k8s常用命令(增)修改标签edit[root@master ~]# kubectl runnginx --image nginx --labels "app=test"pod/nginx created[root@master ~]# kubectl get podsNAMEREADYSTATUSRESTARTSAGEnginx1/1Running034s
·
k8s常用命令(增)
修改标签edit
[root@master ~]# kubectl run nginx --image nginx --labels "app=test"
pod/nginx created
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 34s
[root@master ~]# kubectl edit pods/nginx
pod/nginx edited
......
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2021-12-20T14:00:18Z"
labels:
app: nginx #标签
[root@master ~]# kubectl describe pods nginx
Name: nginx
Namespace: default
Priority: 0
Node: node1.example.com/192.168.244.147
Start Time: Mon, 20 Dec 2021 22:00:18 +0800
Labels: app=nginx #标签
Annotations: <none>
Status: Running
IP: 10.244.1.8
IPs:
IP: 10.244.1.8
Containers:
nginx:
Container ID: docker://d876d1fca12075c74c8058bc0d1f7900923a327366dbe8ce89873140baad8318
Image: nginx
Image ID: docker-pullable://nginx@sha256:9522864dd661dcadfd9958f9e0de192a1fdda2c162a35668ab6ac42b465f0603
Port: <none>
Host Port: <none>
State: Running
Started: Mon, 20 Dec 2021 22:00:34 +0800
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sfqmp (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-sfqmp:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-sfqmp
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 3m52s default-scheduler Successfully assigned default/nginx to node1.example.com
Normal Pulling 3m52s kubelet Pulling image "nginx"
Normal Pulled 3m36s kubelet Successfully pulled image "nginx" in 15.556640756s
Normal Created 3m36s kubelet Created container nginx
Normal Started 3m36s kubelet Started container nginx
回滚rollout
[root@master ~]# kubectl rollout --help
.......
Examples:
# Rollback to the previous deployment #回滚到以前的部署
kubectl rollout undo deployment/abc
# Check the rollout status of a daemonset #检查守护进程的转出状态
kubectl rollout status daemonset/foo
........
[root@master ~]# kubectl create deployment nginx --image nginx
deployment.apps/nginx created
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 41m
nginx-6799fc88d8-hqrl4 1/1 Running 0 26s
[root@master ~]# kubectl rollout undo deployment/nginx
扩展scale
(增减)扩展deployment类型的nginx容器或其他类型
[root@master ~]# kubectl scale --help
........
Examples:
# Scale a replicaset named 'foo' to 3.
kubectl scale --replicas=3 rs/foo
# Scale a resource identified by type and name specified in "foo.yaml" to 3.
kubectl scale --replicas=3 -f foo.yaml
# If the deployment named mysql's current size is 2, scale mysql to 3.
kubectl scale --current-replicas=2 --replicas=3 deployment/mysql
# Scale multiple replication controllers.
kubectl scale --replicas=5 rc/foo rc/bar rc/baz
# Scale statefulset named 'web' to 3.
kubectl scale --replicas=3 statefulset/web
#创建一个deployment类型的容器
[root@master ~]# kubectl create deployment nginx --image nginx
deployment.apps/nginx created
[root@master ~]#
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 2m12s
nginx-6799fc88d8-tw4qw 0/1 ContainerCreating 0 15s
#增减
[root@master ~]# kubectl scale --replicas 5 deployment/nginx
deployment.apps/nginx scaled
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 3m49s
nginx-6799fc88d8-7wpkj 1/1 Running 0 43s
nginx-6799fc88d8-8swjc 1/1 Running 0 43s
nginx-6799fc88d8-mc84k 1/1 Running 0 43s
nginx-6799fc88d8-rgd6w 1/1 Running 0 43s
nginx-6799fc88d8-tw4qw 1/1 Running 0 112s
#减少
[root@master ~]# kubectl scale --replicas 3 deployment/nginx
deployment.apps/nginx scaled
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 5m11s
nginx-6799fc88d8-7wpkj 1/1 Running 0 2m5s
nginx-6799fc88d8-8swjc 1/1 Running 0 2m5s
nginx-6799fc88d8-mc84k 0/1 Terminating 0 2m5s #正在删除
nginx-6799fc88d8-rgd6w 0/1 Terminating 0 2m5s
nginx-6799fc88d8-tw4qw 1/1 Running 0 3m14s
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 5m29s
nginx-6799fc88d8-7wpkj 1/1 Running 0 2m23s
nginx-6799fc88d8-8swjc 1/1 Running 0 2m23s
nginx-6799fc88d8-tw4qw 1/1 Running 0 3m32s
自动扩展autoscale
(定制一个最小范围和一个最大范围,当容器服务访问量过大时就会自动增加容器减轻负担,但不增加容器会超出指定范围)
[root@master ~]# kubectl autoscale --help
......
Examples:
# Auto scale a deployment "foo", with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used:
kubectl autoscale deployment foo --min=2 --max=10
# Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:
kubectl autoscale rc foo --max=5 --cpu-percent=80
#百分比 percent
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 12m
nginx-6799fc88d8-7wpkj 1/1 Running 0 9m43s
nginx-6799fc88d8-8swjc 1/1 Running 0 9m43s
nginx-6799fc88d8-tw4qw 1/1 Running 0 10m
#最少5个最多10个
[root@master ~]# kubectl autoscale --min 5 --max 10 --cpu-percent=50 deployment/nginx
horizontalpodautoscaler.autoscaling/nginx autoscaled
#水平自动控伸缩制器
5个nginx容器
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 15m
nginx-6799fc88d8-7wpkj 1/1 Running 0 12m
nginx-6799fc88d8-8qtsj 1/1 Running 0 39s
nginx-6799fc88d8-8swjc 1/1 Running 0 12m
nginx-6799fc88d8-svs9q 1/1 Running 0 39s
nginx-6799fc88d8-tw4qw 1/1 Running 0 13m
#查看
[root@master ~]# kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
nginx Deployment/nginx <unknown>/50% 5 10 5 6m59s
#删除
[root@master ~]# kubectl delete hpa nginx
horizontalpodautoscaler.autoscaling "nginx" deleted
[root@master ~]# kubectl get hpa
No resources found in default namespace.
describe 显示一个指定容器详情
[root@master ~]# kubectl describe pods/nginx
Name: nginx
Namespace: default
Priority: 0
Node: node1.example.com/192.168.244.147
Start Time: Mon, 20 Dec 2021 22:22:43 +0800
Labels: run=nginx
Annotations: <none>
Status: Running
IP: 10.244.1.12
IPs:
IP: 10.244.1.12
Containers:
nginx:
Container ID: docker://d1a4871b7bc5cabffc5d25b4edc5be2107084c7ae04d054c43d3cc1ac4138809
Image: nginx
Image ID: docker-pullable://nginx@sha256:9522864dd661dcadfd9958f9e0de192a1fdda2c162a35668ab6ac42b465f0603
Port: <none>
Host Port: <none>
State: Running
Started: Mon, 20 Dec 2021 22:23:00 +0800
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sfqmp (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-sfqmp:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-sfqmp
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 46m default-scheduler Successfully assigned default/nginx to node1.example.com
Normal Pulling 46m kubelet Pulling image "nginx"
Normal Pulled 46m kubelet Successfully pulled image "nginx" in 15.476004289s
Normal Created 46m kubelet Created container nginx
Normal Started 46m kubelet Started container nginx
logs 输出容器在 pod 中的日志
[root@master ~]# kubectl logs --help
.......
Examples:
# Return snapshot logs from pod nginx with only one container
kubectl logs nginx
# Return snapshot logs from pod nginx with multi containers
kubectl logs nginx --all-containers=true
# Return snapshot logs from all containers in pods defined by label app=nginx
kubectl logs -lapp=nginx --all-containers=true
# Return snapshot of previous terminated ruby container logs from pod web-1
kubectl logs -p -c ruby web-1
# Begin streaming the logs of the ruby container in pod web-1
kubectl logs -f -c ruby web-1
# Begin streaming the logs from all containers in pods defined by label app=nginx
kubectl logs -f -lapp=nginx --all-containers=true
# Display only the most recent 20 lines of output in pod nginx
kubectl logs --tail=20 nginx
# Show all logs from pod nginx written in the last hour
kubectl logs --since=1h nginx
# Show logs from a kubelet with an expired serving certificate
kubectl logs --insecure-skip-tls-verify-backend nginx
# Return snapshot logs from first container of a job named hello
kubectl logs job/hello
# Return snapshot logs from container nginx-1 of a deployment named nginx
kubectl logs deployment/nginx -c nginx-1
[root@master ~]# kubectl logs nginx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/20 14:23:00 [notice] 1#1: using the "epoll" event method
2021/12/20 14:23:00 [notice] 1#1: nginx/1.21.4
2021/12/20 14:23:00 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
2021/12/20 14:23:00 [notice] 1#1: OS: Linux 4.18.0-305.3.1.el8.x86_64
2021/12/20 14:23:00 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/20 14:23:00 [notice] 1#1: start worker processes
2021/12/20 14:23:00 [notice] 1#1: start worker process 31
2021/12/20 14:23:00 [notice] 1#1: start worker process 32
2021/12/20 14:23:00 [notice] 1#1: start worker process 33
2021/12/20 14:23:00 [notice] 1#1: start worker process 34
#查看deployment类型的日志
[root@master ~]# kubectl logs deployment/nginx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/12/20 15:04:13 [notice] 1#1: using the "epoll" event method
2021/12/20 15:04:13 [notice] 1#1: nginx/1.21.4
2021/12/20 15:04:13 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
2021/12/20 15:04:13 [notice] 1#1: OS: Linux 4.18.0-305.3.1.el8.x86_64
2021/12/20 15:04:13 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/12/20 15:04:13 [notice] 1#1: start worker processes
2021/12/20 15:04:13 [notice] 1#1: start worker process 31
2021/12/20 15:04:13 [notice] 1#1: start worker process 32
2021/12/20 15:04:13 [notice] 1#1: start worker process 33
2021/12/20 15:04:13 [notice] 1#1: start worker process 34
attach Attach 到一个运行中的容器
[root@master ~]# kubectl attach nginx
Defaulting container name to nginx.
Use 'kubectl describe pod/nginx -n default' to see all of the containers in this pod.
If you don't see a command prompt, try pressing enter.
exec 在一个 容器中执行一个命令
#在容器运行命令
[root@master ~]# kubectl exec nginx -- date
Mon Dec 20 15:27:17 UTC 2021
[root@master ~]# kubectl exec nginx -- ls /usr/local
bin
etc
games
include
lib
man
sbin
share
src
#进入一个容器
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 61m
nginx-6799fc88d8-hqrl4 1/1 Running 0 20m
[root@master ~]# kubectl exec -it nginx-6799fc88d8-hqrl4 -- /bin/bash
root@nginx-6799fc88d8-hqrl4:/# ls
bin etc mnt sbin var
boot home opt srv
dev lib proc sys
docker-entrypoint.d lib64 root tmp
docker-entrypoint.sh media run usr
root@nginx-6799fc88d8-hqrl4:/#
#创建一个service
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 68m
nginx-6799fc88d8-hqrl4 1/1 Running 0 26m
[root@master ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d1h
[root@master ~]# kubectl expose deployment nginx --port 8080 --target-port 80
service/nginx exposed
[root@master ~]# kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d1h
nginx ClusterIP 10.108.199.210 <none> 8080/TCP 4s
[root@master ~]# kubectl exec -it svc/nginx /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@nginx-6799fc88d8-hqrl4:/# ls
bin etc mnt sbin var
boot home opt srv
dev lib proc sys
docker-entrypoint.d lib64 root tmp
docker-entrypoint.sh media run usr
port-forward 将一个或多个本地端口转发到pod(端口映射)
[root@master ~]# kubectl port-forward --help
....
Examples:
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
kubectl port-forward pod/mypod 5000 6000
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment
kubectl port-forward deployment/mydeployment 5000 6000
# Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
kubectl port-forward service/myservice 8443:https
# Listen on port 8888 locally, forwarding to 5000 in the pod
kubectl port-forward pod/mypod 8888:5000
# Listen on port 8888 on all addresses, forwarding to 5000 in the pod
kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000
# Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 8888:5000
# Listen on a random port locally, forwarding to 5000 in the pod
kubectl port-forward pod/mypod :5000
#在前台运行
[root@master ~]# kubectl port-forward pod/nginx 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
cp 把文件复制到容器里或把容器里的文件cp到容器外
[root@master ~]# kubectl exec nginx -- ls /tmp
[root@master ~]#
[root@master ~]# ls
anaconda-ks.cfg kube-flannel.yml node2
flannel node1
[root@master ~]# kubectl cp /root/anaconda-ks.cfg nginx:/tmp
[root@master ~]# kubectl exec nginx -- ls /tmp
anaconda-ks.cfg
label 更新在这个资源上的 labels(标签)
[root@master ~]# kubectl describe deployment/nginx
Name: nginx
Namespace: default
CreationTimestamp: Mon, 20 Dec 2021 23:03:57 +0800
Labels: app=nginx
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: nginx-6799fc88d8 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 46m deployment-controller Scaled up replica set nginx-6799fc88d8 to 1
#修改标签
[root@master ~]# kubectl label deployment nginx --overwrite trueapp=test
deployment.apps/nginx labeled
[root@master ~]#
[root@master ~]# kubectl label deployment --overwrite pod nginx app=test
deployment.apps/nginx not labeled
Error from server (NotFound): deployments.apps "pod" not found
[root@master ~]# kubectl describe deployment/nginx
Name: nginx
Namespace: default
CreationTimestamp: Mon, 20 Dec 2021 23:03:57 +0800
Labels: app=test #nginx修改成test
trueapp=test
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: nginx-6799fc88d8 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 52m deployment-controller Scaled up replica set nginx-6799fc88d8 to 1
[root@master ~]#
api-resources 命令简称
[root@master ~]# kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
bindings v1 true Binding
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true ConfigMap
endpoints ep v1 true Endpoints
events ev v1 true Event
limitranges limits v1 true LimitRange
namespaces ns v1 false Namespace
nodes no v1 false Node
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
persistentvolumes pv v1 false PersistentVolume
pods po v1 true Pod
podtemplates v1 true PodTemplate
replicationcontrollers rc v1 true ReplicationController
resourcequotas quota v1 true ResourceQuota
secrets v1 true Secret
serviceaccounts sa v1 true ServiceAccount
services svc v1 true Service
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition
apiservices apiregistration.k8s.io/v1 false APIService
controllerrevisions apps/v1 true ControllerRevision
daemonsets ds apps/v1 true DaemonSet
deployments deploy apps/v1 true Deployment
replicasets rs apps/v1 true ReplicaSet
statefulsets sts apps/v1 true StatefulSet
tokenreviews authentication.k8s.io/v1 false TokenReview
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview
horizontalpodautoscalers hpa autoscaling/v1 true HorizontalPodAutoscaler
cronjobs cj batch/v1beta1 true CronJob
jobs batch/v1 true Job
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest
leases coordination.k8s.io/v1 true Lease
endpointslices discovery.k8s.io/v1beta1 true EndpointSlice
events ev events.k8s.io/v1 true Event
ingresses ing extensions/v1beta1 true Ingress
flowschemas flowcontrol.apiserver.k8s.io/v1beta1 false FlowSchema
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta1 false PriorityLevelConfiguration
ingressclasses networking.k8s.io/v1 false IngressClass
ingresses ing networking.k8s.io/v1 true Ingress
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy
runtimeclasses node.k8s.io/v1 false RuntimeClass
poddisruptionbudgets pdb policy/v1beta1 true PodDisruptionBudget
podsecuritypolicies psp policy/v1beta1 false PodSecurityPolicy
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding
roles rbac.authorization.k8s.io/v1 true Role
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass
csidrivers storage.k8s.io/v1 false CSIDriver
csinodes storage.k8s.io/v1 false CSINode
storageclasses sc storage.k8s.io/v1 false StorageClass
volumeattachments storage.k8s.io/v1 false VolumeAttachment
[root@master ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 99m
nginx-6799fc88d8-hqrl4 1/1 Running 0 58m
api-versions 在服务器上打印支持的API版本,以“group/version”的形式
[root@master ~]# kubectl api-versions
admissionregistration.k8s.io/v1
admissionregistration.k8s.io/v1beta1
apiextensions.k8s.io/v1
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1
apiregistration.k8s.io/v1beta1
apps/v1
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
certificates.k8s.io/v1
certificates.k8s.io/v1beta1
coordination.k8s.io/v1
coordination.k8s.io/v1beta1
discovery.k8s.io/v1beta1
events.k8s.io/v1
events.k8s.io/v1beta1
extensions/v1beta1
flowcontrol.apiserver.k8s.io/v1beta1
networking.k8s.io/v1
networking.k8s.io/v1beta1
node.k8s.io/v1
node.k8s.io/v1beta1
policy/v1beta1
rbac.authorization.k8s.io/v1
rbac.authorization.k8s.io/v1beta1
scheduling.k8s.io/v1
scheduling.k8s.io/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1
version 输出 client 和 server 的版本信息
[root@master ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:51:19Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
更多推荐
已为社区贡献2条内容
所有评论(0)