mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
+5








6d65a90de9
* greetings * Update aws.sh simplified the comment * typo: In the title and h1 element Their was a typo in index.html file. * punctuation changes * docs : added gitpod badge in readme.md * fixed typos * some grammar mistake is corrected inPULL_REQUEST_TEMPLATE.md file * Updated README.md file Added link to CONTRIBUTING.md file in a line in README. * Added link to code of conduct file I have added link to the code of conduct file and fixed some problems in the Readme file. * Fixed readme * Added alpine tag Adding alpine tag instead of latest and removing repeating commands * roadmap.md file is modified * Automatically Close "Typo" labelled Issue * build.py is modified * modified PR template * Fixed some typos in feature_request.md "." at the end of the headings were missing and all the text were in same line. Now this gives a clear and concise view of the texts. * fixed the typo in docs/index.html Found and fixed typo in the 'alt' attribute of img tag * Update PULL_REQUEST_TEMPLATE.md Co-authored-by: Krishna Agarwal <dmkrishna.agarwal@gmail.com> Co-authored-by: Saswata Senapati <74651639+saswat16@users.noreply.github.com> Co-authored-by: Rahul Singh <110548934+rahuldhirendersingh@users.noreply.github.com> Co-authored-by: deepuyadav004 <deepuyadavze@gmail.com> Co-authored-by: kartik <97971066+kartikgajjar7@users.noreply.github.com> Co-authored-by: Rounak-28 <95576871+Rounak-28@users.noreply.github.com> Co-authored-by: pwnb0y <vickykr07@yahoo.com> Co-authored-by: Ben Hirschberg <59160382+slashben@users.noreply.github.com> Co-authored-by: Saptarshi Sarkar <saptarshi.programmer@gmail.com> Co-authored-by: Rahul Surwade <93492791+RahulSurwade08@users.noreply.github.com> Co-authored-by: Suhas Gumma <43647369+suhasgumma@users.noreply.github.com> Co-authored-by: Kamal Nayan <95926324+legendarykamal@users.noreply.github.com> Co-authored-by: TarangVerma <90996971+TarangVerma@users.noreply.github.com> Co-authored-by: avikittu <65793296+avikittu@users.noreply.github.com>
69 lines
2.2 KiB
Bash
Executable File
69 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# AWS
|
|
# Attach the Kubescape service account to an AWS IAM role with the described cluster permission
|
|
|
|
# Prerequisites:
|
|
# eksctl, awscli v2
|
|
|
|
# Set environment variables
|
|
echo 'Set environment variables'
|
|
export kubescape_namespace=kubescape
|
|
export kubescape_serviceaccount=armo-kubescape-service-account
|
|
|
|
# Get current context
|
|
echo 'Get current context'
|
|
export context=$(kubectl config current-context)
|
|
|
|
# Get cluster arn
|
|
echo 'Get cluster arn'
|
|
export cluster_arn=$(kubectl config view -o jsonpath="{.contexts[?(@.name == \"$context\")].context.cluster}")
|
|
|
|
# Get cluster name
|
|
echo 'Get cluster name'
|
|
export cluster_name=$(echo "$cluster_arn" | awk -F'/' '{print $NF}')
|
|
|
|
# Get cluster region
|
|
echo 'Get cluster region'
|
|
export cluster_region=$(echo "$cluster_arn" | awk -F':' '{print $4}')
|
|
|
|
# First step, Create IAM OIDC provider for the cluster (Not required if the third step runs as it is):
|
|
echo 'Create IAM OIDC provider for the cluster'
|
|
eksctl utils associate-iam-oidc-provider --cluster $cluster_name --approve
|
|
|
|
# Second step, Create a policy and service account role:
|
|
# Create a kubescape policy
|
|
echo 'Create a kubescape policy'
|
|
export kubescape_policy_arn=$(aws iam create-policy \
|
|
--output yaml \
|
|
--query 'Policy.Arn' \
|
|
--policy-name kubescape \
|
|
--policy-document \
|
|
"$(cat <<EOF
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Effect": "Allow",
|
|
"Action": "eks:DescribeCluster",
|
|
"Resource": "$cluster_arn"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
)")
|
|
|
|
# Create Kubernetes Kubescape service account, and AWS IAM attachment role
|
|
echo 'Create Kubernetes Kubescape service account, and AWS IAM attachment role'
|
|
eksctl create iamserviceaccount \
|
|
--name $kubescape_serviceaccount \
|
|
--namespace $kubescape_namespace \
|
|
--cluster $cluster_name \
|
|
--attach-policy-arn $kubescape_policy_arn \
|
|
--approve \
|
|
--override-existing-serviceaccounts
|
|
|
|
# Install/Upgrade Kubescape chart
|
|
echo 'Install/Upgrade Kubescape chart'
|
|
helm upgrade --install armo armo-components/ -n kubescape --create-namespace --set clusterName=$cluster_name --set cloud_provider_engine=eks --set createKubescapeServiceAccount=false --set cloudRegion=$cluster_region
|