Skip to content

Commit 11a2014

Browse files
Jonathan Boulleberryjamcoding
Jonathan Boulle
authored andcommitted
CRI: clarify purpose of annotations
Add language to make it explicit that annotations are not to be altered by runtimes, and should only be used for features that are opaque to the Kubernetes APIs. Unfortunately there are currently exceptions introduced in [1][1], but this change makes it clear that they are to be changed and that no more such semantic-affecting annotations should be introduced. In the spirit of the discussion and conclusion in [2][2]. Also captures the link between the annotations returned by various status queries and those supplied in associated configs. [1]: kubernetes#34819 [2]: kubernetes#30819 (comment)
1 parent e3429d2 commit 11a2014

File tree

2 files changed

+96
-32
lines changed

2 files changed

+96
-32
lines changed

pkg/kubelet/api/v1alpha1/runtime/api.pb.go

+48-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/kubelet/api/v1alpha1/runtime/api.proto

+48-16
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,29 @@ message PodSandboxConfig {
234234
repeated PortMapping port_mappings = 5;
235235
// Key-value pairs that may be used to scope and select individual resources.
236236
map<string, string> labels = 6;
237-
// Annotations is an unstructured key value map that may be set by external
238-
// tools to store and retrieve arbitrary metadata. There are a few features are
239-
// driven by annotations, Runtimes could support them optionally:
237+
// Unstructured key-value map that may be set by the kubelet to store and
238+
// retrieve arbitrary metadata. This will include any annotations set on a
239+
// pod through the Kubernetes API.
240+
//
241+
// Annotations MUST NOT be altered by the runtime; the annotations stored
242+
// here MUST be returned in the PodSandboxStatus associated with the pod
243+
// this PodSandboxConfig creates.
244+
//
245+
// In general, in order to preserve a well-defined interface between the
246+
// kubelet and the container runtime, annotations SHOULD NOT influence
247+
// runtime behaviour. For legacy reasons, there are some annotations which
248+
// currently explicitly break this rule, listed below; in future versions
249+
// of the interface these will be promoted to typed features.
250+
//
251+
// Annotations can also be useful for runtime authors to experiment with
252+
// new features that are opaque to the Kubernetes APIs (both user-facing
253+
// and the CRI). Whenever possible, however, runtime authors SHOULD
254+
// consider proposing new typed fields for any new features instead.
240255
//
241256
// 1. AppArmor
242257
//
243258
// key: container.apparmor.security.beta.kubernetes.io/<container_name>
244-
// description: apparmor profile for the container.
259+
// description: apparmor profile for a container in this pod.
245260
// value:
246261
// * runtime/default: equivalent to not specifying a profile.
247262
// * localhost/<profile_name>: profile loaded on the node
@@ -255,8 +270,8 @@ message PodSandboxConfig {
255270
// value: see below.
256271
//
257272
// key: security.alpha.kubernetes.io/seccomp/container/<container name>
258-
// description: the seccomp profile for the container (overides pod).
259-
// values: see below
273+
// description: the seccomp profile for the container (overrides pod).
274+
// value: see below
260275
//
261276
// The value of seccomp is runtime agnostic:
262277
// * runtime/default: the default profile for the container runtime
@@ -348,10 +363,12 @@ message PodSandboxStatus {
348363
optional PodSandboxNetworkStatus network = 5;
349364
// Linux-specific status to a pod sandbox.
350365
optional LinuxPodSandboxStatus linux = 6;
351-
// Labels are key value pairs that may be used to scope and select individual resources.
366+
// Labels are key-value pairs that may be used to scope and select individual resources.
352367
map<string, string> labels = 7;
353-
// Annotations is an unstructured key value map that may be set by external
354-
// tools to store and retrieve arbitrary metadata.
368+
// Unstructured key-value map holding arbitrary metadata.
369+
// Annotations MUST NOT be altered by the runtime; the value of this field
370+
// MUST be identical to that of the corresponding PodSandboxConfig used to
371+
// instantiate the pod sandbox this status represents.
355372
map<string, string> annotations = 8;
356373
}
357374

@@ -391,8 +408,10 @@ message PodSandbox {
391408
optional int64 created_at = 4;
392409
// Labels of the PodSandbox.
393410
map<string, string> labels = 5;
394-
// Annotations is an unstructured key value map that may be set by external
395-
// tools to store and retrieve arbitrary metadata.
411+
// Unstructured key-value map holding arbitrary metadata.
412+
// Annotations MUST NOT be altered by the runtime; the value of this field
413+
// MUST be identical to that of the corresponding PodSandboxConfig used to
414+
// instantiate this PodSandbox.
396415
map<string, string> annotations = 6;
397416
}
398417

@@ -551,8 +570,16 @@ message ContainerConfig {
551570
// prefix ::= DNS_SUBDOMAIN
552571
// name ::= DNS_LABEL
553572
map<string, string> labels = 9;
554-
// Annotations is an unstructured key value map that may be set by external
555-
// tools to store and retrieve arbitrary metadata.
573+
// Unstructured key-value map that may be used by the kubelet to store and
574+
// retrieve arbitrary metadata.
575+
//
576+
// Annotations MUST NOT be altered by the runtime; the annotations stored
577+
// here MUST be returned in the ContainerStatus associated with the container
578+
// this ContainerConfig creates.
579+
//
580+
// In general, in order to preserve a well-defined interface between the
581+
// kubelet and the container runtime, annotations SHOULD NOT influence
582+
// runtime behaviour.
556583
map<string, string> annotations = 10;
557584
// Path relative to PodSandboxConfig.LogDirectory for container to store
558585
// the log (STDOUT and STDERR) on the host.
@@ -665,8 +692,10 @@ message Container {
665692
optional int64 created_at = 7;
666693
// Key-value pairs that may be used to scope and select individual resources.
667694
map<string, string> labels = 8;
668-
// Annotations is an unstructured key value map that may be set by external
669-
// tools to store and retrieve arbitrary metadata.
695+
// Unstructured key-value map holding arbitrary metadata.
696+
// Annotations MUST NOT be altered by the runtime; the value of this field
697+
// MUST be identical to that of the corresponding ContainerConfig used to
698+
// instantiate this Container.
670699
map<string, string> annotations = 9;
671700
}
672701

@@ -708,7 +737,10 @@ message ContainerStatus {
708737
optional string message = 11;
709738
// Key-value pairs that may be used to scope and select individual resources.
710739
map<string,string> labels = 12;
711-
// Annotations is an unstructured key value map.
740+
// Unstructured key-value map holding arbitrary metadata.
741+
// Annotations MUST NOT be altered by the runtime; the value of this field
742+
// MUST be identical to that of the corresponding ContainerConfig used to
743+
// instantiate the Container this status represents.
712744
map<string,string> annotations = 13;
713745
// Mounts for the container.
714746
repeated Mount mounts = 14;

0 commit comments

Comments
 (0)