可以使用以下命令为 StatefulSet(sts)中的 Pod 指定注释:
kubectl annotate statefulset <statefulset-name> kubernetes.io/description=<description>
其中,<statefulset-name>
是要指定注释的 StatefulSet 的名称,<description>
是要添加的注释。例如,如果要将一个名为 nginx
的 StatefulSet 的 kubernetes.io/description
注释设置为 This is a sample StatefulSet for nginx
, 可以运行以下命令:
kubectl annotate statefulset nginx kubernetes.io/description="This is a sample StatefulSet for nginx"
这将在所有 Pod 中添加该注释。如果只要特定的 Pod 具有该注释,则可以使用以下命令为单个 Pod 指定注释:
kubectl annotate pod <pod-name> kubernetes.io/description=<description>
其中,<pod-name>
是要指定注释的 Pod 的名称,<description>
是要添加的注释。例如,如果要将一个名为 nginx-0
的 Pod 的 kubernetes.io/description
注释设置为 This is a sample Pod for nginx
, 可以运行以下命令:
kubectl annotate pod nginx-0 kubernetes.io/description="This is a sample Pod for nginx"
这将仅在此 Pod 中添加该注释。