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

Added ingress support #712 #785

Merged
merged 4 commits into from
Nov 11, 2021

Conversation

abhishekdwivedi3060
Copy link
Contributor

@abhishekdwivedi3060 abhishekdwivedi3060 commented Oct 19, 2021

closes #712

  • Added support for UI ingress resource with CRDB cluster
  • Added new actor for ingress resource creation and deletion

Input to be given:

ingress:
    ui:
      ingressClassName: nginx
      annotations:
        key: value
      host: ui.test.com

Make sure the host ui.test.com is publicly accessible.
There can be 2 ways to make the host locally resolvable are:

a. Make an entry in /etc/hosts with the host and ingress-controller Public IP
b. Make an entry in /etc/hosts` with the local host (127.0.0.1) and do port-forwarding on ingress-controller pod

NOTE: Ingress-controller is not deployed as part of this feature. It is pre-requisite that ingress-controller is running inside the Kubernetes cluster

@abhishekdwivedi3060 abhishekdwivedi3060 changed the title WIP: Added ingress support #712 Added ingress support #712 Nov 10, 2021
@@ -82,13 +84,34 @@ func (r *CrdbCluster) Default() {
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (r *CrdbCluster) ValidateCreate() error {
webhookLog.Info("validate create", "name", r.Name)
var errors []error
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to have a slice of errors if there can be at most one error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now, there are minimal checks in webhook so returning single error is fine.
But as we keep on adding more validation checks in webhook, ideally we should validate the complete CR object and return the combined error in one go instead of returning one by one error in each iteration by the user.
Hence added slice of errors here.

return false, nil
}

// this is the case of update when ingress is removed from CR
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe name the function needsIngressDeploy? it's a little confusing in this case when the name is needsIngress but we need to remove the ingress

@@ -210,12 +216,19 @@ func (r *ClusterReconciler) Reconcile(ctx context.Context, req reconcile.Request

// SetupWithManager registers the controller with the controller.Manager from controller-runtime
func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
var ingress client.Object
ingress = &v1.Ingress{}
if !util.CheckIfAPIVersionKindAvailable(mgr.GetConfig(), "networking.k8s.io/v1", "Ingress") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this - does it depend on the version of k8s being used or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We need to support both v1beta1 ingress and v1 ingress. So depending upon the version available in the cluster (depends on the k8s version), we have to watch corresponding version ingress.
This will be removed when our minimum supported version is 1.19

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.

Expose CRDB services via Ingress
2 participants