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

Check for no external IPs or private cluster in PostgreSQL webhook is implemented #589

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

DoodgeMatvey
Copy link
Contributor

Closes #588

Comment on lines +202 to +225
nodeList := &k8sCore.NodeList{}

err := pgv.K8sClient.List(ctx, nodeList, &client.ListOptions{})
if err != nil {
return fmt.Errorf("cannot list node list, error: %v", err)
}

var externalIPExists bool
for _, node := range nodeList.Items {
for _, nodeAddress := range node.Status.Addresses {
if nodeAddress.Type == k8sCore.NodeExternalIP {
externalIPExists = true
break
}
}
}

if !externalIPExists || pg.Spec.PrivateNetworkCluster {
return fmt.Errorf("cannot create PostgreSQL user, if your cluster is private or has no external ips " +
"you need to configure peering and remove user references from cluster specification")
}

return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

please, remove a similar code from the controller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@DoodgeMatvey DoodgeMatvey force-pushed the issue-588-externalip-webhook branch from 4c337f0 to 2f45543 Compare October 6, 2023 13:34
@DoodgeMatvey DoodgeMatvey requested a review from ribaraka October 9, 2023 11:16
@DoodgeMatvey DoodgeMatvey merged commit 5ed2ebd into main Oct 9, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle no external IPs or private cluster for PostgreSQL users in webhook
4 participants