Cleaning up deploy-example-secret.sh (#5374)

pull/5403/head
Gerard Vanloo 4 years ago committed by GitHub
parent 7378b697f8
commit 82897832a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      operator/Makefile
  2. 10
      operator/docs/hack_loki_operator.md
  3. 19
      operator/hack/deploy-aws-storage-secret.sh
  4. 35
      operator/hack/deploy-example-secret.sh

@ -183,15 +183,6 @@ olm-deploy: olm-deploy-bundle olm-deploy-operator $(OPERATOR_SDK)
$(OPERATOR_SDK) run bundle -n $(CLUSTER_LOGGING_NS) --install-mode OwnNamespace $(BUNDLE_IMG)
endif
# Build and push the secret for the S3 storage
.PHONY: olm-deploy-example-storage-secret
olm-deploy-example-storage-secret:
hack/deploy-example-secret.sh $(CLUSTER_LOGGING_NS)
.PHONY: olm-deploy-example
olm-deploy-example: olm-deploy olm-deploy-example-storage-secret ## Deploy example LokiStack custom resource
kubectl -n $(CLUSTER_LOGGING_NS) create -f hack/lokistack_dev.yaml
.PHONY: olm-undeploy
olm-undeploy: $(OPERATOR_SDK) ## Cleanup deployments of the operator bundle and the operator via OLM on an OpenShift cluster selected via KUBECONFIG.
$(OPERATOR_SDK) cleanup loki-operator

@ -29,7 +29,7 @@ Loki Operator is the Kubernetes Operator for [Loki](https://grafana.com/docs/lok
```console
kubectl get pods
```
You should see `controller-manager-xxxx` and `minio-xxxx` pods running.
* Now create a LokiStack instance to get the various components of Loki up and running:
@ -104,17 +104,15 @@ It will undeploy controller from the configured Kubernetes cluster in [~/.kube/c
* Now you need to create a storage secret for the operator. This can be done using:
```console
make olm-deploy-example-storage-secret
./hack/deploy-aws-storage-secret.sh <BUCKET_NAME>
```
OR
This secret will be available in `openshift-logging` namespace. You can check the `hack/deploy-aws-storage-secret.sh` file to check the content of the secret. By default, the script will pull credential information using the `aws` cli. However, these values can be overwritten. For example:
```console
./hack/deploy-example-secret.sh openshift-logging
REGION=us-west-1 ./hack/deploy-aws-storage-secret.sh <BUCKET_NAME>
```
This secret will be available in openshift-logging namespace. You can check the `hack/deploy-example-secret.sh` file to check the content of the secret.
* Now you need to create a gateway secret [3] for the operator. This can be done using:
```code

@ -0,0 +1,19 @@
#!/bin/bash
set -eou pipefail
BUCKET_NAME=$1
NAMESPACE=${NAMESPACE:-openshift-logging}
REGION=${REGION:-$(aws configure get region)}
ACCESS_KEY_ID=${ACCESS_KEY_ID:-$(aws configure get aws_access_key_id)}
SECRET_ACCESS_KEY=${SECRET_ACCESS_KEY:-$(aws configure get aws_secret_access_key)}
kubectl --ignore-not-found=true -n "${NAMESPACE}" delete secret test
kubectl -n "${NAMESPACE}" create secret generic test \
--from-literal=region="$(echo -n "${REGION}")" \
--from-literal=bucketnames="$(echo -n "${BUCKET_NAME}")" \
--from-literal=access_key_id="$(echo -n "${ACCESS_KEY_ID}")" \
--from-literal=access_key_secret="$(echo -n "${SECRET_ACCESS_KEY}")" \
--from-literal=endpoint="$(echo -n "https://s3.${REGION}.amazonaws.com")"

@ -1,35 +0,0 @@
#!/bin/bash
set -eou pipefail
NAMESPACE=$1
REGION=""
ENDPOINT=""
ACCESS_KEY_ID=""
SECRET_ACCESS_KEY=""
LOKI_BUCKET_NAME="${LOKI_BUCKET_NAME:-loki}"
set_credentials_from_aws() {
REGION="$(aws configure get region)"
ACCESS_KEY_ID="$(aws configure get aws_access_key_id)"
SECRET_ACCESS_KEY="$(aws configure get aws_secret_access_key)"
ENDPOINT="https://s3.${REGION}.amazonaws.com"
}
create_secret() {
kubectl -n "${NAMESPACE}" delete secret test ||:
kubectl -n "${NAMESPACE}" create secret generic test \
--from-literal=endpoint="$(echo -n "${ENDPOINT}")" \
--from-literal=region="$(echo -n "${REGION}")" \
--from-literal=bucketnames="$(echo -n "${LOKI_BUCKET_NAME}")" \
--from-literal=access_key_id="$(echo -n "${ACCESS_KEY_ID}")" \
--from-literal=access_key_secret="$(echo -n "${SECRET_ACCESS_KEY}")"
}
main() {
set_credentials_from_aws
create_secret
}
main
Loading…
Cancel
Save