Skip to content

Commit

Permalink
CI: only install gateway CRDs if k8s version >= 1.23 (#3420)
Browse files Browse the repository at this point in the history
* CI: only install gateway CRDs if k8s version >= 1.23

Follow-up of XXX

The gateway CRDs installed use `x-kubernetes-validations` which is only
[available as of 1.23](https://kubernetes
.io/docs/reference/generated/kubernetes-api/v1.23/#jsonschemaprops-v1-apiextensions-k8s-io).

This breaks CI when the kubectl version is lower than 1.23. We use these
 CI actions for grafana/mimir-distributed [with 1.20 for example]
 (https://github.com/grafana/mimir/blob/a7f1e3f79fe0a72f64d2f60c6ce65afa03e2dd8c/.github/workflows/helm-ci.yml#L11-L18)

Signed-off-by: Dimitar Dimitrov <[email protected]>

* Update .github/workflows/lint-test.yaml

Signed-off-by: Dimitar Dimitrov <[email protected]>

---------

Signed-off-by: Dimitar Dimitrov <[email protected]>
  • Loading branch information
dimitarvdimitrov authored Nov 11, 2024
1 parent d04c572 commit dda0112
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,22 @@ jobs:
kubectl_version: ${{ inputs.kind_kubectl_version }}
node_image: ${{ inputs.kind_node_image }}

- name: Apply Gateway API CRDs
- name: Check Kubernetes version and apply Gateway API CRDs
if: steps.list-changed.outputs.changed == 'true'
run: kubectl apply -k https://github.com/kubernetes-sigs/gateway-api/config/crd
run: |
# Get Kubernetes version and extract the major.minor version
version=$(kubectl version -o json | jq -r '.serverVersion.major + "." + .serverVersion.minor' | tr -d '+')
major_version=$(echo $version | cut -d. -f1)
minor_version=$(echo $version | cut -d. -f2)
# Compare version with 1.23. The gateway CRDs use x-kubernetes-validations, which is only supported from 1.23 onwards.
if [ "$major_version" -eq 1 ] && [ "$minor_version" -ge 23 ] || [ "$major_version" -gt 1 ]; then
echo "Kubernetes version $version >= 1.23, applying Gateway API CRDs"
kubectl apply -k https://github.com/kubernetes-sigs/gateway-api/config/crd
else
echo "Kubernetes version $version < 1.23, skipping Gateway API CRDs installation"
echo "Please use an older version of Gateway API CRDs or upgrade your Kubernetes version"
fi
- name: Run chart-testing (install)
run: |
Expand Down

0 comments on commit dda0112

Please sign in to comment.