giantswarm / roadmap

Giant Swarm Product Roadmap
https://github.com/orgs/giantswarm/projects/273
Apache License 2.0
3 stars 0 forks source link

Add volumes metadata #710

Closed kopiczko closed 2 years ago

kopiczko commented 2 years ago

We need metadata to be able to clean orphaned volumes reliably. We have many volumes which are not attached and they are not cleaned. For the OS projects where we have only Giant Swarm platform running we can wipe out all unattached volumes but it is probably not acceptable in projects where volumes can be created outside Giant Swarm product.

cornelius-keller commented 2 years ago

Should be doable with https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/docs/book/src/clusteropenstack/configuration.md#tagging, and would also tag all the other recources. So this sould be easy to add to the templates.

kopiczko commented 2 years ago

That's surely useful but I doubt it will tag volumes because there are managed by a different controller (openstack-cinder-csi-nodeplugin)

cornelius-keller commented 2 years ago

Ok, got it. Then there is a --cluster command line argument in the driver config that we can use. How would we pass the cluater name as a value here? https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/cinder-csi-plugin/using-cinder-csi-plugin.md#driver-deployment

kopiczko commented 2 years ago

That should be easy 👍

erkanerol commented 2 years ago

https://github.com/kubernetes/cloud-provider-openstack/blob/master/docs/cinder-csi-plugin/using-cinder-csi-plugin.md#driver-deployment

I tried that but it didn't work. My understanding is that it is related to klog.

However, I found this https://github.com/giantswarm/cloud-provider-openstack-app/blob/master/helm/cloud-provider-openstack-app/charts/openstack-cinder-csi/templates/controllerplugin-statefulset.yaml#L107

and tested. It works.

Screen Shot 2022-01-25 at 19 08 53

I can see my cluster name in properties.

erkanerol commented 2 years ago
+---------------------+---------------------------------------------------------------------+
| Field               | Value                                                               |
+---------------------+---------------------------------------------------------------------+
| admin_state_up      | True                                                                |
| availability_zone   | None                                                                |
| created_at          | 2022-01-26T07:27:17                                                 |
| description         | Kubernetes external service default/nginxservice from cluster erk4n |
| flavor_id           | None                                                                |
| id                  | b703c177-c726-40d8-a94b-95aa6b1761db                                |
| listeners           | 275c6304-dfba-4618-8f95-8ab822506df9                                |
| name                | kube_service_erk4n_default_nginxservice                             |
| operating_status    | ONLINE                                                              |
| pools               | 464b1726-4090-401a-977f-4eb57c7e8c06                                |
| project_id          | bf9a710c30c44575a51db4b0c1f859f9                                    |
| provider            | amphora                                                             |
| provisioning_status | ACTIVE                                                              |
| updated_at          | 2022-01-26T07:28:05                                                 |
| vip_address         | 10.6.0.197                                                          |
| vip_network_id      | 8ac9b826-5266-40ab-883f-9caeebf1f673                                |
| vip_port_id         | 9961cf3b-48d3-423f-a8ba-dd991f02427b                                |
| vip_qos_policy_id   | None                                                                |
| vip_subnet_id       | ba528d72-e178-478c-a017-98c8096aa29c                                |
| tags                | kube_service_erk4n_default_nginxservice                             |
+---------------------+---------------------------------------------------------------------+

To be able to tag load balancers as above:

  1. We need to use openstack-cloud-controller-manager v1.23.0 or newer versions
  2. We need to add --cluster-name flag into openstack-cloud-controller-manager daemonset here https://github.com/giantswarm/cloud-provider-openstack-app/blob/master/helm/cloud-provider-openstack-app/charts/openstack-cloud-controller-manager/templates/daemonset.yaml#L35
erkanerol commented 2 years ago

To be able to distinguish tags referring to clusters' names, we decided to use giant_swarm_cluster_ as a prefix. [1]

MC: Volume&Load Balancer Tagging: https://github.com/giantswarm/capo-mc-bootstrap/pull/68 Cluster Tagging+Volume&Load Balancer Tagging: https://github.com/giantswarm/capo-mc-bootstrap/pull/71

WC: Cluster Tagging: https://github.com/giantswarm/cluster-openstack/pull/32 Volume&Load Balancer Tagging: https://github.com/giantswarm/default-apps-openstack/pull/20

  1. Using giantswarm.io/cluster is not possible because of character limitations in tags. Using giant-swarm-cluster doesn't make sense since cluster names may include - and it is easier to split into different parts now. Also note that, cinder-csi and cloud-controller-manager allow us to use only 1 value as cluster name so it is not possible to pass managementCluster and clusterID values separately.