Conformance IPsec E2E (ci-ipsec-e2e) #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Conformance IPsec E2E (ci-ipsec-e2e) | |
# Any change in triggers needs to be reflected in the concurrency group. | |
on: | |
workflow_dispatch: | |
inputs: | |
PR-number: | |
description: "Pull request number." | |
required: true | |
context-ref: | |
description: "Context in which the workflow runs. If PR is from a fork, will be the PR target branch (general case). If PR is NOT from a fork, will be the PR branch itself (this allows committers to test changes to workflows directly from PRs)." | |
required: true | |
SHA: | |
description: "SHA under test (head of the PR branch)." | |
required: true | |
extra-args: | |
description: "[JSON object] Arbitrary arguments passed from the trigger comment via regex capture group. Parse with 'fromJson(inputs.extra-args).argName' in workflow." | |
required: false | |
default: '{}' | |
# Run every 6 hours | |
schedule: | |
- cron: '0 5/6 * * *' | |
# By specifying the access of one of the scopes, all of those that are not | |
# specified are set to 'none'. | |
permissions: | |
# To be able to access the repository with actions/checkout | |
contents: read | |
# To allow retrieving information from the PR API | |
pull-requests: read | |
# To be able to set commit status | |
statuses: write | |
concurrency: | |
# Structure: | |
# - Workflow name | |
# - Event type | |
# - A unique identifier depending on event type: | |
# - schedule: SHA | |
# - workflow_dispatch: PR number | |
# | |
# This structure ensures a unique concurrency group name is generated for each | |
# type of testing, such that re-runs will cancel the previous run. | |
group: | | |
${{ github.workflow }} | |
${{ github.event_name }} | |
${{ | |
(github.event_name == 'schedule' && github.sha) || | |
(github.event_name == 'workflow_dispatch' && github.event.inputs.PR-number) | |
}} | |
cancel-in-progress: true | |
env: | |
cilium_cli_ci_version: | |
check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
jobs: | |
commit-status-start: | |
name: Commit Status Start | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set initial commit status | |
uses: myrotvorets/set-commit-status-action@38f3f27c7d52fb381273e95542f07f0fba301307 # v2.0.0 | |
with: | |
sha: ${{ inputs.SHA || github.sha }} | |
setup-and-test: | |
name: 'Setup & Test' | |
runs-on: ubuntu-latest-4cores-16gb | |
env: | |
job_name: 'Setup & Test' | |
strategy: | |
fail-fast: false | |
max-parallel: 16 | |
matrix: | |
include: | |
# See https://github.com/cilium/cilium/issues/20606 for configuration table | |
- name: '1' | |
# renovate: datasource=docker depName=quay.io/lvh-images/kind | |
kernel: '4.19-20231128.100518' | |
kube-proxy: 'iptables' | |
kpr: 'false' | |
tunnel: 'vxlan' | |
encryption: 'ipsec' | |
encryption-node: 'false' | |
key-one: 'gcm(aes)' | |
key-two: 'cbc(aes)' | |
- name: '2' | |
# renovate: datasource=docker depName=quay.io/lvh-images/kind | |
kernel: '5.4-20231128.100518' | |
kube-proxy: 'iptables' | |
kpr: 'false' | |
tunnel: 'disabled' | |
encryption: 'ipsec' | |
encryption-node: 'false' | |
key-one: 'cbc(aes)' | |
key-two: 'cbc(aes)' | |
- name: '3' | |
# renovate: datasource=docker depName=quay.io/lvh-images/kind | |
kernel: '5.10-20231128.100518' | |
kube-proxy: 'iptables' | |
kpr: 'false' | |
tunnel: 'disabled' | |
encryption: 'ipsec' | |
encryption-node: 'false' | |
endpoint-routes: 'true' | |
key-one: 'gcm(aes)' | |
key-two: 'gcm(aes)' | |
- name: '4' | |
# renovate: datasource=docker depName=quay.io/lvh-images/kind | |
kernel: 'bpf-next-20231211.012942' | |
kube-proxy: 'iptables' | |
kpr: 'false' | |
tunnel: 'geneve' | |
encryption: 'ipsec' | |
encryption-node: 'false' | |
endpoint-routes: 'true' | |
key-one: 'cbc(aes)' | |
key-two: 'gcm(aes)' | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout context ref (trusted) | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: ${{ inputs.context-ref || github.sha }} | |
persist-credentials: false | |
- name: Set Environment Variables | |
uses: ./.github/actions/set-env-variables | |
- name: Set up job variables | |
id: vars | |
run: | | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
SHA="${{ inputs.SHA }}" | |
else | |
SHA="${{ github.sha }}" | |
fi | |
echo sha=${SHA} >> $GITHUB_OUTPUT | |
- name: Derive Cilium installation config and junit type | |
id: cilium-config | |
uses: ./.github/actions/cilium-config | |
with: | |
image-tag: ${{ steps.vars.outputs.sha }} | |
chart-dir: './install/kubernetes/cilium' | |
tunnel: ${{ matrix.tunnel }} | |
devices: ${{ matrix.devices }} | |
endpoint-routes: ${{ matrix.endpoint-routes }} | |
ipv6: ${{ matrix.ipv6 }} | |
kpr: ${{ matrix.kpr }} | |
lb-mode: ${{ matrix.lb-mode }} | |
lb-acceleration: ${{ matrix.lb-acceleration }} | |
encryption: ${{ matrix.encryption }} | |
encryption-node: ${{ matrix.encryption-node }} | |
egress-gateway: ${{ matrix.egress-gateway }} | |
host-fw: ${{ matrix.host-fw }} | |
ingress-controller: ${{ matrix.ingress-controller }} | |
misc: ${{ matrix.misc }} | |
# Warning: since this is a privileged workflow, subsequent workflow job | |
# steps must take care not to execute untrusted code. | |
- name: Checkout pull request branch (NOT TRUSTED) | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
ref: ${{ steps.vars.outputs.sha }} | |
persist-credentials: false | |
- name: Install Cilium CLI-cli | |
uses: cilium/cilium-cli@c1fa8afda634f0457e9905d4f638e5164c4e0fc8 # v0.15.17 | |
with: | |
repository: ${{ env.CILIUM_CLI_RELEASE_REPO }} | |
release-version: ${{ env.CILIUM_CLI_VERSION }} | |
ci-version: ${{ env.cilium_cli_ci_version }} | |
binary-name: cilium-cli | |
binary-dir: ./ | |
- name: Set Kind params | |
id: kind-params | |
shell: bash | |
run: | | |
IP_FAM="dual" | |
if [ "${{ matrix.ipv6 }}" == "false" ]; then | |
IP_FAM="ipv4" | |
fi | |
echo params="--xdp --secondary-network \"\" 3 \"\" \"\" ${{ matrix.kube-proxy }} $IP_FAM" >> $GITHUB_OUTPUT | |
- name: Provision K8s on LVH VM | |
uses: cilium/cilium/.github/actions/lvh-kind@main | |
with: | |
test-name: e2e-conformance | |
kernel: ${{ matrix.kernel }} | |
kind-params: "${{ steps.kind-params.outputs.params }}" | |
- name: Wait for images to be available | |
timeout-minutes: 30 | |
shell: bash | |
run: | | |
for image in cilium-ci operator-generic-ci hubble-relay-ci ; do | |
until docker manifest inspect quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/$image:${{ steps.vars.outputs.sha }} &> /dev/null; do sleep 45s; done | |
done | |
- name: Run tests (${{ join(matrix.*, ', ') }}) | |
shell: bash | |
run: | | |
kubectl patch node kind-worker3 --type=json -p='[{"op":"add","path":"/metadata/labels/cilium.io~1no-schedule","value":"true"}]' | |
if [[ "${{ matrix.key-one }}" == "gcm(aes)" ]]; then | |
key="rfc4106(gcm(aes)) $(dd if=/dev/urandom count=20 bs=1 2> /dev/null | xxd -p -c 64) 128" | |
elif [[ "${{ matrix.key-one }}" == "cbc(aes)" ]]; then | |
key="hmac(sha256) $(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64) cbc(aes) $(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)" | |
else | |
echo "Invalid key type"; exit 1 | |
fi | |
kubectl create -n kube-system secret generic cilium-ipsec-keys \ | |
--from-literal=keys="3 ${key}" | |
export CILIUM_CLI_MODE=helm | |
./cilium-cli install ${{ steps.cilium-config.outputs.config }} | |
kubectl -n cilium-spire wait --for=condition=Ready pod -l app=spire-server --timeout=300s | |
kubectl -n cilium-spire wait --for=condition=Ready pod -l app=spire-agent --timeout=300s | |
./cilium-cli status --wait | |
kubectl get pods --all-namespaces -o wide | |
kubectl -n kube-system exec daemonset/cilium -- cilium-dbg status | |
mkdir -p cilium-junits | |
./cilium-cli connectivity test --include-unsafe-tests --collect-sysdump-on-failure \ | |
--sysdump-hubble-flows-count=1000000 --sysdump-hubble-flows-timeout=5m \ | |
--sysdump-output-filename "cilium-sysdump-${{ matrix.name }}-<ts>" \ | |
--junit-file "cilium-junits/${{ env.job_name }} (${{ join(matrix.*, ', ') }}).xml" \ | |
--junit-property github_job_step="Run tests (${{ join(matrix.*, ', ') }})" \ | |
--flush-ct | |
- name: Rotate IPsec Key & Test (${{ join(matrix.*, ', ') }}) | |
uses: cilium/cilium/.github/actions/conn-disrupt-test@main | |
with: | |
job-name: conformance-ipsec-e2e-key-rotation-${{ matrix.name }} | |
operation-cmd: | | |
KEYID=$(kubectl get secret -n kube-system cilium-ipsec-keys -o go-template --template={{.data.keys}} | base64 -d | cut -c 1) | |
if [[ $KEYID -ge 15 ]]; then KEYID=0; fi | |
if [[ "${{ matrix.key-two }}" == "gcm(aes)" ]]; then | |
key="rfc4106(gcm(aes)) $(dd if=/dev/urandom count=20 bs=1 2> /dev/null | xxd -p -c 64) 128" | |
elif [[ "${{ matrix.key-two }}" == "cbc(aes)" ]]; then | |
key="hmac(sha256) $(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64) cbc(aes) $(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)" | |
else | |
echo "Invalid key type"; exit 1 | |
fi | |
data="{\"stringData\":{\"keys\":\"$((($KEYID+1))) ${key}\"}}" | |
kubectl patch secret -n kube-system cilium-ipsec-keys -p="$data" -v=1 | |
# Wait until key rotation starts | |
while true; do | |
keys_in_use=$(kubectl -n kube-system exec daemonset/cilium -- cilium-dbg encrypt status | awk '/Keys in use/ {print $NF}') | |
if [[ $keys_in_use == 2 ]]; then | |
break | |
fi | |
echo "Waiting until key rotation starts (seeing $keys_in_use keys)" | |
sleep 30s | |
done | |
# Wait until key rotation completes | |
# By default the key rotation cleanup delay is 5min, let's sleep 4min before actively polling | |
sleep $((4*60)) | |
while true; do | |
keys_in_use=$(kubectl -n kube-system exec daemonset/cilium -- cilium-dbg encrypt status | awk '/Keys in use/ {print $NF}') | |
if [[ $keys_in_use == 1 ]]; then | |
break | |
fi | |
echo "Waiting until key rotation completes (seeing $keys_in_use keys)" | |
sleep 30s | |
done | |
- name: Fetch artifacts | |
if: ${{ !success() }} | |
shell: bash | |
run: | | |
kubectl get pods --all-namespaces -o wide | |
./cilium-cli status | |
mkdir -p cilium-sysdumps | |
./cilium-cli sysdump --output-filename cilium-sysdump-${{ matrix.name }}-final | |
- name: Upload artifacts | |
if: ${{ !success() }} | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | |
with: | |
name: cilium-sysdumps | |
path: cilium-sysdump-*.zip | |
retention-days: 5 | |
- name: Upload JUnits [junit] | |
if: ${{ always() }} | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | |
with: | |
name: cilium-junits | |
path: cilium-junits/*.xml | |
retention-days: 2 | |
- name: Publish Test Results As GitHub Summary | |
if: ${{ always() }} | |
uses: aanm/junit2md@332ebf0fddd34e91b03a832cfafaa826306558f9 # v0.0.3 | |
with: | |
junit-directory: "cilium-junits" | |
commit-status-final: | |
if: ${{ always() }} | |
name: Commit Status Final | |
needs: setup-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set final commit status | |
uses: myrotvorets/set-commit-status-action@38f3f27c7d52fb381273e95542f07f0fba301307 # v2.0.0 | |
with: | |
sha: ${{ inputs.SHA || github.sha }} | |
status: ${{ needs.setup-and-test.result }} |