-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
E2E: Use Helm instead of Docker #10897
Draft
richard-cox
wants to merge
9
commits into
rancher:master
Choose a base branch
from
richard-cox:e2e-k3s
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
597c9be
WIP
richard-cox 1d14f9b
WIP2
richard-cox 6ade845
WIP4
richard-cox a952821
WIP5
richard-cox db96dab
WIP6
richard-cox 55ca056
Tidying up
richard-cox 5c9a4a1
Fix min length arg
richard-cox 5c881bc
Tidying up
richard-cox e059202
Merge remote-tracking branch 'upstream/master' into e2e-k3s
richard-cox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,119 @@ | ||
#!/usr/bin/env bash | ||
|
||
K3S_VERSION=v1.28.8+k3s1 | ||
|
||
# Image version | ||
# RANCHER_IMG_VERSION=v2.9-c9be13b09329bbee60a5f6419d500198f83c44d1-head | ||
RANCHER_IMG_VERSION=v2.9-head | ||
DASHBOARD_URL="${TEST_BASE_URL#https://}" | ||
NAMESPACE=cattle-system | ||
|
||
DIR=$(cd $(dirname $0)/..; pwd) | ||
|
||
# See `script/build-e2e`. This is the ui builds we wish to test | ||
DASHBOARD_DIST=${DIR}/dist | ||
EMBER_DIST=${DIR}/dist_ember | ||
|
||
echo "Installing k3s (with kubectl).........." | ||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="$K3S_VERSION" sh - | ||
export KUBECONFIG=~/.kube/config | ||
mkdir ~/.kube 2> /dev/null | ||
sudo k3s kubectl config view --raw > "$KUBECONFIG" | ||
chmod 600 "$KUBECONFIG" | ||
|
||
echo "Installing helm.........." | ||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | ||
chmod 700 get_helm.sh | ||
./get_helm.sh | ||
|
||
echo "Installing cert-manager.........." | ||
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml | ||
helm repo add jetstack https://charts.jetstack.io | ||
helm repo update | ||
helm install cert-manager jetstack/cert-manager \ | ||
--namespace cert-manager \ | ||
--create-namespace \ | ||
--version v1.7.1 | ||
|
||
echo "Cert manager pods should be up" | ||
kubectl get pods --namespace cert-manager | ||
|
||
echo "Setting up Rancher Repo.........." | ||
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest | ||
helm repo update | ||
|
||
# TODO: RC wire in host name to e2e tests | ||
|
||
echo "Installing Rancher.........." | ||
kubectl create ns $NAMESPACE | ||
helm install rancher rancher-latest/rancher \ | ||
--namespace cattle-system \ | ||
--set hostname=$DASHBOARD_URL \ | ||
--set replicas="1" \ | ||
--set rancherImage="rancher/rancher" \ | ||
--set rancherImageTag="$RANCHER_IMG_VERSION" \ | ||
--set rancherImagePullPolicy="Always" \ | ||
--set extraEnv\[0\].name="CATTLE_AGENT_IMAGE" \ | ||
--set-string extraEnv\[0\].value="rancher/rancher:$RANCHER_IMG_VERSION" \ | ||
--set extraEnv\[1\].name="CATTLE_UI_OFFLINE_PREFERRED" \ | ||
--set-string extraEnv\[1\].value="true" \ | ||
--set extraEnv\[2\].name="CATTLE_BOOTSTRAP_PASSWORD" \ | ||
--set-string extraEnv\[2\].value="password" \ | ||
--set extraEnv\[3\].name="CATTLE_PASSWORD_MIN_LENGTH" \ | ||
--set-string extraEnv\[3\].value="3" | ||
|
||
echo "Waiting for Rancher to come up.........." | ||
kubectl -n cattle-system rollout status deploy/rancher | ||
|
||
echo "Waiting for dashboard UI to be reachable.........." | ||
|
||
okay=0 | ||
|
||
while [ $okay -lt 20 ]; do | ||
STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') | ||
|
||
echo "Status: $STATUS (Try: $okay)" | ||
|
||
okay=$((okay+1)) | ||
|
||
if [ "$STATUS" == "200" ]; then | ||
okay=100 | ||
else | ||
sleep 5 | ||
fi | ||
done | ||
|
||
if [ "$STATUS" != "200" ]; then | ||
echo "Dashboard did not become available in a reasonable time" | ||
exit 1 | ||
fi | ||
|
||
echo "Updating UI within Rancher container.........." | ||
# Note - these will pick the first container within the pod, so replicas=1 above is important | ||
POD_NAME=$(kubectl get pods --selector=app=rancher -n $NAMESPACE | tail -n 1 | cut -d ' ' -f1) | ||
echo "POD NAME: $POD_NAME" | ||
if [ "$POD_NAME" == "" ]; then | ||
echo "Failed to find rancher pod" | ||
exit 1 | ||
fi | ||
|
||
# Remove root folders that container UIs | ||
kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui-dashboard/dashboard' | ||
kubectl exec $POD_NAME -n $NAMESPACE -- sh -c 'rm -rf /usr/share/rancher/ui' | ||
|
||
# Copy local builds to root folders that should contain UIs | ||
mv $DASHBOARD_DIST dashboard | ||
mv $EMBER_DIST ui | ||
kubectl cp dashboard $POD_NAME:/usr/share/rancher/ui-dashboard -n $NAMESPACE | ||
kubectl cp ui $POD_NAME:/usr/share/rancher -n $NAMESPACE | ||
|
||
# Final validation | ||
STATUS=$(curl --silent --location --head -k $DASHBOARD_URL/dashboard/ | awk -F'HTTP/2 ' '{print $2}' | awk 'length { print $1}') | ||
echo "Status: $STATUS" | ||
|
||
if [ "$STATUS" != "200" ]; then | ||
echo "After updating dashboard with dev build it is no longer available" | ||
exit 1 | ||
fi | ||
|
||
echo "Dashboard UI is ready" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be passed in?