我有一个输入字符串说Please go to http://stackoverflow.com.检测到String的url部分,并且<a href=""></a>许多浏览器/ IDE /应用程序自动添加锚点.所以它变成了Please go to <a href='http://stackoverflow.com'>http://stackoverflow.com</a>.
我需要使用Java做同样的事情.
当我跑步时kubectl -n abc-namespace describe pod my-pod-zl6m6,我得到了很多关于pod的信息以及最后的事件.
有没有办法使用kubectl describe或kubectl get命令输出pod的事件?
我正在尝试为基于某些选择器的一组 pod 创建一个服务。例如,以下get pods命令根据我的要求检索正确的 pod -
kubectl get pods --selector property1=dev,property2!=admin
Run Code Online (Sandbox Code Playgroud)
以下是服务定义 yaml 的摘录,我在其中尝试使用与上述相同的选择器 -
apiVersion: v1
kind: Service
metadata:
name: service1
spec:
type: NodePort
ports:
- name: port1
port: 30303
targetPort: 30303
selector:
property1: dev
<< property2: ???? >>>
Run Code Online (Sandbox Code Playgroud)
我尝试过matchExpressions但没有意识到service 不在支持 set-based filters 的资源中。它导致以下错误 -
error: error validating "STDIN": error validating data: ValidationError(Service.spec.selector.matchExpressions): invalid type for io.k8s.api.core.v1.ServiceSpec.selector: got "array", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false …Run Code Online (Sandbox Code Playgroud) 我希望 Prometheus 只抓取带有特定注释的 Kubernetes 集群中的 pod。因此,在作业配置中,我想__meta_kubernetes_pod_annotationpresent_<annotationname> : true按照此处的建议使用 - https://prometheus.io/docs/prometheus/latest/configuration/configuration/#pod for Prometheus 的 Kubernetes SD 配置。
问题是,我找不到相同的任何示例:(
一位同事建议——
- job_name: 'k8sPodScrape'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: ['__meta_kubernetes_pod_annotationpresent_my_custom_annotation']
action: 'keep'
regex: 'true'
Run Code Online (Sandbox Code Playgroud)
但我不太确定它是否有效以及如何?任何指示都会有很大帮助。