Skip to content

Add Cilium k8s CRDs#166

Open
bmurray wants to merge 3 commits intoapple:mainfrom
bmurray:main
Open

Add Cilium k8s CRDs#166
bmurray wants to merge 3 commits intoapple:mainfrom
bmurray:main

Conversation

@bmurray
Copy link
Copy Markdown

@bmurray bmurray commented Mar 19, 2026

Cilium is a widely used CNI for k8s clusters. We're trying to keep all our k8s configs in pkl, so we needed the pkl schemas. I used the k8s.contrib.crd generator to generate the CRDs. I also included some tests, similar to the k8s.networking.gateway CRDs.

Copy link
Copy Markdown
Contributor

@HT154 HT154 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay on this. We needed to discuss how we intend to support CRDs like this in pkl-pantry. Here's how we're approaching this:

  • We will happily accept generated packages containing K8s CRD.
  • We (the Pkl team) will rely on community contributions to keep these packages up to date with their upstream software.

Comment on lines +2 to +4
set -euo pipefail

BASE_URL="https://raw.githubusercontent.com/cilium/cilium/refs/heads/main/pkg/k8s/apis/cilium.io/client/crds"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script must be run from the package root.

Suggested change
set -euo pipefail
BASE_URL="https://raw.githubusercontent.com/cilium/cilium/refs/heads/main/pkg/k8s/apis/cilium.io/client/crds"
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR"
BASE_URL="https://raw.githubusercontent.com/cilium/cilium/refs/heads/main/pkg/k8s/apis/cilium.io/client/crds"

Comment on lines +42 to +44
done

echo "Done!"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer to format inline when generating code!

Suggested change
done
echo "Done!"
done
echo "Formatting..."
cd ../..
./gradlew spotlessApply
echo "Done!"

Comment on lines +114 to +141
/// Selector is a label selector to select objects of the type specified by AdvertisementType. For the
/// PodCIDR AdvertisementType it is not applicable. For other advertisement types, if not specified, no
/// objects of the type specified by AdvertisementType are selected for advertisement.
class Selector {
/// matchExpressions is a list of label selector requirements. The requirements are ANDed.
matchExpressions: Listing<MatchExpression>?

/// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is
/// equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and
/// the values array contains only "value". The requirements are ANDed.
matchLabels: Mapping<String, String(length <= 63, matches(Regex("^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$")))>?
}

/// A label selector requirement is a selector that contains values, a key, and an operator that relates
/// the key and values.
class MatchExpression {
/// key is the label key that the selector applies to.
key: String

/// operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists
/// and DoesNotExist.
operator: "In"|"NotIn"|"Exists"|"DoesNotExist"

/// values is an array of string values. If the operator is In or NotIn, the values array must be
/// non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is
/// replaced during a strategic merge patch.
values: Listing<String>?
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These classes (and others like NodeSelector) are repeated several times and are (largely) identical. It would be best to pull these out into a common file so that a Selector or MatchExpression from a CiliumBGPAdvertisement can be reused for CiliumEgressGatewayPolicy and others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants