Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle cloud.google.com/gke-dpv2-unified-cni node label #402

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scripts/install-cni.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ if [[ "${MIGRATE_TO_DPV2:-}" == "true" ]]; then
fi

if [[ "${ENABLE_CILIUM_PLUGIN}" == "true" ]]; then
dpv2_unified_cni=$(jq -r '.metadata.labels."cloud.google.com/gke-dpv2-unified-cni"' <<<"${node_object}")
log "Using Cilium plug-in; unified mode: '${dpv2_unified_cni}' (no action needed here if true)"
if [[ "${dpv2_unified_cni}" = "true" ]]; then
success
fi
cilium_cni_config='{"type": "cilium-cni", "enable-route-mtu": true}'
if [[ -n "${CILIUM_FAST_START_NAMESPACES:-}" ]]; then
cilium_cni_config=$(jq --arg namespaces "${CILIUM_FAST_START_NAMESPACES:-}" '.["dpv2-fast-start-namespaces"] = $namespaces' <<<"${cilium_cni_config}")
Expand Down
1 change: 1 addition & 0 deletions scripts/testcase/testcase-basic-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function before_test() {
echo '{"object":{
"metadata": {
"labels": {
"cloud.google.com/gke-dpv2-unified-cni": "true"
},
"creationTimestamp": "2024-01-03T11:54:01Z",
"name": "gke-my-cluster-default-pool-128bc25d-9c94",
Expand Down
1 change: 1 addition & 0 deletions scripts/testcase/testcase-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function before_test() {
echo '{"object":{
"metadata": {
"labels": {
"cloud.google.com/gke-dpv2-unified-cni": "true"
},
"creationTimestamp": "2024-01-03T11:54:01Z",
"name": "gke-my-cluster-default-pool-128bc25d-9c94",
Expand Down
1 change: 1 addition & 0 deletions scripts/testcase/testcase-calico-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function before_test() {
echo '{"object":{
"metadata": {
"labels": {
"cloud.google.com/gke-dpv2-unified-cni": "true"
},
"creationTimestamp": "2024-01-03T11:54:01Z",
"name": "gke-my-cluster-default-pool-128bc25d-9c94",
Expand Down
1 change: 1 addition & 0 deletions scripts/testcase/testcase-calico.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function before_test() {
echo '{"object":{
"metadata": {
"labels": {
"cloud.google.com/gke-dpv2-unified-cni": "true"
},
"creationTimestamp": "2024-01-03T11:54:01Z",
"name": "gke-my-cluster-default-pool-128bc25d-9c94",
Expand Down
67 changes: 67 additions & 0 deletions scripts/testcase/testcase-cilium-skip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
export KUBERNETES_SERVICE_HOST=kubernetes.default.svc
export KUBERNETES_SERVICE_PORT=443

export ENABLE_CALICO_NETWORK_POLICY=false
export ENABLE_CILIUM_PLUGIN=true
export CILIUM_HEALTHZ_PORT=63197
export CILIUM_FAST_START_NAMESPACES=
export ENABLE_MASQUERADE=false
export ENABLE_IPV6=false

CNI_SPEC_TEMPLATE=$(cat testdata/spec-template.json)
export CNI_SPEC_TEMPLATE

function before_test() {

# shellcheck disable=SC2329
function curl() {
# shellcheck disable=SC2317
case "$*" in
*http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0*)
echo '{"ipv6s": ["2600:1900:4000:318:0:7:0:0"]}'
;;
*https://kubernetes.default.svc:443/api/v1/nodes*)
echo '{"object":{
"metadata": {
"labels": {
"cloud.google.com/gke-dpv2-unified-cni": "true"
},
"creationTimestamp": "2024-01-03T11:54:01Z",
"name": "gke-my-cluster-default-pool-128bc25d-9c94",
"resourceVersion": "891003",
"uid": "f2353a2f-ca8c-4ca0-8dd3-ad1f964a54f0"
},
"spec": {
"podCIDR": "10.52.1.0/24",
"podCIDRs": [
"10.52.1.0/24"
],
"providerID": "gce://my-gke-project/us-central1-c/gke-my-cluster-default-pool-128bc25d-9c94"
}
}}'
;;
*http://localhost:63197/*)
echo 'healthz'
;;
*)
#unsupported
exit 1
esac
}
export -f curl

rm -f "/host/etc/cni/net.d/${CNI_SPEC_NAME}"

}

function verify() {
local actual

if [[ -f "/host/etc/cni/net.d/${CNI_SPEC_NAME}" ]]; then
actual=$(jq -S . <"/host/etc/cni/net.d/${CNI_SPEC_NAME}")
echo "Expected CNI config to be missing, but it has:"
echo "$actual"
return 1
fi

}
Loading