说我有以下Pod规格。
apiVersion: apps/v1beta1
kind: Deployment
metadata:
# Unique key of the Deployment instance
name: deployment-example
spec:
# 3 Pods should exist at all times.
replicas: 3
template:
metadata:
labels:
# Apply this label to pods and default
# the Deployment label selector to this value
app: nginx
spec:
containers:
- name: nginx
# Run this image
image: nginx:1.10
Run Code Online (Sandbox Code Playgroud)
在这里,容器的名称是nginx
。有没有办法从正在运行的容器中获取“ nginx”字符串?
我的意思是,一旦我用类似的东西执行到容器中
kubectl exec -it <pod-name> -c nginx bash
Run Code Online (Sandbox Code Playgroud)
有没有一种编程的方法来获取pod规范中的给定容器名称?
请注意,这不一定是在中打印的docker容器名称docker ps
。Kubernetes为生成的Docker容器编写了一个更长的名称。
该向下API看起来在这方面的承诺。但是container name …
kubernetes ×1