<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kubernetes Contributors – Code Organization</title><link>https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/</link><description>Recent content in Code Organization on Kubernetes Contributors</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/index.xml" rel="self" type="application/rss+xml"/><item><title>Docs: CRI API version skew policy</title><link>https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-version-skew-policy/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-version-skew-policy/</guid><description>
&lt;p>CRI is a plugin interface which enables the kubelet to use a wide variety of container runtimes,
without the need to recompile. CRI consists of a protocol buffers and gRPC API.
Read more about CRI API at &lt;a href="https://kubernetes.io/docs/concepts/architecture/cri/">kubernetes docs&lt;/a>.&lt;/p>
&lt;p>The CRI API is &lt;strong>only&lt;/strong> intended to be used for the kubelet to container runtime
interactions, or for node-level troubleshooting using a tool such as &lt;code>crictl&lt;/code>.
It is &lt;strong>not&lt;/strong> a common purpose container runtime API for general use, and is &lt;strong>intended&lt;/strong>
to be Kubernetes-centric. This is why there may be an undocumented logic
within a container runtimes that assumes the order or specific parameters
of call(s) that the kubelet makes. Attempts to call CRI API in a different order
by a client different than the kubelet, might result in unrecoverable error.
Whenever discovered, this logic is being documented and avoided.&lt;/p>
&lt;h2 id="version-skew-on-a-node">Version skew on a node&lt;/h2>
&lt;p>On a single Node there may be installed multiple components implementing
different versions of CRI API.&lt;/p>
&lt;p>For example, on a single node there might be:&lt;/p>
&lt;ul>
&lt;li>&lt;em>Kubelet&lt;/em> may call into &lt;em>Container Runtime&lt;/em> (e.g. &lt;a href="https://containerd.io">containerd&lt;/a>)
and &lt;em>Image Service Proxy&lt;/em> (e.g. &lt;a href="https://github.com/containerd/stargz-snapshotter">stargz-snapshotter&lt;/a>).
&lt;em>Container Runtime&lt;/em> may be versioned with the OS Image, &lt;em>Kubelet&lt;/em> is installed
by system administrator and &lt;em>Image Service proxy&lt;/em> is versioned by the third party vendor.&lt;/li>
&lt;li>&lt;em>Image Service Proxy&lt;/em> calls into &lt;em>Container Runtime&lt;/em>.&lt;/li>
&lt;li>&lt;em>CRI tools&lt;/em> (e.g. &lt;a href="https://kubernetes.io/docs/tasks/debug/debug-cluster/crictl/">crictl&lt;/a>)
may be installed by end user to troubleshoot, same as a third party daemonsets.
All of them are used to call into the &lt;em>Container Runtime&lt;/em> to collect container information.&lt;/li>
&lt;/ul>
&lt;p>So on a single node it may happen that &lt;em>Container Runtime&lt;/em> is serving a newer
version&amp;rsquo;d kubelet and older versioned crictl. This is a supported scenario within
the version skew policy.&lt;/p>
&lt;h3 id="version-skew-policy-for-cri-api">Version Skew Policy for CRI API&lt;/h3>
&lt;p>CRI API has two versions:&lt;/p>
&lt;ul>
&lt;li>Major semantic version (known versions are
&lt;code>v1alpha2&lt;/code> (&lt;a href="https://kubernetes.io/blog/2022/12/09/kubernetes-v1-26-release/#cri-v1alpha2-removed">removed in 1.26&lt;/a>), &lt;code>v1&lt;/code>).&lt;/li>
&lt;li>Kubernetes version (for example: &lt;code>@1.23&lt;/code>). Note, the &lt;code>cri-api&lt;/code> Golang library
is versioned as &lt;code>0.23&lt;/code> as it doesn&amp;rsquo;t guarantee Go types backward compatibility.&lt;/li>
&lt;/ul>
&lt;p>Major semantic version (e.g. &lt;code>v1&lt;/code>) is used to introduce breaking changes
and major new features that are incompatible with the current API.&lt;/p>
&lt;p>Kubernetes version is used to indicate a specific feature set implemented
on top of the major semantic version. All changes made without the change
of a major semantic version API must be backward and forward compatible.&lt;/p>
&lt;ul>
&lt;li>&lt;em>Kubelet&lt;/em> must work with the older &lt;em>Container Runtime&lt;/em> if it implements
the same semantic version of CRI API (e.g. &lt;code>v1&lt;/code>) of up to three Kubernetes minor
versions back. New features implemented in CRI API must be gracefully degraded.
For example, &lt;em>Kubelet&lt;/em> of version 1.26 must work with &lt;em>Container Runtime&lt;/em>
implementing &lt;code>k8s.io/cri-api@v0.23.0&lt;/code>+.&lt;/li>
&lt;li>&lt;em>Kubelet&lt;/em> must work with &lt;em>Container Runtime&lt;/em> if it implements
the same semantic version of CRI API (e.g. &lt;code>v1&lt;/code>) of up to
three minor versions up. New features implemented in CRI API must not change
behavior of old method calls and response values. For example, &lt;em>Kubelet&lt;/em> of
version 1.22 must work with &lt;em>Container Runtime&lt;/em> implementing &lt;code>k8s.io/cri-api@v0.25.5&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h2 id="versioning">Versioning&lt;/h2>
&lt;p>This library contains go classes generated from the CRI API protocol buffers and gRPC API.&lt;/p>
&lt;p>The library versioned as &lt;code>0.XX&lt;/code> as Kubernetes doesn&amp;rsquo;t provide any guarantees
on backward compatibility of Go wrappers between versions. However CRI API itself
(protocol buffers and gRPC API) is marked as stable &lt;code>v1&lt;/code> version and it is
backward compatible between versions.&lt;/p>
&lt;p>Versions like &lt;code>v0.&amp;lt;minor&amp;gt;.&amp;lt;patch&amp;gt;&lt;/code> (e.g. &lt;code>v0.25.5&lt;/code>) are considered stable.
It is discouraged to introduce CRI API changes in patch releases and recommended
to use versions like &lt;code>v0.&amp;lt;minor&amp;gt;.0&lt;/code>.&lt;/p>
&lt;p>All alpha and beta versions (e.g. &lt;code>k8s.io/cri-api@v0.26.0-beta.0&lt;/code>) should be
backward and forward compatible.&lt;/p>
&lt;h2 id="feature-development">Feature development&lt;/h2>
&lt;p>Some features development requires changes in CRI API and corresponding changes
in &lt;em>Container Runtime&lt;/em>. Coordinating between Kubernetes branches and release
versions and &lt;em>Container Runtime&lt;/em> versions is not always trivial.&lt;/p>
&lt;p>The recommended feature development flow is following:&lt;/p>
&lt;ul>
&lt;li>Review proposed CRI API changes during the KEP review stage.
Some field names and types may not be spelled out exactly at this stage.&lt;/li>
&lt;li>Locally implement a prototype that implement changes in both - Kubernetes and Container Runtime.&lt;/li>
&lt;li>Submit a Pull Request for Kubernetes implementing CRI API changes alongside the feature code.
Feature must be developed to degrade gracefully when used with older Container Runtime
according to the Version Skew policy.&lt;/li>
&lt;li>Once PR is merged, wait for the next Kubernetes release tag being produced.
Find the corresponding CRI API tag (e.g. &lt;code>k8s.io/cri-api@v0.26.0-beta.0&lt;/code>).&lt;/li>
&lt;li>This tag can be used to implement the feature in Container Runtime. It is recommended
to switch to the stable tag like (&lt;code>k8s.io/cri-api@v0.26.0&lt;/code>) once available.&lt;/li>
&lt;/ul>
&lt;h3 id="designing-new-cri-apis">Designing new CRI APIs&lt;/h3>
&lt;p>The following are considerations to take into account designing new features:&lt;/p>
&lt;ol>
&lt;li>The intended behavior, expectations, and call sequence, must be documented directly
in the protocol definition to simplify runtime adoption.&lt;/li>
&lt;li>The CRI API change must be as simple as possible. Choosing between simplicity and
expressiveness, simplicity has a preference.&lt;/li>
&lt;li>Existing fields must be reused only if their logical meaning allows it
and does not interfere with the existing features. Changing the expected value
format or call sequence may break things in a way that is hard to test and should be avoided.&lt;/li>
&lt;/ol>
&lt;h3 id="feature-testing">Feature testing&lt;/h3>
&lt;p>It is highly encouraged to add critest to every new CRI API.
Read about CRI API &lt;a href="https://github.com/kubernetes-sigs/cri-tools/blob/master/docs/validation.md">validation&lt;/a>.&lt;/p>
&lt;h2 id="whats-next">What&amp;rsquo;s next&lt;/h2>
&lt;ul>
&lt;li>What is &lt;a href="https://kubernetes.io/docs/concepts/architecture/cri/">Container Runtime Interface (CRI)&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-dev-policies/">Kubernetes feature development and container runtimes&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/">Installing Container Runtimes&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>Docs: Kubernetes feature development and container runtimes</title><link>https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-dev-policies/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-dev-policies/</guid><description>
&lt;p>CRI is a plugin interface which enables the kubelet to use a wide variety of container runtimes,
without the need to recompile. CRI consists of a protocol buffers and gRPC API.
Read more about CRI API at &lt;a href="https://kubernetes.io/docs/concepts/architecture/cri/">kubernetes docs&lt;/a>.&lt;/p>
&lt;p>The mechanics of a feature development that requires new CRI APIs is covered in
documentation on CRI API &lt;a href="https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-version-skew-policy/#feature-development">feature-development&lt;/a>.
This article defines policies for developing new Kubernetes features
that require CRI API changes. The goal of these policies is to ensure great user
experience for people trying the new feature early, adopting it when it is
enabled by default, and relying on it as a GA functionality.&lt;/p>
&lt;div class="alert alert-warning" role="alert">
&lt;h4 class="alert-heading">Notice&lt;/h4>
This document establishes development policies for new features requiring
adherence to the policy by two currently-participating runtime. This is not
a commitment from the Kubernetes community to support these features. Also
the list of participating container runtimes may change depending on the community
engagement.
&lt;/div>
&lt;h2 id="participating-container-runtimes">Participating container runtimes&lt;/h2>
&lt;p>Features and CRI API are supposed to be portable and generic and not limited to
a specific container runtime. However at this moment SIG Node requires every
feature to work on two container runtimes: &lt;a href="https://containerd.io/">containerd&lt;/a>
and &lt;a href="https://cri-o.io/">CRI-O&lt;/a>. These are two runtimes that are tested as part
of a Kubernetes development and release process to refer features portability.
When this document refers to two container runtimes, it assumes both -
containerd and CRI-O. If any other container runtimes begin working actively
with the Kubernetes community, or one of existing container runtimes will stop
engagement, this document will be updated.&lt;/p>
&lt;h2 id="same-maturity-level-for-beta-and-ga">Same maturity level (for beta and GA)&lt;/h2>
&lt;p>Implementation of an API needed for a Kubernetes feature in a container runtime
&lt;strong>must&lt;/strong> be at least the same maturity as in k8s at a moment of Kubernetes release.
This is similar to the &lt;a href="https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecating-a-feature-or-behavior">deprecation policy&lt;/a>
when one feature is replacing another.&lt;/p>
&lt;p>With containerd and CRI-O it means that for the GA features, there should be a
release of containerd and CRI-O implementing APIs needed for the feature in
those container runtimes. And those APIs &lt;strong>must not&lt;/strong> be marked as experimental
features (&lt;a href="https://containerd.io/releases/#experimental-features">containerd experimental features&lt;/a>).
For the beta, neither container runtime has a notion of beta feature and
realistically the same maturity criteria applies as for GA.&lt;/p>
&lt;p>Note, beta releases of containerd and CRI-O have a different semantic than the
beta feature in Kubernetes. Beta releases on container runtimes today
are referring to the release readiness rather than feature completeness.&lt;/p>
&lt;h2 id="same-maturity-level-for-alpha">Same maturity level (for alpha)&lt;/h2>
&lt;p>There should be at least one implementation of an API needed for the Kubernetes
feature merged into the container runtime development branch (main) or marked as
experimental. An e2e test which demonstrates that the feature is working should be
merged alongside the code. Note, tests may run against the default branch of a
container runtime and the feature can be still not shipped.&lt;/p>
&lt;p>The actual container runtime release may be delayed to the later stage, but
Kubernetes highly encourages fast availability of a release of a container
runtime that can be tested by early adopters.&lt;/p>
&lt;h2 id="minimal-number-of-implementations">Minimal number of implementations&lt;/h2>
&lt;p>Both containerd and CRI-O &lt;strong>must&lt;/strong> have a GA release with the implementations of an
API needed for a Kubernetes feature before this Kubernetes feature can be
promoted to GA.&lt;/p>
&lt;h2 id="safe-kubernetes-defaults">Safe Kubernetes defaults&lt;/h2>
&lt;p>The feature cannot be enabled by default in Kubernetes as a beta feature before
the required APIs are implemented in both container runtimes (containerd and
CRI-O) and there is a GA release of a container runtime for each. The feature
can be marked as beta, but disabled by default, if there is only one container
runtime implementation of a required API that is released as GA. Note, as for
any Kubernetes features, at least one release with the beta feature enabled by
default is required before it is progressing to GA.&lt;/p>
&lt;h2 id="guarantee-portability">Guarantee portability&lt;/h2>
&lt;p>The feature design (KEP PR) MUST be lgtm-ed by container runtime maintainers of
CRI-O and containerd.&lt;/p>
&lt;p>The feature can only be merged as alpha in Kubernetes, if there is an agreement
from both container runtime maintainers on the feature design in general and API
shape. Gaining this agreement will often involve authoring the pull request
demonstrating an API implementation to the both container runtime repositories
or an alternative way for container runtime maintainers to confirm viability of
suggested CRI APIs.&lt;/p>
&lt;h2 id="guaranteed-implementation">Guaranteed implementation&lt;/h2>
&lt;p>CRI API can only be merged if there is a PR in both - Kubernetes repository and
container runtime repository (at least one) utilizing this API and demoing the
feature working end to end. See CRI API
&lt;a href="https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-version-skew-policy/#feature-development">feature-development&lt;/a>
documentation.&lt;/p>
&lt;h2 id="features-discoverability">Features discoverability&lt;/h2>
&lt;p>Kubernetes features that depend on the environment or special container runtime
capabilities &lt;strong>must&lt;/strong> have its own explicit API configuration (like Pod API or Node
API) and &lt;strong>must&lt;/strong> not depend on the cluster or node configuration that is not
clearly exposed via these APIs. For example, it is OK to have Windows specific
features that are configured via Pod API. But it is not OK to design a feature
that will work on one container runtime and incompatible with the other
container runtime. There are three exceptions to this case:&lt;/p>
&lt;ul>
&lt;li>there will be a different behavior during the feature adoption period while
older runtime versions do not support the API yet. In those cases, attempting
to try the feature &lt;strong>must&lt;/strong> result in failing as fast as possible.&lt;/li>
&lt;li>LTS and older versions of container runtimes may not have an implementation of
an API and still be widely used by Kubernetes end users.&lt;/li>
&lt;li>If any of container runtime underlying systems cannot support the feature
in-principle (e.g. &lt;a href="https://katacontainers.io/">kata containers&lt;/a> with CRI-O
may have limitations), while CRI-O still supports the feature without these
systems configured, this &lt;strong>must&lt;/strong> be designed as part of a normal operation.
In this case, Pod or Node APIs &lt;strong>must&lt;/strong> handle these cases gracefully and
those &lt;strong>must&lt;/strong> be documented clearly.&lt;/li>
&lt;/ul>
&lt;h2 id="whats-next">What&amp;rsquo;s next&lt;/h2>
&lt;ul>
&lt;li>What is &lt;a href="https://kubernetes.io/docs/concepts/architecture/cri/">Container Runtime Interface (CRI)&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://deploy-preview-670--kubernetes-contributor.netlify.app/docs/code/cri-api-version-skew-policy/">CRI API version skew policy&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/">Installing Container Runtimes&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>