-
Notifications
You must be signed in to change notification settings - Fork 16
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/external api #74
base: main
Are you sure you want to change the base?
Conversation
type ExternalSettings struct { | ||
// +kubebuilder:validation:Enum={ingress,loadbalancer,none} | ||
// +optional | ||
Strategy ExternalStrategy `json:"strategy,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly are these fields supposed to change or control? Could you please include a one-sentence comment above the new fields and structs being added?
@RobotSail can you check this out when you get the chance? |
This is running in the test cluster, you can find the gateway with and this can be used as a gateway just like ipfs.io. i.e. you can find content in a browser by hitting |
@@ -135,28 +146,28 @@ func (r *IpfsClusterReconciler) StatefulSet(m *clusterv1alpha1.IpfsCluster, | |||
}, | |||
Ports: []corev1.ContainerPort{ | |||
{ | |||
Name: "swarm", | |||
ContainerPort: portSwarm, | |||
Name: nameIpfsSwarm, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
svcName, | ||
m.Name, | ||
m.Namespace, | ||
"LoadBalancer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this always need to be a loadbalancer? Could a ClusterIP not fulfill this role?
@@ -161,6 +166,13 @@ func (r *IpfsClusterReconciler) createTrackedObjects( | |||
&secConfig: mutSecConfig, | |||
&sts: mutSts, | |||
} | |||
|
|||
if instance.Spec.Gateway.Strategy == clusterv1alpha1.ExternalStrategyLoadBalancer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in other words, only LoadBalancer is currently supported?
@@ -43,8 +43,8 @@ spec: | |||
- --leader-elect | |||
command: | |||
- /manager | |||
image: "{{ include "container-image" (list . .Values.image) }}" | |||
imagePullPolicy: {{ .Values.image.pullPolicy }} | |||
image: quay.io/redhat-et-ipfs/ipfs-operator:v0.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why but one of the make targets always makes this change. We want to revert this so that the template exists
api/v1alpha1/ipfscluster_types.go
Outdated
const ( | ||
// ReproviderStrategyAll Announces the CID of every stored block. | ||
ReproviderStrategyAll ReproviderStrategy = "all" | ||
// ReproviderStrategyPinned Only announces the pinned CIDs recursively. | ||
ReproviderStrategyPinned ReproviderStrategy = "pinned" | ||
// ReproviderStrategyRoots Only announces the root block of explicitly pinned CIDs. | ||
ReproviderStrategyRoots ReproviderStrategy = "roots" | ||
ReproviderStrategyRoots ReproviderStrategy = "roots" | ||
ExternalStrategyNone ExternalStrategy = "none" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string values themselves should be in Pascal case to be consistent with the Kubernetes style.
So these would be None
, LoadBalancer
, Ingress
api/v1alpha1/ipfscluster_types.go
Outdated
// +optional | ||
Strategy ExternalStrategy `json:"strategy,omitempty"` | ||
// +optional | ||
Annotations map[string]string `json:"interval,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
api/v1alpha1/ipfscluster_types.go
Outdated
@@ -91,6 +105,8 @@ type IpfsClusterSpec struct { | |||
// should use when reproviding content. | |||
// +optional | |||
Reprovider ReprovideSettings `json:"reprovider,omitempty"` | |||
Gateway ExternalSettings `json:"gateway"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a description
controllers/service.go
Outdated
m.Name, | ||
m.Namespace, | ||
"LoadBalancer", | ||
m.Annotations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we're passing the CR's annotations onto the expected service?
controllers/service.go
Outdated
m.Name, | ||
m.Namespace, | ||
"LoadBalancer", | ||
m.Annotations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is passing the same annotations onto the expected service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes needed but it looks good overall, though I did have some questions:
- At the moment it looks like we're providing options to have
LoadBalancer
andIngress
, is there a reason thatClusterIP
isn't supported? - I like that you provided options for what the users can select, but I saw in the code that it only does something when
LoadBalancer
is provided, whereasIngress
andNone
are both doing nothing. IfClusterIP
isn't supported for whatever reason, should we just drop the other fields? - I noticed that you added the option for the user to provide their own annotations, is there a reason we can't provide these values ourselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I have added some observations below.
api/v1alpha1/ipfscluster_types.go
Outdated
@@ -91,6 +105,8 @@ type IpfsClusterSpec struct { | |||
// should use when reproviding content. | |||
// +optional | |||
Reprovider ReprovideSettings `json:"reprovider,omitempty"` | |||
Gateway ExternalSettings `json:"gateway"` | |||
ClusterAPI ExternalSettings `json:"clusterApi"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make Gateway
and ClusterAPI
as optional field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Setting these to omitempty
mutgwsvc, _ := r.serviceGateway(instance, &gwsvc) | ||
mutapisvc, _ := r.serviceAPI(instance, &apisvc) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider moving this under the below if condition on line 170?
Along with this changes we will also need to add |
So as discussed before, This adds the ability to expose ports outside the cluster. At the moment, it supports only "LoadBalancer" strategy, but I expect we will want to add an Ingress strategy also in a future PR. I think some of the old comments have been lost in resolved conversations. The reason for the "AppendAnnotations" is becasuse I am thinking of how we will configure the future Ingress strategy. Ingress Controllers tend to accept configuration through annotations, and this will let you do such things as set Host names and URL routes. Likewise, I the user might have external-dns automation, and this is also controlled by annotation. The LoadBalancer, with no annotations, is probably the simplest, and crudest way to expose the service. One of the comments is asking why we don't support ClusterIP, and we do! But those services are already created. I just didn't want to expose the administrative endpoints If you want to try it out, there is an "gateway" service running now! There is no DNS or anything, it's reachable here on port 8080 a0371fb3c5dc7448e8aff816b8c00454-264540294.us-west-1.elb.amazonaws.com You can try this with anything CID that works on the ipfs.io, cloudflare, or any other IPFS gateway. Try this: same as other IFPS gateways Authentication, etc, can be setup in a future PR to add Ingress Controller support |
fixes: #72
fixes: #71