refactor(suites): simplify kubernetes suite (#1680)

This PR achieves the following goals:
* Utilise upstream version of kind instead of a patched version which allows binding to networks other than the default "kind"
* Utilises the registry cache which is setup one level above the kind cluster

The former point was required to successfully run our integration tests in a Kubernetes environment, however this is now possible without running a patched version of kind.

The second point is because DockerHub has introduced rate limiting for container downloads. If there are a large number of CI jobs nodes may occasionally be rejected due to the Kubernetes suite not pulling down from the registry cache.
This commit is contained in:
Amir Zarrinkafsh 2021-02-02 09:53:44 +11:00 committed by GitHub
parent 968fffb7fe
commit d17c7e7fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -3,8 +3,8 @@ FROM alpine:3.13.1
WORKDIR /kind
RUN apk add --no-cache bash curl docker && \
curl -Lo kind https://github.com/clems4ever/kind/releases/download/docker-network/kind && chmod +x kind && \
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kubectl && chmod +x kubectl
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.10.0/kind-linux-amd64 && chmod +x kind && \
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.20.2/bin/linux/amd64/kubectl && chmod +x kubectl
ADD entrypoint.sh entrypoint.sh
ADD patch-kubeconfig.sh patch-kubeconfig.sh

View File

@ -1,4 +1,6 @@
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
networking:
dockerNetwork: authelia_authelianet
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."registrycache.internal:5000"]
endpoint = ["http://registrycache.internal:5000"]

View File

@ -9,6 +9,8 @@ services:
- './example/kube:/authelia'
- './example/compose/kind/config.yml:/etc/kind/config.yml'
command: 'kubectl port-forward --address 0.0.0.0 -n authelia service/nginx-ingress-controller-service 8080:443'
environment:
- KIND_EXPERIMENTAL_DOCKER_NETWORK=authelia_authelianet
networks:
authelianet:
aliases:
@ -28,6 +30,8 @@ services:
- 'kind-volume:/kind/config'
- './example/compose/kind/entrypoint-dashboard.sh:/entrypoint-dashboard.sh'
command: '/entrypoint-dashboard.sh'
environment:
- KIND_EXPERIMENTAL_DOCKER_NETWORK=authelia_authelianet
networks:
authelianet:
aliases:

View File

@ -3,5 +3,4 @@
# This script patches the kubeconfig generated by Kind in order to access the cluster container via this container
echo "Patching Kubeconfig to target Kube container without link"
CONTROL_PLANE_IP=`docker inspect -f '{{(index .NetworkSettings.Networks "authelia_authelianet").IPAddress}}' kind-control-plane`
sed -i "s/127.0.0.1:.*/$CONTROL_PLANE_IP:6443/" `kind get kubeconfig-path --name="kind"`
sed -i "s/127.0.0.1:.*/$(docker inspect -f '{{(index .NetworkSettings.Networks "authelia_authelianet").IPAddress}}' kind-control-plane):6443/" ${KUBECONFIG}