labels.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package runtime
  15. const (
  16. PodNameLabel = "io.yunion.pod.name"
  17. PodNamespaceLabel = "io.yunion.pod.namespace"
  18. PodUIDLabel = "io.yunion.pod.uid"
  19. ContainerNameLabel = "io.yunion.container.name"
  20. ContainerRestartCountLabel = "io.yunion.container.restart_count"
  21. )
  22. const (
  23. ContainerNameAnnotation = "io.kubernetes.cri.container-name"
  24. ContainerTypeAnnotation = "io.kubernetes.cri.container-type"
  25. ImageNameAnnotation = "io.kubernetes.cri.image-name"
  26. SandboxIdAnnotation = "io.kubernetes.cri.sandbox-id"
  27. SandboxNameAnnotation = "io.kubernetes.cri.sandbox-name"
  28. SandboxNamespaceAnnotation = "io.kubernetes.cri.sandbox-namespace"
  29. SandboxUidAnnotation = "io.kubernetes.cri.sandbox-uid"
  30. )
  31. func GetContainerName(labels map[string]string) string {
  32. return labels[ContainerNameLabel]
  33. }
  34. func GetPodName(labels map[string]string) string {
  35. return labels[PodNameLabel]
  36. }
  37. func GetPodUID(labels map[string]string) string {
  38. return labels[PodUIDLabel]
  39. }
  40. func GetPodNamespace(labels map[string]string) string {
  41. return labels[PodNamespaceLabel]
  42. }