[root@linux-node1 ~]# kubectl api-versions admissionregistration.k8s.io/v1beta1 apiextensions.k8s.io/v1beta1 apiregistration.k8s.io/v1 apiregistration.k8s.io/v1beta1 apps/v1 apps/v1beta1 apps/v1beta2 authentication.k8s.io/v1 authentication.k8s.io/v1beta1 authorization.k8s.io/v1 authorization.k8s.io/v1beta1 autoscaling/v1 autoscaling/v2beta1 batch/v1 batch/v1beta1 certificates.k8s.io/v1beta1 events.k8s.io/v1beta1 extensions/v1beta1 networking.k8s.io/v1 policy/v1beta1 rbac.authorization.k8s.io/v1 rbac.authorization.k8s.io/v1beta1 storage.k8s.io/v1 storage.k8s.io/v1beta1 v1
[root@linux-node1 ~]# kubectl explain deployment KIND: Deployment VERSION: extensions/v1beta1 DESCRIPTION: DEPRECATED - This group version of Deployment is deprecated by apps/v1beta2/Deployment. See the release notes for more information. Deployment enables declarative updates for Pods and ReplicaSets. FIELDS: apiVersion <string> APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources kind <string> Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds metadata <Object> Standard object metadata. spec <Object> Specification of the desired behavior of the Deployment. status <Object> Most recently observed status of the Deployment.
yaml文件示例:
# cat nginx-daemonset.yam
apiVersion: apps/v1 kind: DaemonSet metadata: name: nginx-daemonset labels: app: nginx spec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.13.12 ports: - containerPort: 80 nodeSelector: nginx_yaml
[root@linux-node1 ~]# kubectl get pod -l app=nginx -o wide NAME READY STATUS RESTARTS AGE IP NODE nginx-daemonset-lr8rk 1/1 Running 0 1d 10.2.76.4 192.168.56.13
yaml文件示例:
# cat nginx-daemonset.yam
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-daemonset
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.13.12
ports:
- containerPort: 80
nodeSelector:
nginx_yaml
[root@linux-node1 ~]# kubectl get pod -L app NAME READY STATUS RESTARTS AGE APP nginx-daemonset-lr8rk 1/1 Running 0 1d nginx
[root@linux-node1 ~]# kubectl label nodes 192.168.56.13 nginx_yaml=true node "192.168.56.13" labeled
[root@linux-node1 ~]# kubectl get node --show-labels NAME STATUS ROLES AGE VERSION LABELS 192.168.56.12 Ready <none> 2d v1.10.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,edgenode=true,kubernetes.io/hostname=192.168.56.12 192.168.56.13 Ready <none> 2d v1.10.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=192.168.56.13,nginx_yaml=true
[root@linux-node1 ~]# kubectl label nodes 192.168.56.13 nginx_yaml- node "192.168.56.13" labeled
[root@linux-node1 ~]# kubectl get namespace NAME STATUS AGE default Active 2d kube-public Active 2d kube-system Active 2d
[root@linux-node1 ~]# kubectl create namespace test-namespace
namespace "test-namespace" created
[root@linux-node1 ~]# kubectl get namespace
NAME STATUS AGE
default Active 2d
kube-public Active 2d
kube-system Active 2d
test-namespace Active 3s
[root@linux-node1 ~]# kubectl delete namespace test-namespace namespace "test-namespace" deleted [root@linux-node1 ~]# kubectl get namespace NAME STATUS AGE default Active 2d kube-public Active 2d kube-system Active 2d test-namespace Terminating 1m [root@linux-node1 ~]# kubectl get namespace NAME STATUS AGE default Active 2d kube-public Active 2d kube-system Active 2d
[root@linux-node1 ~]# kubectl get pod NAME READY STATUS RESTARTS AGE nginx-daemonset-kkkb6 1/1 Running 0 19h [root@linux-node1 ~]# kubectl exec nginx-daemonset-kkkb6 -- cat /etc/resolv.conf nameserver 10.1.0.2 search default.svc.cluster.local. svc.cluster.local. cluster.local. options ndots:5
原文:https://www.cnblogs.com/faithH/p/12171983.html