资源概念

1. 资源概念

  • Pod: k8s最小部署单元,一组容器的集合
  • Deployment:最常见的工作负载控制器,用于更高级别部署和管理Pod
  • Service:为一组Pod提供负载均衡,对外提供统一访问入口
  • Label:标签,附加到某个资源上,用于关联对象,查询和筛选
  • Namespace:命名空间,将对象逻辑上隔离,也利于权限控制

2. 命令使用

# service负载均衡使用
[root@k8s-master ~]# kubectl get service
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP        46h
nginx        NodePort    10.109.59.90    <none>        80:30836/TCP   17h
web          NodePort    10.102.43.204   <none>        80:30291/TCP   16h

# deployment使用
[root@k8s-master ~]# kubectl scale deployment web --replicas=3
deployment.apps/web scaled


# 查询pod
[root@k8s-master ~]# kubectl get pods
NAME                     READY   STATUS              RESTARTS   AGE
nginx-6799fc88d8-s5wvx   1/1     Running             0          17h
web-674477549d-flj78     1/1     Running             0          16h
web-674477549d-m7lsj     0/1     ContainerCreating   0          8s
web-674477549d-stk84     0/1     ContainerCreating   0          8s


# 标签的使用
[root@k8s-master ~]# kubectl get pods --show-labels
NAME                     READY   STATUS    RESTARTS   AGE   LABELS
nginx-6799fc88d8-s5wvx   1/1     Running   0          18h   app=nginx,pod-template-hash=6799fc88d8
web-674477549d-flj78     1/1     Running   0          17h   app=web,pod-template-hash=674477549d
web-674477549d-m7lsj     1/1     Running   0          28m   app=web,pod-template-hash=674477549d
web-674477549d-stk84     1/1     Running   0          28m   app=web,pod-template-hash=674477549d


# namespace命令空间

原文地址:https://www.cnblogs.com/scajy/p/14823118.html