forked from netobserv/documents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloki-s3-only.sh
executable file
·30 lines (25 loc) · 960 Bytes
/
loki-s3-only.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
if [[ "$#" -lt 1 || "$1" = "--help" ]]; then
echo "Syntax: $0 S3_NAME AWS_REGION"
echo ""
echo "Create S3 bucket and the related secret to use with the Loki operator"
echo "You need to have the AWS CLI installed and configured."
echo ""
echo " e.g: $0 yourname-loki eu-west-1"
echo ""
exit
fi
S3_NAME="$1"
AWS_REGION="$2"
AWS_KEY=$(aws configure get aws_access_key_id)
AWS_SECRET=$(aws configure get aws_secret_access_key)
aws s3api create-bucket --bucket $S3_NAME --region $AWS_REGION --create-bucket-configuration LocationConstraint=$AWS_REGION
SECRET=lokistack-dev-s3
NAMESPACE=netobserv
kubectl create namespace $NAMESPACE
kubectl create -n $NAMESPACE secret generic ${SECRET} \
--from-literal=bucketnames="$S3_NAME" \
--from-literal=endpoint="https://s3.${AWS_REGION}.amazonaws.com" \
--from-literal=access_key_id="${AWS_KEY}" \
--from-literal=access_key_secret="${AWS_SECRET}" \
--from-literal=region="${AWS_REGION}"