forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore Kubernetes Integration tests (gravitational#25624)
* Restore Kubernetes Integration tests This PR re-enables the Kubernetes integrations tests using a KinD (Kubernetes in Docker) cluster. New steps have been introduced to GitHub's Integrations (Non-Root) Action that configure the KinD cluster using [`helm/kind-action`](https://github.com/helm/kind-action) and do some network configurations allowing the container where tests run to connect to the KinD control plane. This PR also fixes some of the tests and fixes a bug that affected joining operations when the target service was a legacy kubernetes proxy. Some improvements will be introduced in future patches to improve the logic and reduce the time required for the tests to run. Fixes gravitational#25539 * fix data race in spdystream dep * address feedback * remove docker installation * fix test
- Loading branch information
Showing
9 changed files
with
265 additions
and
32 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
.github/workflows/kube-integration-tests-non-root-bypass.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This workflow is required to ensure that required Github check passes even if | ||
# the actual "Kube Integration Tests (Non-root)" workflow skipped due to path filtering. | ||
# Otherwise it will stay forever pending. | ||
# | ||
# See "Handling skipped but required checks" for more info: | ||
# | ||
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks | ||
# | ||
# Note both workflows must have the same name. | ||
|
||
name: Kube Integration Tests (Non-root) | ||
run-name: Skip Kube Integration Tests (Non-root) - ${{ github.run_id }} - @${{ github.actor }} | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- '.github/workflows/kube-integration-tests-non-root.yaml' | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- 'build.assets/Makefile' | ||
- 'build.assets/Dockerfile*' | ||
- 'Makefile' | ||
merge_group: | ||
paths-ignore: | ||
- '.github/workflows/kube-integration-tests-non-root.yaml' | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- 'build.assets/Makefile' | ||
- 'build.assets/Dockerfile*' | ||
- 'Makefile' | ||
|
||
jobs: | ||
test: | ||
name: Kube Integration Tests (Non-root) | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: none | ||
|
||
steps: | ||
- run: 'echo "No changes to verify"' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Kube Integration Tests (Non-root) | ||
run-name: Kube Integration Tests (Non-root) - ${{ github.run_id }} - @${{ github.actor }} | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- branch/* | ||
pull_request: | ||
paths: | ||
- '.github/workflows/kube-integration-tests-non-root.yaml' | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- 'build.assets/Makefile' | ||
- 'build.assets/Dockerfile*' | ||
- 'Makefile' | ||
merge_group: | ||
paths: | ||
- '.github/workflows/kube-integration-tests-non-root.yaml' | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- 'build.assets/Makefile' | ||
- 'build.assets/Dockerfile*' | ||
- 'Makefile' | ||
|
||
env: | ||
TEST_KUBE: true | ||
KUBECONFIG: /home/.kube/config | ||
|
||
jobs: | ||
test: | ||
name: Kube Integration Tests (Non-root) | ||
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | ||
runs-on: ubuntu-22.04-16core | ||
|
||
permissions: | ||
contents: read | ||
packages: read | ||
|
||
container: | ||
image: ghcr.io/gravitational/teleport-buildbox:teleport13 | ||
env: | ||
WEBASSETS_SKIP_BUILD: 1 | ||
options: --cap-add=SYS_ADMIN --privileged | ||
|
||
steps: | ||
- name: Checkout Teleport | ||
uses: actions/checkout@v3 | ||
|
||
- name: Prepare workspace | ||
uses: ./.github/actions/prepare-workspace | ||
|
||
- name: Chown | ||
run: | | ||
mkdir -p $(go env GOMODCACHE) | ||
mkdir -p $(go env GOCACHE) | ||
chown -Rf ci:ci ${GITHUB_WORKSPACE} $(go env GOMODCACHE) $(go env GOCACHE) | ||
continue-on-error: true | ||
|
||
- name: Create KinD cluster | ||
uses: helm/[email protected] | ||
with: | ||
cluster_name: kind | ||
config: fixtures/kind/config.yaml | ||
|
||
# The current container where tests run isn't linked to the KinD network and | ||
# we won't be able to access the KinD control plane without linking them. | ||
# This step is required because our tests run in teleport-buildbox container | ||
# and by default the KinD container network isn't exposed to it. | ||
# Connecting the network allow us to access the control plane using DNS kind-control-plane. | ||
# It also copies the default kubeconfig and places it in /home/.kube so ci user | ||
# is able to access it. | ||
- name: Link test container to KinD network | ||
run: | | ||
docker network connect kind $(cat /etc/hostname) | ||
kubectl config set-cluster kind-kind --server=https://kind-control-plane:6443 | ||
kubectl cluster-info | ||
kubectl apply -f fixtures/ci-teleport-rbac/ci-teleport.yaml | ||
cp -r $HOME/.kube /home/ | ||
chown -R ci:ci /home/.kube | ||
- name: Run tests | ||
timeout-minutes: 40 | ||
run: | | ||
runuser -u ci -g ci make rdpclient integration-kube |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
networking: | ||
apiServerAddress: '127.0.0.1' | ||
apiServerPort: 6443 | ||
|
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
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
Oops, something went wrong.