cilium

Форк
0
/
tests-smoke.yaml 
205 строк · 7.9 Кб
1
name: Smoke Test
2

3
# Any change in triggers needs to be reflected in the concurrency group.
4
on:
5
  pull_request: {}
6
  push:
7
    branches:
8
      - main
9
      - ft/main/**
10
  merge_group:
11
    types: [checks_requested]
12

13
permissions: read-all
14

15
concurrency:
16
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after || github.event.merge_group && github.run_id }}
17
  cancel-in-progress: ${{ !github.event.merge_group }}
18

19
env:
20
  cilium_cli_ci_version:
21
  CILIUM_CLI_MODE: helm
22
  # renovate: datasource=github-releases depName=kubernetes-sigs/kind
23
  KIND_VERSION: v0.22.0
24
  KIND_CONFIG: .github/kind-config.yaml
25
  CONFORMANCE_TEMPLATE: examples/kubernetes/connectivity-check/connectivity-check.yaml
26
  TIMEOUT: 2m
27
  LOG_TIME: 30m
28
  PROM_VERSION: 2.34.0
29

30
jobs:
31
  check_changes:
32
    name: Deduce required tests from code changes
33
    runs-on: ubuntu-22.04
34
    outputs:
35
      tested: ${{ steps.tested-tree.outputs.src }}
36
    steps:
37
      - name: Checkout code
38
        if: ${{ !github.event.pull_request }}
39
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
40
        with:
41
          persist-credentials: false
42
      - name: Check code changes
43
        uses: dorny/paths-filter@ebc4d7e9ebcb0b1eb21480bb8f43113e996ac77a # v3.0.1
44
        id: tested-tree
45
        with:
46
          # For `push` events, compare against the `ref` base branch
47
          # For `pull_request` events, this is ignored and will compare against the pull request base branch
48
          base: ${{ github.ref }}
49
          filters: |
50
            src:
51
              - '!(test|Documentation)/**'
52

53
  preflight-clusterrole:
54
    runs-on: ubuntu-latest
55
    name: Preflight Clusterrole Check
56
    steps:
57
      - name: Checkout code
58
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
59
        with:
60
          persist-credentials: false
61

62
      - name: Check pre-flight clusterrole
63
        run: make check-k8s-clusterrole
64

65
  helm-charts:
66
    runs-on: ubuntu-latest
67
    name: Helm Charts Check
68
    steps:
69
      - name: Checkout
70
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
71
        with:
72
          persist-credentials: false
73

74
      - name: Run helm-charts
75
        run: |
76
          make -C install/kubernetes
77
          test -z "$(git status --porcelain)" || (echo "please run 'make -C install/kubernetes' and submit your changes"; exit 1)
78

79
  conformance-test:
80
    needs: check_changes
81
    if: ${{ needs.check_changes.outputs.tested == 'true' && github.event_name != 'merge_group' }}
82
    runs-on: ubuntu-latest
83
    name: Installation and Conformance Test
84
    steps:
85
      - name: Checkout main branch to access local actions
86
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
87
        with:
88
          ref: ${{ github.event.repository.default_branch }}
89
          persist-credentials: false
90
      - name: Set Environment Variables
91
        uses: ./.github/actions/set-env-variables
92

93
      - name: Checkout
94
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
95
        with:
96
          persist-credentials: false
97

98
      - name: Get Cilium's default values
99
        id: default_vars
100
        uses: ./.github/actions/helm-default
101
        with:
102
          image-tag: ${{ github.event.pull_request.head.sha }}
103

104
      - name: Set image tag
105
        id: sha
106
        run: |
107
          echo sha=${{ steps.default_vars.outputs.sha }} >> $GITHUB_OUTPUT
108

109
      - name: Precheck generated connectivity manifest files
110
        run: |
111
          make -C examples/kubernetes/connectivity-check fmt
112
          make -C examples/kubernetes/connectivity-check all
113
          test -z "$(git status --porcelain)" || (echo "please run 'make -C examples/kubernetes/connectivity-check fmt all' and submit your changes"; exit 1)
114

115
      - name: Create kind cluster
116
        uses: helm/kind-action@99576bfa6ddf9a8e612d83b513da5a75875caced # v1.9.0
117
        with:
118
          version: ${{ env.KIND_VERSION }}
119
          config: ${{ env.KIND_CONFIG }}
120

121
      - name: Wait for images to be available
122
        timeout-minutes: 30
123
        shell: bash
124
        run: |
125
          for image in cilium-ci operator-generic-ci hubble-relay-ci ; do
126
            until docker manifest inspect quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/$image:${{ steps.sha.outputs.sha }} &> /dev/null; do sleep 45s; done
127
          done
128

129
      - name: Set up install variables
130
        id: vars
131
        run: |
132
          CILIUM_INSTALL_DEFAULTS="${{ steps.default_vars.outputs.cilium_install_defaults }} \
133
             --helm-set nodeinit.enabled=true \
134
             --helm-set kubeProxyReplacement=true \
135
             --helm-set ipam.mode=kubernetes \
136
             --helm-set hubble.relay.enabled=true \
137
             --helm-set prometheus.enabled=true \
138
             --helm-set operator.prometheus.enabled=true \
139
             --helm-set hubble.enabled=true \
140
             --helm-set=hubble.metrics.enabled=\"{dns,drop,tcp,flow,port-distribution,icmp,http}\" \
141
             --helm-set ingressController.enabled=true"
142

143
          echo cilium_install_defaults=${CILIUM_INSTALL_DEFAULTS} >> $GITHUB_OUTPUT
144

145
      - name: Install Cilium CLI
146
        uses: cilium/cilium-cli@7306e3cdc6caee738157f08e3e1ba26179f104e5 # v0.15.23
147
        with:
148
          repository: ${{ env.CILIUM_CLI_RELEASE_REPO }}
149
          release-version: ${{ env.CILIUM_CLI_VERSION }}
150
          ci-version: ${{ env.cilium_cli_ci_version }}
151

152
      - name: Install Cilium
153
        id: install-cilium
154
        run: |
155
          cilium install ${{ steps.vars.outputs.cilium_install_defaults }}
156

157
      - name: Wait for Cilium status to be ready
158
        run: |
159
          cilium status --wait
160
          kubectl -n kube-system get pods
161

162
      - name: Port forward Relay
163
        run: |
164
          cilium hubble port-forward&
165
          sleep 10s
166
          [[ $(pgrep -f "cilium.*hubble.*port-forward|kubectl.*port-forward.*hubble-relay" | wc -l) == 2 ]]
167

168
      - name: Run conformance test (e.g. connectivity check)
169
        run: |
170
          kubectl apply -f ${{ env.CONFORMANCE_TEMPLATE }}
171
          kubectl wait --for=condition=Available --all deployment --timeout=${{ env.TIMEOUT }}
172

173
      - name: Check prometheus metrics
174
        if: ${{ success() }}
175
        run: |
176
          cd $HOME
177
          cilium_pod=$(kubectl -n kube-system get po -o name --field-selector=status.phase==Running -l 'k8s-app=cilium' -o jsonpath='{.items[0].metadata.name}' )
178
          kubectl -n kube-system exec $cilium_pod -- sh -c "apt update && apt install curl -y"
179
          kubectl -n kube-system exec $cilium_pod -- curl http://localhost:9962/metrics > metrics.prom
180
          # Install promtool binary release. `go install` doesn't work due to
181
          # https://github.com/prometheus/prometheus/issues/8852 and related issues.
182
          curl -sSL --remote-name-all https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/{prometheus-${PROM_VERSION}.linux-amd64.tar.gz,sha256sums.txt}
183
          sha256sum --check --ignore-missing sha256sums.txt
184
          tar xzvf prometheus-${PROM_VERSION}.linux-amd64.tar.gz prometheus-${PROM_VERSION}.linux-amd64/promtool
185
          rm -f prometheus-${PROM_VERSION}.linux-amd64.tar.gz
186
          sudo mv prometheus-${PROM_VERSION}.linux-amd64/promtool /usr/bin
187
          cat metrics.prom | promtool check metrics
188

189
      - name: Report cluster failure status and capture cilium-sysdump
190
        if: ${{ failure() && steps.install-cilium.outcome != 'skipped' }}
191
        # The following is needed to prevent hubble from receiving an empty
192
        # file (EOF) on stdin and displaying no flows.
193
        shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
194
        run: |
195
          echo "=== Retrieve cluster state ==="
196
          kubectl get pods --all-namespaces -o wide
197
          cilium status
198
          cilium sysdump --output-filename cilium-sysdump-out
199

200
      - name: Upload cilium-sysdump
201
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
202
        if: ${{ failure() }}
203
        with:
204
          name: cilium-sysdump-out.zip
205
          path: cilium-sysdump-out.zip
206

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.