-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathloki-operator.sh
executable file
·65 lines (54 loc) · 1.93 KB
/
loki-operator.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
if [[ "$#" -lt 1 || "$1" = "--help" ]]; then
echo "Syntax: $0 S3_NAME AWS_REGION NAMESPACE"
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 loki"
echo ""
exit
fi
S3_NAME="$1"
AWS_REGION="$2"
NAMESPACE="netobserv"
if [[ "$3" != "" ]]; then
NAMESPACE="$3"
fi
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
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}"
kubectl apply -n $NAMESPACE -f examples/loki-stack/demo.yaml
echo ""
echo "Deployment complete"
echo ""
echo "Configure FlowCollector Loki with:"
echo " mode: LokiStack"
echo " lokiStack:"
echo " name: loki"
echo " namespace: $NAMESPACE"
echo ""
echo "To allow test user reading flow logs, run:"
echo "kubectl apply -n $NAMESPACE -f examples/loki-stack/rolebinding-user-test.yaml"
echo "or"
echo "oc adm policy add-cluster-role-to-user netobserv-reader test"
echo ""
echo "To delete all created Kube resources, run:"
echo "kubectl delete -n $NAMESPACE secret $SECRET"
echo "kubectl delete -n $NAMESPACE -f examples/loki-stack/demo.yaml"
echo "kubectl delete -n $NAMESPACE pvc --all"
echo ""
echo "To delete the S3 bucket, run:"
echo "aws s3 rm s3://$S3_NAME --recursive"
echo "aws s3 rb s3://$S3_NAME"
echo ""
echo "⏳ Waiting for LokiStack to be ready..."
kubectl wait --timeout=180s --for=condition=ready lokistack loki -n $NAMESPACE