-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - Convert e2e test to Python test + unpriviliged user test case
- Loading branch information
1 parent
0feab0f
commit 6d43dc4
Showing
28 changed files
with
226 additions
and
200 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
apiVersion: v1 | ||
kind: Config | ||
clusters: | ||
- cluster: | ||
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJek1USXhNakV3TWpneE4xb1hEVE16TVRJd09URXdNamd4TjFvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTGFPCi9vY1dITXVnS1BOMEwxcjM5b1Nqa0Z3TXlSMkpQTXlmeHFpdHZaclo4TUVsNEN5ekk0emVaakp5V1RTaG1ZTTEKT08yN1BqeE11QTZSQUtMekE3QVR3Z05wSUNQYm1lL1pYNTFaaks1SWFETG83SHUwZXc4Z2ZGQW9qSWs4eG4rOApENS9kaHlBeTRlbVhUUXpSbGd1MENnZjE3ZEl3Sm9YU0dBaU9nSytYcEtUQ3p4bGNad1RvdWNGUjNYa0YyeUhjCnliaTdJV3M5RDl4V3B6WXB3Z1RXemh2SDdNcU1UdVppRU93L2lQOEJxZVhTZVhiN21NV3MyNGh5aTVYczQwS2cKUmtzRFFCWUFhUCsrRzZmOEptRVo0SGQxUTl6a01ZQThGSXp1L29ZVEdoKzZ0THRhS3FYaTRNOHc5WWM4OEZLNwp1ZWlQQlhXbitONmFUM3dWcGo4Q0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZFanE4ampuOTA3c1A1UkNXZFc0bkQ1MXAya2xNQlVHQTFVZEVRUU8KTUF5Q0NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBS1VINVVsU2UzVE1hdHQrWXZPWgpHZkcwSzZDd0hBQUlGVVhFQVdUa3Fyb0pKVjhCT3NkVEh4SGhJOFZtWlkrMEJoU3pCckZsek13NmVLNHhtR3V6CnRucFVMQnUvZXVjQXNhNWd2ZU8wWjZQamY4VER2MXhJcmdDS044RlgydWx6TEZjdEJrdXB1MXByM2g1MVd1eGEKL3NGNS9vU0dMR0VtcEZ2bGZFNFdub1FwejAyeEFGSE1QS0poRVpGQ3dndmJ6dWNUVDZPYWRuQ2RQdVMrcVRnVgo4TlVlMVgyTkE5RHFDZlllZ2VpWm5PTXlFY2o3WVpiL1BGZ09QdWtFYU1NOHh1YXZpbm9tenlLVHFKd1VJcG5iCkhBNzFKK3IyWFdBellPN1gyRkRWNnhyanlJdFVSWithcFJFREEwL29maTB5andzRjBtV01oMVJSY0tCQ1ZJUzMKWHBJPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== | ||
server: https://127.0.0.1:34211 | ||
name: kind-kind | ||
contexts: | ||
- context: | ||
cluster: kind-kind | ||
user: sdk-user | ||
name: sdk-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VlBVSklwSE5Bb0dCQUpHSgpaRFhubmFTYitZbDg0V1FkZ0FmeEd5Vkg3TTZKWll5L2VVZ3BSOUg0NXgrWjQ3SzdGU1JieFlnQ0FzOFArL3Q3CnlZTG45NUY4VjlaQnhxVjI5bW45NWZEdThIWEZTZ0Q1UEU4QjFhaFFTUUdYcDZvNGdZeWc1OHRHRC93WVZ3ZlYKdk5jMElwRkdlZEpOY091aWphSnFwWGxsUVptUnVINnVwQjRGMGt5dEFvR0JBTzh5ZVVOVmhQNWhjandQVmNFawpYV0FSS3ErNnhBM3d3R0ZLV25CY1JSd2xOcFNjMUkrWWo0dFZaLzN5R3VxVndCL2JqWm1UemlQOG5HK3FGL3NoCm1zTzFsN0JZVlcrMDFpQ1k5c0M1S3FBR0lyTG5yUkd6LzdSZUhvWDdIVFVTM29PQW9YSmtkSWZPRkJVNVdDVGkKMzg3dHFTTDBjQkN6bHlEU2dGZUJFZWVyCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K |
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 |
---|---|---|
@@ -1,17 +1,9 @@ | ||
#!/bin/bash | ||
|
||
cd .. | ||
# !/bin/bash | ||
|
||
# Install Poetry and configure virtualenvs | ||
pip install poetry | ||
poetry config virtualenvs.create false | ||
|
||
cd codeflare-sdk | ||
|
||
# Lock dependencies and install them | ||
poetry lock --no-update | ||
poetry install --with test,docs | ||
|
||
# Return to the workdir | ||
cd .. | ||
cd workdir |
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,133 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2022 IBM, Red Hat | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -euo pipefail | ||
: "${INGRESS_NGINX_VERSION:=controller-v1.6.4}" | ||
|
||
echo "Creating KinD cluster" | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
image: kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1 | ||
kubeadmConfigPatches: | ||
- | | ||
kind: InitConfiguration | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
node-labels: "ingress-ready=true" | ||
EOF | ||
|
||
echo "Deploying Ingress controller into KinD cluster" | ||
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/"${INGRESS_NGINX_VERSION}"/deploy/static/provider/kind/deploy.yaml | sed "s/--publish-status-address=localhost/--report-node-internal-ip-address\\n - --status-update-interval=10/g" | kubectl apply -f - | ||
kubectl annotate ingressclass nginx "ingressclass.kubernetes.io/is-default-class=true" | ||
kubectl -n ingress-nginx wait --timeout=300s --for=condition=Available deployments --all | ||
|
||
## Create a user with limited permissions to test the SDK | ||
# Create a CA and a user certificate and key | ||
docker cp kind-control-plane:/etc/kubernetes/pki/ca.crt . | ||
docker cp kind-control-plane:/etc/kubernetes/pki/ca.key . | ||
openssl genrsa -out sdk-user.key 2048 | ||
openssl req -new -key sdk-user.key -out sdk-user.csr -subj /CN=sdk-user/O=tenant1 | ||
openssl x509 -req -in sdk-user.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out sdk-user.crt -days 360 | ||
base64 -w 0 < ca.crt > ca.crt.base64 | ||
base64 -w 0 < sdk-user.crt > sdk-user.crt.base64 | ||
base64 -w 0 < sdk-user.key > sdk-user.key.base64 | ||
SERVER_ADDRESS=$(kubectl cluster-info | grep -o "https://127.0.0.1:[0-9]*" | head -n 1) | ||
|
||
# Replace the placeholders in the user config file with the actual values | ||
sed -i 's|certificate-authority-data:.*|certificate-authority-data: '$(cat ca.crt.base64)'|g' ./tests/e2e/config | ||
sed -i 's|client-certificate-data:.*|client-certificate-data: '$(cat sdk-user.crt.base64)'|g' ./tests/e2e/config | ||
sed -i 's|client-key-data:.*|client-key-data: '$(cat sdk-user.key.base64)'|g' ./tests/e2e/config | ||
sed -i 's|server:.*|server: '$(echo $SERVER_ADDRESS)'|g' ./tests/e2e/config | ||
|
||
# Apply to the user limited RBAC permissions | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: tenant-user | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["namespaces"] | ||
verbs: ["get", "watch", "list"] | ||
- apiGroups: ["mcadv1beta1.groupname"] | ||
resources: ["appwrappers"] | ||
verbs: ["get", "create", "delete", "list", "patch", "update"] | ||
- apiGroups: ["rayv1.groupversion.group"] | ||
resources: ["rayclusters", "rayclusters/status"] | ||
verbs: ["get", "list"] | ||
- apiGroups: ["route.openshift.io"] | ||
resources: ["routes"] | ||
verbs: ["get", "list"] | ||
- apiGroups: ["networking.k8s.io"] | ||
resources: ["ingresses"] | ||
verbs: ["get", "list"] | ||
EOF | ||
|
||
cat <<EOF | kubectl apply -f - | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: tenant-user | ||
subjects: | ||
- kind: User | ||
name: sdk-user | ||
apiGroup: rbac.authorization.k8s.io | ||
roleRef: | ||
kind: Role | ||
name: tenant-user | ||
apiGroup: rbac.authorization.k8s.io | ||
EOF | ||
|
||
# Temporary ClusterRoles | ||
cat <<EOF | kubectl apply -f - | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: cr-tenant-user | ||
rules: | ||
- apiGroups: ["config.openshift.io"] | ||
resources: ["ingresses"] | ||
verbs: ["get", "list"] | ||
resourceNames: ["cluster"] | ||
EOF | ||
|
||
cat <<EOF | kubectl apply -f - | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: cr-tenant-user | ||
subjects: | ||
- kind: User | ||
name: sdk-user | ||
apiGroup: rbac.authorization.k8s.io | ||
roleRef: | ||
kind: ClusterRole | ||
name: cr-tenant-user | ||
apiGroup: rbac.authorization.k8s.io | ||
EOF | ||
|
||
# Cleanup csr/crt/keys from local machine | ||
rm -f ca.crt.base64 sdk-user.crt.base64 sdk-user.key.base64 ca.crt sdk-user.crt sdk-user.key sdk-user.csr ca.key ca.srl kind.csr | ||
|
||
# Install CodeFlare SDK | ||
chmod +x ./tests/e2e/install-codeflare-sdk.sh | ||
./tests/e2e/install-codeflare-sdk.sh | ||
|
||
# Confirming the user can access the cluster | ||
kubectl get ns default --as sdk-user |
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.