- Learn OpenShift
- Denis Zuev Artemii Kropachev Aleksey Usov
- 197字
- 2021-08-13 16:03:52
Using Kubernetes labels
When you have an application that consists of one pod and one service, there is no problem operating these resources. But when your application grows, or you have tens or hundreds of projects, pods, services and other Kubernetes resources, it will get harder to operate and effectively troubleshoot Kubernetes. This is where we can use the Kubernetes labels we mentioned earlier in this chapter. We are going to run a couple more Kubernetes pods using labels:
$ kubectl run httpd1 --image=httpd --labels="app=httpd-demo1"
$ kubectl run httpd2 --image=httpd --labels="app=httpd-demo2"
Check the Kubernetes pods we have at the moment:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
httpd-8576c89d7-qjd62 1/1 Running 0 17m
httpd1-c9f7d7fd9-rn2nz 1/1 Running 0 21s
httpd2-5b4ff5cf57-9llkn 1/1 Running 0 15s
Now, imagine you have at least 10 or more pods. In order to efficiently filter out this output, we can use the -l option:
$ kubectl get pods -l="app=httpd-demo2"
NAME READY STATUS RESTARTS AGE
httpd2-5b4ff5cf57-9llkn 1/1 Running 0 2m
Filtering out output with Kubernetes labels is not the only use case. Labels are also used alongside selectors. You can get more information on both topics using the Kubernetes official documentation at https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/.
推薦閱讀
- Social Media Mining with R
- 構建高可用Linux服務器(第4版)
- FreeRTOS實時內核應用指南
- WordPress Mobile Web Development:Beginner's Guide
- 嵌入式Linux系統開發:基于Yocto Project
- 深入Linux內核架構與底層原理(第2版)
- 嵌入式實時操作系統μC/OS原理與實踐
- Social Data Visualization with HTML5 and JavaScript
- Introduction to R for Quantitative Finance
- Hadoop Real-World Solutions Cookbook
- Windows Server 2008組網技術與實訓(第3版)
- Linux網絡操作系統項目教程(RHEL 7.4/CentOS 7.4)(第3版)(微課版)
- Web Penetration Testing with Kali Linux(Third Edition)
- 電腦辦公(Windows 10 + Office 2016)入門與提高(超值版)
- Linux操作系統案例教程(第2版)