From 987aba9ca7ae9415178936858c456863e2d72da3 Mon Sep 17 00:00:00 2001 From: Gerard Vanloo Date: Fri, 11 Feb 2022 11:52:47 -0500 Subject: [PATCH] Cleaning up deploy-example-secret.sh --- operator/Makefile | 9 ------ operator/docs/hack_loki_operator.md | 10 +++---- operator/hack/deploy-aws-storage-secret.sh | 19 ++++++++++++ operator/hack/deploy-example-secret.sh | 35 ---------------------- 4 files changed, 23 insertions(+), 50 deletions(-) create mode 100755 operator/hack/deploy-aws-storage-secret.sh delete mode 100755 operator/hack/deploy-example-secret.sh diff --git a/operator/Makefile b/operator/Makefile index b6d7187e6620c..90fb198ff5f4f 100644 --- a/operator/Makefile +++ b/operator/Makefile @@ -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 diff --git a/operator/docs/hack_loki_operator.md b/operator/docs/hack_loki_operator.md index 112f65f3a816a..4a80f83d1a28f 100644 --- a/operator/docs/hack_loki_operator.md +++ b/operator/docs/hack_loki_operator.md @@ -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 ``` - 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 ``` - 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 diff --git a/operator/hack/deploy-aws-storage-secret.sh b/operator/hack/deploy-aws-storage-secret.sh new file mode 100755 index 0000000000000..5fcf2e83f75f5 --- /dev/null +++ b/operator/hack/deploy-aws-storage-secret.sh @@ -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")" diff --git a/operator/hack/deploy-example-secret.sh b/operator/hack/deploy-example-secret.sh deleted file mode 100755 index 3f4456c07ba61..0000000000000 --- a/operator/hack/deploy-example-secret.sh +++ /dev/null @@ -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