33 lines
834 B
Bash
33 lines
834 B
Bash
|
#!/bin/bash
|
||
|
ELASTIC_PASSWORD="your_secure_password"
|
||
|
ELASTIC_HOST=$(microk8s.kubectl get svc elasticsearch -n efk -o wide | awk 'NR==2 {print $3}')
|
||
|
echo $ES_IP
|
||
|
|
||
|
curl -X PUT "http://${ELASTIC_HOST}:9200/_security/role/fluentd_writer" \
|
||
|
-u elastic:$ELASTIC_PASSWORD \
|
||
|
-H "Content-Type: application/json" \
|
||
|
-d '{
|
||
|
"cluster": ["monitor"],
|
||
|
"indices": [
|
||
|
{
|
||
|
"names": ["logstash-*"],
|
||
|
"privileges": ["write", "create_index"]
|
||
|
}
|
||
|
]
|
||
|
}'
|
||
|
echo "\n"
|
||
|
curl -X PUT "http://$ELASTIC_HOST:9200/_security/user/fluentd_user" \
|
||
|
-u elastic:$ELASTIC_PASSWORD \
|
||
|
-H "Content-Type: application/json" \
|
||
|
-d '{
|
||
|
"password": "fluentd_password",
|
||
|
"roles": ["fluentd_writer"]
|
||
|
}'
|
||
|
|
||
|
|
||
|
echo "\n"
|
||
|
curl -X GET "http://$ELASTIC_HOST:9200/_security/user/fluentd_user" \
|
||
|
-u elastic:$ELASTIC_PASSWORD
|
||
|
|
||
|
echo "\n"
|