Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion api/v1alpha1/ipfscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ const (

type ReproviderStrategy string

type ExternalStrategy string

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"
Copy link
Collaborator

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

ExternalStrategyIngress ExternalStrategy = "ingress"
ExternalStrategyLoadBalancer ExternalStrategy = "loadbalancer"
)

type ReprovideSettings struct {
Expand All @@ -54,6 +59,14 @@ type ReprovideSettings struct {
Interval string `json:"interval,omitempty"`
}

type ExternalSettings struct {
// +kubebuilder:validation:Enum={ingress,loadbalancer,none}
// +optional
Strategy ExternalStrategy `json:"strategy,omitempty"`
Copy link
Collaborator

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?

// +optional
Annotations map[string]string `json:"interval,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this for?

}

type followParams struct {
Name string `json:"name"`
Template string `json:"template"`
Expand All @@ -72,6 +85,8 @@ type IpfsClusterSpec struct {
Replicas int32 `json:"replicas"`
Networking networkConfig `json:"networking"`
Follows []followParams `json:"follows"`
Gateway ExternalSettings `json:"gateway"`
ClusterAPI ExternalSettings `json:"clusterApi"`
// Reprovider Describes the settings that each IPFS node
// should use when reproviding content.
// +optional
Expand Down
24 changes: 24 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions config/crd/bases/cluster.ipfs.io_ipfsclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ spec:
type: object
spec:
properties:
clusterApi:
properties:
interval:
additionalProperties:
type: string
type: object
strategy:
enum:
- ingress
- loadbalancer
- none
type: string
type: object
clusterStorage:
type: string
follows:
Expand All @@ -48,6 +61,19 @@ spec:
- template
type: object
type: array
gateway:
properties:
interval:
additionalProperties:
type: string
type: object
strategy:
enum:
- ingress
- loadbalancer
- none
type: string
type: object
ipfsStorage:
anyOf:
- type: integer
Expand Down Expand Up @@ -87,8 +113,10 @@ spec:
url:
type: string
required:
- clusterApi
- clusterStorage
- follows
- gateway
- ipfsStorage
- networking
- public
Expand Down
8 changes: 4 additions & 4 deletions controllers/circuitrelay_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (r *CircuitRelayReconciler) serviceRelay(
{
Name: "swarm",
Protocol: corev1.ProtocolTCP,
Port: portSwarm,
Port: portIpfsSwarm,
TargetPort: intstr.FromString("swarm"),
},
// Commented out because some load balancers don't support TCP+UDP:(
Expand Down Expand Up @@ -420,18 +420,18 @@ func (r *CircuitRelayReconciler) deploymentRelay(
Ports: []corev1.ContainerPort{
{
Name: "swarm",
ContainerPort: portSwarm,
ContainerPort: portIpfsSwarm,
Protocol: "TCP",
},
{
// Should this port number be the same as portSwarm or should it be a different one?
Name: "swarm-udp",
ContainerPort: portSwarmUDP,
ContainerPort: portIpfsSwarmUDP,
Protocol: "UDP",
},
{
Name: "pprof",
ContainerPort: portPprof,
ContainerPort: portIpfsPprof,
Protocol: "UDP",
},
},
Expand Down
35 changes: 0 additions & 35 deletions controllers/configmap.go

This file was deleted.

19 changes: 14 additions & 5 deletions controllers/ipfscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,36 @@ func (r *IpfsClusterReconciler) createTrackedObjects(
) map[client.Object]controllerutil.MutateFn {
sa := corev1.ServiceAccount{}
svc := corev1.Service{}
gwsvc := corev1.Service{}
apisvc := corev1.Service{}
cmScripts := corev1.ConfigMap{}
cmConfig := corev1.ConfigMap{}
secConfig := corev1.Secret{}
sts := appsv1.StatefulSet{}

mutsa := r.serviceAccount(instance, &sa)
mutsvc, svcName := r.serviceCluster(instance, &svc)

mutgwsvc, _ := r.serviceGateway(instance, &gwsvc)
mutapisvc, _ := r.serviceAPI(instance, &apisvc)

Copy link
Contributor

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?

mutCmScripts, cmScriptName := r.ConfigMapScripts(ctx, instance, &cmScripts)
mutSecConfig, secConfigName := r.SecretConfig(ctx, instance, &secConfig, []byte(clusterSecret), []byte(privateString))
mutCmConfig, cmConfigName := r.configMapConfig(instance, &cmConfig, peerID.String())
mutSts := r.statefulSet(instance, &sts, svcName, secConfigName, cmConfigName, cmScriptName)
mutSecConfig, secConfigName := r.SecretConfig(ctx, instance, &secConfig, []byte(clusterSecret), []byte(peerID.String()), []byte(privateString))
mutSts := r.statefulSet(instance, &sts, svcName, secConfigName, cmScriptName)

trackedObjects := map[client.Object]controllerutil.MutateFn{
&sa: mutsa,
&svc: mutsvc,
&cmScripts: mutCmScripts,
&cmConfig: mutCmConfig,
&secConfig: mutSecConfig,
&sts: mutSts,
}

if instance.Spec.Gateway.Strategy == clusterv1alpha1.ExternalStrategyLoadBalancer {
Copy link
Collaborator

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?

trackedObjects[&gwsvc] = mutgwsvc
}
if instance.Spec.ClusterAPI.Strategy == clusterv1alpha1.ExternalStrategyLoadBalancer {
trackedObjects[&apisvc] = mutapisvc
}
return trackedObjects
}

Expand Down
2 changes: 2 additions & 0 deletions controllers/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (r *IpfsClusterReconciler) SecretConfig(
m *clusterv1alpha1.IpfsCluster,
sec *corev1.Secret,
clusterSecret,
bootstrapPeerID,
bootstrapPrivateKey []byte,
) (controllerutil.MutateFn, string) {
secName := "ipfs-cluster-" + m.Name
Expand All @@ -59,6 +60,7 @@ func (r *IpfsClusterReconciler) SecretConfig(
}
expectedSecret.Data["CLUSTER_SECRET"] = clusterSecret
expectedSecret.Data["BOOTSTRAP_PEER_PRIV_KEY"] = bootstrapPrivateKey
expectedSecret.Data["BOOTSTRAP_PEER_ID"] = bootstrapPeerID
} else {
// secret exists.
// test if we need to add more identieis
Expand Down
Loading