-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Setting bootstrap key on startup not working #27
Comments
the bootstrap key is bootstraping the cluster once in the beginning and for all - no way back or replacements, you cannot replace it at will (unless if you create another admin key via typesense itself, encode it to base64 and then replace it in the Secret , then recreate the StatefulSet Pods to take the new value in their envvars - but i guess that might be an "emergency" situation and has nothing to do with this operator) which sounds like your case:
In your second question, where you altered the name of the Secret, the error that you get is fully legit - no malfuction of the operator. The STS Pods were created by the operator to point to that Secret and they're still looking for the original name. |
The secret is in our helm chart in the same file as the TypesenseCluster. It gets deployed at the same time. We are not trying to change the bootstrap key after the pods are already deployed.
The situation I meant with this is as follows:
My deduction of the situation was:
Changing the name was a futile step and has nothing to do with the problem at hand. But my thinking was to see if the problem layed in the check of the operator that looks at the TypesenseCluster and if the spec.adminApiKey variable is set or not. If after the name change there were 2 secrets I would know that the operator has not processed the given api key and instead created a new one that was then used by the typesense pods. But if there is only 1 secret after the name change, that would mean there is nothing wrong with the processing but something else.
This was just, because I did not completely reinstall our helm chart, but just used upgrade after the name of the secret was changed in the chart. After reinstalling the chart the secret with the other name is found, yet the TYPESENSE_API_KEY variable in the pod is not the decoded value of the secret, but some other generated value. Naturally sending requests with our defined key will not work in this situation. $ kubectl get secret -n typesense typesense-bootstrap-key -o yaml
apiVersion: v1
data:
typesense-api-key: eHl6Cg== env | grep TYPESENSE_
TYPESENSE_API_KEY=S0OagYMvis7oIe3vxa1ge+fD+lzOweqtvraFhwEogW029BGCQzaqOGwZx/UUdiQTuj63w1vm4IGQs8mEkj7C4gac7HRokTHW1NmgQH9m2RevXJ6jzJCHUuHpz5tJeqsYHPTU8DPZiOpCpfYKoSToufQJsDme4R4DiV86ptYZt8vtBxbzTxCOLM445bxR8Z+JjI8Ijh2G4Yok5sNH3ND9oM8p5vfuuA7aAfSp6aYhFEVSnicdegKjtV/2pAeu6mQtDHJEKuzdoLdkAYfzen2oAkztVvsgode+4/oL5La/44K31WSf5/mhS/NjlY6gPIp+7GPPh52HV+x2/KSmV9a4Lg== After updating the crd, as it was the fix for problem #26, the situation is different but the problem still the same. Now the correct value is in the pod, but any request is still unauthorized. $ env | grep TYPESENSE_
TYPESENSE_API_KEY=xyz $ curl 'http://localhost:8108/keys' \
-X GET \
-H "X-TYPESENSE-API-KEY: xyz"
{"message": "Forbidden - a valid `x-typesense-api-key` header must be sent."} Now I do not know where the differing bootstrap key is coming from or how the pod has a bootstrap key that is different from the TYPESENSE_API_KEY variable. |
Ok I found the bug; your deduction is somehow (under conditions) correct => The Secret was deployed after the Helm Chart (I don't imply you should follow a deployment order; the contrary) and the Operator falsely creates in this case a new Secret with the exact very name you provided in |
We would like to be able to set the bootstrap key, as it removes the step of decoding the generated key and adding it to some keystore/vault. It would be easier to set some key in a vault and start typesense with that key. But we cannot get the changes from #13 working.
Naturally the key is just a placeholder and is just used for debugging, as the key is "xyz".
The sample is the same with a different key value.
We would assume this set the bootstrap key to our defined value, but when sending requests we are unauthorized with our key. The problem is that there is only one secret and that has our value, so we cannot get the actual value of the bootstrap key for our pods. We somehow overwrote the secret that was used.
I then changed the name of our secret from typesense-common-bootstrap-key to typesense-bootstrap-key and it was still the only secret, but now the containers could not start as they did not find typesense-common-bootstrap-key secret, even though the name value for the key was typesense-bootstrap-key.
Is there anything wrong with our configuration?
The text was updated successfully, but these errors were encountered: