-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update script to create/delete cluster automatically --------- Co-authored-by: Vladislav Volodkin <[email protected]>
- Loading branch information
Showing
12 changed files
with
446 additions
and
71 deletions.
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
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 @@ | ||
csi-test-artifacts/* |
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,13 +1,52 @@ | ||
|
||
## Usage | ||
# Usage | ||
## Prerequisites | ||
AWS credentials in ENVs with the following policies attached: | ||
``` | ||
AmazonEC2FullAccess | ||
AmazonRoute53FullAccess | ||
AmazonS3FullAccess | ||
IAMFullAccess | ||
AmazonVPCFullAccess | ||
AmazonSQSFullAccess | ||
AmazonEventBridgeFullAccess | ||
AmazonSSMReadOnlyAccess | ||
``` | ||
|
||
## Setting up the environment | ||
All of the following commands are expected to be executed from repo root: | ||
|
||
```bash | ||
ACTION=install_tools tests/e2e-kubernetes/run.sh | ||
|
||
ACTION=create_cluster AWS_REGION=us-east-1 CLUSTER_TYPE=kops tests/e2e-kubernetes/run.sh # set KOPS_STATE_FILE to your bucket when running locally | ||
|
||
ACTION=install_driver AWS_REGION=us-east-1 CLUSTER_TYPE=kops IMAGE_NAME=s3-csi-driver TAG=v0.1.0 tests/e2e-kubernetes/run.sh | ||
|
||
ACTION=uninstall_driver AWS_REGION=us-east-1 CLUSTER_TYPE=kops tests/e2e-kubernetes/run.sh | ||
|
||
ACTION=delete_cluster AWS_REGION=us-east-1 CLUSTER_TYPE=kops tests/e2e-kubernetes/run.sh | ||
``` | ||
|
||
## Running tests | ||
### On cluster created by run.sh | ||
`run_tests` command is expected to be executed from tests/e2e-kubernetes directory: | ||
```bash | ||
pushd tests/e2e-kubernetes | ||
ACTION=run_tests AWS_REGION=us-east-1 CLUSTER_TYPE=kops TAG=v0.1.0 ./run.sh | ||
popd | ||
``` | ||
|
||
### On existing cluster | ||
From repository root: | ||
``` | ||
make e2e E2E_KUBECONFIG=~/.kube/config E2E_REGION=eu-west-1 | ||
``` | ||
> E2E_REGION specifies where to create bucket for test (should be the same as where cluster is located) | ||
## Prerequisites | ||
#### Prerequisites | ||
- existing k8s cluster (e.g. EKS) | ||
- `kubectl` in $PATH | ||
- `kubeconfig` setting up access to k8s cluster | ||
- driver deployed in the cluster | ||
- aws credentials with access to s3 (create/delete buckets, read/write/list objects) | ||
- aws credentials with access to s3 (create/delete buckets, read/write/list objects) |
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,15 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
# does not actually create cluster yet | ||
function eksctl_create_cluster() { | ||
EKS_CLUSTER_NAME=${1} | ||
EKS_REGION=${2} | ||
KUBECONFIG=${3} | ||
aws eks update-kubeconfig --region ${EKS_REGION} --name ${EKS_CLUSTER_NAME} --kubeconfig=${KUBECONFIG} | ||
} | ||
|
||
function eksctl_delete_cluster() { | ||
echo "eksctl is still using pre-created cluster" | ||
} |
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,59 @@ | ||
#!/bin/bash | ||
|
||
set -euox pipefail | ||
|
||
function helm_install() { | ||
INSTALL_PATH=${1} | ||
if [[ ! -e ${INSTALL_PATH}/helm ]]; then | ||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | ||
chmod 700 get_helm.sh | ||
export USE_SUDO=false | ||
export HELM_INSTALL_DIR=${INSTALL_PATH} | ||
./get_helm.sh | ||
rm get_helm.sh | ||
fi | ||
} | ||
|
||
function helm_uninstall_driver() { | ||
HELM_BIN=${1} | ||
KUBECTL_BIN=${2} | ||
RELEASE_NAME=${3} | ||
KUBECONFIG=${4} | ||
if [[ $($HELM_BIN list -A --kubeconfig $KUBECONFIG | grep $RELEASE_NAME) == *deployed* ]]; then | ||
$HELM_BIN uninstall $RELEASE_NAME --namespace kube-system --kubeconfig $KUBECONFIG | ||
$KUBECTL_BIN wait --for=delete pod --selector="app=s3-csi-node" -n kube-system --timeout=60s --kubeconfig $KUBECONFIG | ||
else | ||
echo "driver does not seem to be installed" | ||
fi | ||
$KUBECTL_BIN get pods -A --kubeconfig $KUBECONFIG | ||
$KUBECTL_BIN get CSIDriver --kubeconfig $KUBECONFIG | ||
} | ||
|
||
function helm_install_driver() { | ||
HELM_BIN=${1} | ||
KUBECTL_BIN=${2} | ||
RELEASE_NAME=${3} | ||
REPOSITORY=${4} | ||
TAG=${5} | ||
KUBECONFIG=${6} | ||
helm_uninstall_driver \ | ||
"$HELM_BIN" \ | ||
"$KUBECTL_BIN" \ | ||
"$RELEASE_NAME" \ | ||
"$KUBECONFIG" | ||
# temporary crutch to make eksctl working with pre-created cluster | ||
SA_CREATE=true | ||
if [[ "${KUBECONFIG}" == *"s3-csi-cluster.kubeconfig"* ]]; then | ||
SA_CREATE=false | ||
fi | ||
$HELM_BIN upgrade --install $RELEASE_NAME --namespace kube-system ./charts/aws-s3-csi-driver --values \ | ||
./charts/aws-s3-csi-driver/values.yaml \ | ||
--set image.repository=${REPOSITORY} \ | ||
--set image.tag=${TAG} \ | ||
--set image.pullPolicy=Always \ | ||
--set node.serviceAccount.create=${SA_CREATE} \ | ||
--kubeconfig ${KUBECONFIG} | ||
$KUBECTL_BIN rollout status daemonset s3-csi-node -n kube-system --timeout=60s --kubeconfig $KUBECONFIG | ||
$KUBECTL_BIN get pods -A --kubeconfig $KUBECONFIG | ||
echo "s3-csi-node-image: $($KUBECTL_BIN get daemonset s3-csi-node -n kube-system -o jsonpath="{$.spec.template.spec.containers[:1].image}" --kubeconfig $KUBECONFIG)" | ||
} |
This file was deleted.
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,3 @@ | ||
spec: | ||
instanceMetadata: | ||
httpPutResponseHopLimit: 3 |
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,12 @@ | ||
spec: | ||
additionalPolicies: | ||
node: | | ||
[ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"s3:*" | ||
], | ||
"Resource": "*" | ||
} | ||
] |
Oops, something went wrong.