IFRCGo / go-api

MIT License
14 stars 6 forks source link

[Staging] New tasks in Kubernetes world #1783

Open szabozoltan69 opened 1 year ago

szabozoltan69 commented 1 year ago

Issue

Due to the new Kubernetes system there are some new tasks:

szabozoltan69 commented 1 year ago

@batpad @geohacker

szabozoltan69 commented 1 year ago

Some logs about saving a "General Document":

    raise _wrap_exception(ex, AzureException)
azure.common.AzureException: Invalid URL 'http:///subscriptions/39308fb0-.../resourceGroups/ifrct...02rg/providers/Microsoft.Storage/storageAccounts/ifrctgo.blob.core.windows.net/api/documents/test1/a.jpg': No host supplied
geohacker commented 1 year ago

advised workflow", what to do with develop and terraform branches, how to keep them parallel, when to merge.

@szabozoltan69 we should delete the terraform branch once it's merged to develop. Which I think we can do right before going to production

In the Azure container registry (ifrcgoacr, ifrcgo-api) a plenty of 2GB containers are collected. Should we clean up sometimes manually?

We might have to do this manually. https://learn.microsoft.com/en-gb/azure/container-registry/container-registry-auto-purge

@szabozoltan69 @batpad I believe we are ready to switch to the k8s based stack for production too. Is there anything else blocking this move?

szabozoltan69 commented 1 year ago

Yes (about blocking), it would be fine to have a sharp endpoint of the deployment (when the sign changes to green), because recently it changes to green, and "at some point it turns out that is is ready". (We should avoid displaying green status of deployment in pipeline while the deployment is not finished.) I suppose it's not a big deal, but makes things clear.

And also another thing: In https://goadmin-stage.ifrc.org/api/v2/brief the git-last-tag has no relation to the real value. I suppose the pipeline git value disturb this. We should find a solution to be able to check the deployed branch "git tag" hash (here in /brief). https://github.com/IFRCGo/go-api/blob/develop/api/views.py#L504-L505

geohacker commented 1 year ago

it would be fine to have a sharp endpoint of the deployment (when the sign changes to green), because recently it changes to green, and "at some point it turns out that is is ready".

I'm not sure if I understand this correctly. Are you referring to the azure pipeline behaviour?

And also another thing: In https://goadmin-stage.ifrc.org/api/v2/brief the git-last-tag has no relation to the real value.

@szabozoltan69 It's because for staging deploys we don't create git tags, but we can if needed. But the "git_last_commit": "ec1f00cd" would line up correctly with the commit that triggered the deploy https://github.com/IFRCGo/go-api/pull/1725/commits/ec1f00cd6fb1c666c46f08f847c7a8d411766cd5

szabozoltan69 commented 1 year ago

@geohacker Yes, I refer to azure pipeline behaviour (in my first comment). @batpad mentioned somewhere a way how to avoid that pipeline gets green and the deployment is still not fully finished.

The git last commit is ok, but the last git tag (which is like 1.1.482) is not. If possible, it would be fine to be able to check that also. If it is too difficult, I can let it go.

szabozoltan69 commented 1 year ago

Also it is a question in me, that is it really unavoidable that a new env variable should appear in 8 locations? Can't we reduce these somehow?

szabozoltan69 commented 1 year ago

Also: a basic knowhow is needed for the Loki/Graphana/Prometheus log checking. Without this it makes no sense to do the go-live cutover.

geohacker commented 1 year ago

@szabozoltan69 @batpad I've added a section in the docs about how to access and view logs in Grafana and using kubectl https://github.com/IFRCGo/go-api/tree/terraform#see-logs-from-kubernetes

The git last commit is ok, but the last git tag (which is like 1.1.482) is not.

Creating tags per staging release seems unnecessary. If we want to do that for production that's ok. But that has nothing to do with the azure pipeline.

that is it really unavoidable that a new env variable should appear in 8 locations

@szabozoltan69 unfortunately, we can't avoid this right now. Though are there 8 locations? The value is set in azure pipeline secrets, then read from github actions, then used in Docker Compose to the container env, then in variables.tf and main.tf (that's 4-5 in total, right?) We can look into optimising this later on but there are no easy ways. It's better to be more verbose about variables than it being magically populated.

szabozoltan69 commented 1 year ago

Ok, I can accept these. Otherwise it's really 8: docker-compose.yml, deploy/docker-compose.yml, deploy/terraform/resources/helm-ifrcgo.tf, deploy/terraform/resources/variables.tf, deploy/terraform/main.tf, deploy/terraform/variables.tf, deploy/helm/ifrcgo-helm/values.yaml, deploy/helm/ifrcgo-helm/templates/config/secret.yaml or deploy/helm/ifrcgo-helm/templates/config/configmap.yaml – though one of them is not for pipeline but for local development (but unavoidable).

szabozoltan69 commented 1 year ago

About Graphana my question (howto) was not only to know the technical details how to reach it in the browser, but mostly what are the really effective queries to check relevant events, details about the system. So: "If you want to run custom queries, use the Explore tab." – but what custom queries should be relevant in our case? I suppose there are not 10000 interesting queries, but maybe 2-3 types.

geohacker commented 1 year ago

@szabozoltan69 You can see some examples in the Grafana docs here https://grafana.com/docs/loki/latest/logql/query_examples/ — but ideally you should just go to Explore and use the options there to frame a query if needed. It's all to look through logs and search for specific keywords. I'm pretty sure you'll be able to figure it out!

szabozoltan69 commented 1 week ago

Refreshment of SSL certificates should be done on a non-manual way. @sunu