Skip to content
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

feat(kuma-cp) DNS resolver persistence #850

Merged
merged 12 commits into from
Jun 26, 2020
Merged

Conversation

nickolaev
Copy link
Contributor

Summary

Introduce a new ConfigStore inspired by the SecretsStore. Implement DNS persistence on top of it.

Example format of the resulting storage in ConfigMap on K8s:

> kubectl -n kuma-system get cm/kuma-internal-config -o yaml
apiVersion: v1
data:
  config: '{"demo-client":"240.0.0.1","echo-server":"240.0.0.0"}'
kind: ConfigMap
metadata:
  creationTimestamp: "2020-06-24T13:14:00Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:config: {}
    manager: kuma-cp
    operation: Update
    time: "2020-06-24T13:14:27Z"
  name: kuma-internal-config
  namespace: kuma-system
  resourceVersion: "1667"
  selfLink: /api/v1/namespaces/kuma-system/configmaps/kuma-internal-config
  uid: 38a374dd-0abf-4133-be77-dafd4307441d

@nickolaev nickolaev requested a review from a team June 24, 2020 13:42
@nickolaev nickolaev marked this pull request as draft June 24, 2020 13:42
Nikolay Nikolaev added 5 commits June 24, 2020 17:42
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev marked this pull request as ready for review June 25, 2020 05:06
api/system/v1alpha1/config.proto Outdated Show resolved Hide resolved
pkg/dns-server/resolver/persistence.go Outdated Show resolved Hide resolved
pkg/dns-server/resolver/persistence.go Outdated Show resolved Hide resolved
pkg/dns-server/resolver/persistence.go Outdated Show resolved Hide resolved
resource := &config_model.ConfigResource{}
err := p.manager.Get(context.Background(), resource, store.GetByKey("kuma-internal-config", ""))
if err != nil {
err = p.manager.Create(context.Background(), resource, store.CreateByKey("kuma-internal-config", ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and isn't resource is empty at that line, why we try to create it?

pkg/dns-server/resolver/persistence.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

@nickolaev nickolaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have doubts about the VIPs synchronizer running also on the leader. That sounds redundant to me.

resource := &config_model.ConfigResource{}
err := p.manager.Get(context.Background(), resource, store.GetByKey(dnsConfigKey, ""))
if err != nil {
if store.IsResourceNotFound(err) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

func (s *dnsResolver) SetVIPs(list VIPList) {
s.Lock()
defer s.Unlock()
s.viplist = list
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this does not get in the range of hundreds of thousands in practice.

return service, nil
}

var _ DNSResolver = &dnsResolver{}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should this be on top?

close(stop)
})

It("", func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a name here?

}
}

if change {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

func (d *vipsSynchronizer) synchronize() error {
vipList, err := d.persistence.Get()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this will run also on the leader? We set the VIPs and then get them back?

Copy link
Contributor Author

@nickolaev nickolaev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Approved

@@ -64,6 +67,9 @@ func (d *vipsSynchronizer) Start(stop <-chan struct{}) error {
}

func (d *vipsSynchronizer) synchronize() error {
if d.leadInfo.IsLeader() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jakubdyszkiewicz jakubdyszkiewicz merged commit aecb8aa into master Jun 26, 2020
@jakubdyszkiewicz jakubdyszkiewicz deleted the feat/dns_persistence branch June 26, 2020 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants