课程链接:http://video.jessetalk.cn/course/explore
良心课程,大家一起来学习哈!
所有资源对象(包括Pod, Service, Namespace, Volume)都可以打 Label,定义标签
Selectors:=, !=, in, not in, and 关系
#deploy.yamlapiVersion: apps/v1kind: Deploymentmetadata: name: k8s-demo namespace: netcore labels: name: k8s-demospec: replicas: 2 #2个实例 selector: #该selector用于匹配Pod,对应15行的labels matchLabels: name: k8s-demo template: metadata: labels: name: k8s-demo #给Pod打标签 spec: containers: - name: k8s-demo image: jessetalk/k8s-demo ports: - containerPort: 80 imagePullPolicy: Always---kind: ServiceapiVersion: v1metadata: name: k8s-demo namespace: netcorespec: type: NodePort ports: - port: 80 targetPort: 80 selector: #该selector用于选择Deployment的Pod,对应15行的labels name: k8s-demo #用Selectors来将Service绑定到Pod
#kubectl label selectors 查询(使用 kubectl 来针对 apiserver ,并且使用Equality-based的条件)$ kubectl get pods -l environment=production,tier=frontend
为何如此设计?
The type field is a string with the following possible values:
#查看podkubectl describe pod -l name-k8s-demo -n netcore
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
欢迎转载、使用、重新发布,但务必保留文章署名 郑子铭 (包含链接: http://www.cnblogs.com/MingsonZheng/ ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。
如有任何疑问,请与我联系 (504025730@qq.com) 。